Test and Measurement Forum

GetStreamingLatestValues() - 'PICO_BUSY'

Post your .Net discussions here

GetStreamingLatestValues() - 'PICO_BUSY'

Postby 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.
yorke102
Newbie
 
Posts: 0
Joined: Tue May 16, 2017 6:22 am

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Postby 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
Hitesh
Site Admin
Site Admin
 
Posts: 2389
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Postby 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.
yorke102
Newbie
 
Posts: 0
Joined: Tue May 16, 2017 6:22 am

Re: GetStreamingLatestValues() - 'PICO_BUSY'

Postby 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
Hitesh
Site Admin
Site Admin
 
Posts: 2389
Joined: Tue May 31, 2011 3:43 pm
Location: St. Neots, Cambridgeshire


Return to .Net Languages (C#, VB.Net, .)

Who is online

Users browsing this forum: No registered users and 0 guests