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 »

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

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by Hitesh »

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,

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

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by yorke102 »

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

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by Hitesh »

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,

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

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by TimOster »

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: 401
Joined: Tue Oct 21, 2014 3:07 pm

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by AndrewA »

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

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by Hitesh »

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,

acherone
User
User
Posts: 2
Joined: Thu Feb 18, 2021 5:02 pm

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Post by acherone »

Hitesh wrote:
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,
Do you mean the time from callback call to callback call (or from PICO_OK over PICO_BUSY to PICO_OK) as the time it takes to execute a single iteration of the loop to collect data?

Post Reply