Test and Measurement Forum

ps2000_get_streaming_last_values flaws and clarification

Post your C and C++ discussions here

ps2000_get_streaming_last_values flaws and clarification

Postby Timmmm » Mon Jul 17, 2017 3:15 pm

Hi, I'd appreciate a few clarifications:

1. Is the PS2000A API older than the PS2000 one? You should probably make this clear if true because I started developing a program using the PS2000A API, since I have a PS2204A device (pretty close name right?) but actually it uses the PS2000 API (apparently). PS2000A certainly sounds newer than PS2000.

2. The ps2000aGetStreamingLatestValues() function takes a `void*` user data parameter, like all properly designed C callback APIs must do. But the ps2000_get_streaming_last_values() function doesn't have this. This leads me to believe that you realised the mistake and PS2000A is actually the new API. What is going on? Do I have to resort to global variable hacks like the PS2000 examples do?

3. It's not clear at all when any by whom the streaming callback is called. Is it guaranteed to be called while in ps2000_get_streaming_last_values()? Could it be called after that function has returned? Is it called on a different thread? Etc. etc. All this information is necessary to write safe programs.

Thanks,

Tim
Timmmm
Newbie
 
Posts: 0
Joined: Mon Jul 17, 2017 3:05 pm

Re: ps2000_get_streaming_last_values flaws and clarification

Postby Hitesh » Tue Jul 18, 2017 9:44 am

Hi Tim,

The ps2000a driver is relatively recent (dated from 2011) compared to the ps2000 driver. The copyright years on the Programmer's Guide indicates the year when the Programmer's Guide was first published.

The PicoScope 2204A and 2205A are direct replacements for the PicoScope 2204 and 2205 respectively and hence use the same driver model so it is an anomaly. We do list in the Programmer's Guides as to which models are supported by a driver and also via this forum post.

The ps2000 driver uses an older driver model and with testing we carried out when updating the SDK examples, we used global variables to ensure that the data could be copied out of the driver buffers to an application buffer for each channel.

The streaming callback will be called when the device has data available - the ps2000_get_streaming_last_values() function only registers the callback function with the driver. In our C example we check the total number of samples to see if any new data has been received.

Unlike the driver model for the ps2000a driver, the callback could be called more than once during the execution of each loop during the streaming data collection process, so our advice would be to setup a large application buffer for each channel and ensure that the data is copied into the next available section of the buffer when received as per the example.

Regards,
Hitesh

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

Re: ps2000_get_streaming_last_values flaws and clarification

Postby Timmmm » Tue Jul 18, 2017 11:57 am

Ugh I already wrote a long post but Cloudflare's anti-spam protection lost it so this will be a bit shorter and more frustrated, sorry:

Ok that makes sense about the supported models for each driver. Table is useful. Weird that you don't have one SDK that supports all models but whatever. Are there any plans to support the 2204A with the PS2000A driver?

I'm afraid you haven't answered the question about ps2000_get_streaming_last_values(). Suppose I have this code:

Code: Select all
printf("A");
ps2000_get_streaming_last_values(..., my_callback);
printf("C");

void my_callback(...) {
    printf("B");
}


In my testing it always prints "ABC" or "ABBC" or "AC". But there is nothing in the documentation to say that it will never print "ACB". You need to be explicit about this to allow people to write correct programs.
Timmmm
Newbie
 
Posts: 0
Joined: Mon Jul 17, 2017 3:05 pm

Re: ps2000_get_streaming_last_values flaws and clarification

Postby Hitesh » Tue Jul 18, 2017 1:59 pm

Hi Tim,

Unfortunately, the PicoScope 2204A will not be supported by the ps2000a driver functions in the future.

Apologies if the explanation which referenced the callback being called more than once didn't provide a complete answer.

I've run some tests here again and will request an update of the Programmer's Guide if possible. If data is not available from the device, the callback function will not be called when you call ps2000_get_streaming_last_values(). If there is data available when you call the function, the callback will be called, and on some occasions this can be twice which is why we recommend using a large application buffer to copy data into.

Regards,
Hitesh

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


Return to C and C++

Who is online

Users browsing this forum: No registered users and 0 guests