Test and Measurement Forum

ps2000_run_block not working in a loop

Discussion forum for the new Picoscope Linux software

ps2000_run_block not working in a loop

Postby bwbarco » Thu Oct 05, 2017 8:29 am

We want to acquire a sine wave 1KHz audio signal over a longer period of time.
This is achieved by running ps2000_run_block in a loop until the time has expired.
After setting up the acquisition, timebase and trigger, the loop below is executed.

The first run, it works fine: ps2000_ready returns 1 as expected. The data is collected and processed.
The second run, ps2000_ready keeps returning 0, making the loop hang - unless a key is pressed.

This is code I inherited, so it looks OK to me -- according the documentation of ps2000_run_block.
Any ideas what we are doing wrong?

I had to cut the code real short, due to some blocking mechanism on this forum that did not allow me to paste the full code in a code block:

while ()
{
ps2000_run_block ( unitOpened.handle, no_of_samples, timebase, oversample, &time_indisposed_ms );
flag = ps2000_ready ( unitOpened.handle ); --> flag is 1 the first time, but fails the second time ( remains 0 )
ps2000_stop ( unitOpened.handle );
}
bwbarco
Newbie
 
Posts: 0
Joined: Tue Oct 03, 2017 9:12 am

Re: ps2000_run_block not working in a loop

Postby bwbarco » Thu Oct 05, 2017 2:48 pm

This one is also solved: the scope does not trigger the second time and hence the loop keeps waiting for a valid buffer.
Solved by adding a time check to the wait loop.

My apologies for these relatively stupid questions, but we are entirely new to the code.
bwbarco
Newbie
 
Posts: 0
Joined: Tue Oct 03, 2017 9:12 am

Re: ps2000_run_block not working in a loop

Postby Hitesh » Fri Oct 06, 2017 10:29 am

Hi bwbarco,

Thanks for the update :)

If you require any further assistance with the API functions, please post back here or contact us via support@picotech.com

Regards,
Hitesh

Technical Support Engineer
Hitesh
Site Admin
Site Admin
 
Posts: 2498
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to PicoScope for Linux

Who is online

Users browsing this forum: No registered users and 0 guests