GetStreamingLatestValues() - 'PICO_BUSY'

Post your .Net discussions here
Post Reply
yorke102
Newbie
Posts: 0
Joined: Tue May 16, 2017 6:22 am

GetStreamingLatestValues() - 'PICO_BUSY'

Post by yorke102 » Tue May 16, 2017 6:46 am

I'm creating streaming capture program using GetStreamingLatestValues().
It is roughly working now, but I'm a bit puzzled.

1. How can I assure the program captured all data, or how can I count the number of data dropped ? I feel this feature is important for me because I need up to 5 or 10 Mega samples per Sec capturing.

2. How should I handle 'PICO_BUSY' status ? Should I just neglect and retry this code ?
Assuming, 'PICO_BUSY' means 'driver is busy just now', I wrote like,

Code: Select all

   status = Imports.GetStreamingLatestValues(_handle, callback, param);
   if (status == PICO_BUSY)
   {
       Thread.Sleep(10);
       status = Imports.GetStreamingLatestValues(_handle, callback, param);
   }
  //PICO_BUSY status still happens. 
But PICO_BUSY status still happens. Does it mean some error status ?
Thanks in advance.

Hitesh
Site Admin
Site Admin
Posts: 2810
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by Hitesh » Tue May 16, 2017 8:39 am

Hi yorke102,

To ensure the best possible chance of collecting the data without dropping too much data, you should set the size of the overview buffer to be a little larger than the number of samples that would be collected in the time it takes to execute a single iteration of the loop to collect data.

When you get a 'PICO_BUSY' status code, you should wait a little while before calling GetStreamingValues() again.

Which specific PicoScope device are you using?

Regards,
Hitesh

Technical Support Engineer

yorke102
Newbie
Posts: 0
Joined: Tue May 16, 2017 6:22 am

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by yorke102 » Wed May 17, 2017 7:49 am

Dear Hitesh,

Thank you, excuse me for lack of information.
I'm using PicoScope 3205B and 3206B now, and palnnig to use 2205MSO also.

As to "the size of the overview buffer", if my understanding is correct,
my program assigned 640kbytes (for 320k samples) .
I feel it is large enough, isn't it ?
My program is like below code.

Code: Select all

BufferSize = 320000
buffers = new short[_channelCount * 2][];
for(int chan=0; chan< _channelCount; chan++)
{
	buffers[chan] = new short[BufferSize];
	buffers[chan + 2] = new short[tempBufferSize];
	status = Imports.SetDataBuffers(_handle, (Imports.Channel)(chan),
  buffers[chan], buffers[chan+2], (int)BufferSize, 0,
  Imports.RatioMode.None );
}

  appBuffer = new short[ _channelCount * BufferSize ];
  intval = 240;
  units = Imports.ReportedTimeUinits.NanoSeconds;
  ratioMode = Imports.RatioMode.None;
  
  do{
    status = Imports.RunStreaming(_handle, ref interval, units, 2000, 4000,
       false, 1, ratioMode, BufferSize);
 #if status != PICO_OK; do somothing to recover or wait;
     ...
  } while (status != PICO_OK);

 #prepare the output file;
 bwriter = new System.IO.BinaryWriter(File.OpenWrite("capdata.bin"));

while (! stop_condition)
{
	status = Imports.GetStreamingLatestValues(_handle, callback, param);
	#
	# if status == PICO_OK and callback has done job, captured data is in
'appBuffer';
	# output them
	for(int i=0;i<_sampled; i++)
	  bwriter.Write((short)appBuffers[i]);
}
#
 Imports.Stop(_handle);
 bwrite.close();
Do you have any hits how many miliseconds I should wait before
calling GetStreamingValues() again, when PICO_BUSY detected ?

For example,
Assuming, preTrigger + postTrigger <= 8000 and sample-interval is 240 nano Sec,
calculating; 8000 x 240 nano = 1920 micro ,
2 m Sec wait should be enough ? I'm not sure.

Hitesh
Site Admin
Site Admin
Posts: 2810
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by Hitesh » Mon May 22, 2017 4:10 pm

Hi yorke102,

Have you timed how long it takes for the loop to execute?

What happens if you set a sleep of 1 or 2 milliseconds in the loop? Have you checked the data to see if there is any missing data?

Regards,
Hitesh

Technical Support Engineer

TimOster
Newbie
Posts: 0
Joined: Mon Dec 01, 2014 5:36 pm

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by TimOster » Thu Jul 19, 2018 3:28 pm

since this seems to be an old thread, I'll hijack it...

Can you just use something like (pseudo code) While PICO_BUSY = true...wait some time, check again, then grab the data when it's no longer true?

That way you won't need to know exactly how long it will take.

AndrewA
PICO STAFF
PICO STAFF
Posts: 196
Joined: Tue Oct 21, 2014 3:07 pm

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by AndrewA » Wed Jul 25, 2018 1:41 pm

Yes polling the status code in loop is better. Like this-

(pseudo code)
While PICO_BUSY == true
(...wait 1ms,
check again)
then grab the data from buffer

Our LabVIEW example does something like this but uses the wrapper functions.
Regards Andrew
Technical Specialist

Hitesh
Site Admin
Site Admin
Posts: 2810
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by Hitesh » Mon Aug 06, 2018 10:30 am

Just to add to AndrewA's response, if the call to GetStreamingLatestValues() returns something other than PICO_OK, handle the status code accordingly in your loop e.g. if it is PICO_BUSY, wait a short while before calling the functions again.

Hope this helps,
Hitesh

Technical Support Engineer

Post Reply