Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

read burst string

Dear LV programmers, I have question about reading a burst string from a serial device. In my case each burst string is a string which starts with AA AA xx xx xx xx (hexadecimal, where the xx represent a byte of data). AA AA is used for synchronization and is sent before each burst string. After sending the command to start burst string, the device constantly sends the data (i am reading it in a while loop). I am having a problem with reading. What is the most prudent way to read such string - getting the data between AA AA and the next AA AA? How many bytes should i read?Should I flush the buffer after each burst or not? I can attach the vi tommorow, but i think the explanation is clear? I would be very grateful for any help or opinion. Best regards, K

https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 1 of 4
(3,345 Views)

keep reading what is already present, do not flush because flushing can destroy characters.

In a separate loop proces the data you get in. 

Check the producer consumer template.

 

greetings from the Netherlands
0 Kudos
Message 2 of 4
(3,341 Views)
Thank you for the answer. I need real-time 8 ms loop (the device supports this). How should i determine how many bytes to read each iteration? The device sends this string burst until i send the stop command (even if i dont read the data)... My string is for example AA AA 04 E5 04 D5 AA AA etc... i need to extract the middle part. Sometimes the string is AA 04 E5 04 D5 AA AA 04, depending on how many bytes i read... I think i need to wait for AA AA and then read to the next AA AA... This is where i am a little lost... Thank you.

https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
0 Kudos
Message 3 of 4
(3,338 Views)

reading and processing should be apart, in that way you can skip data when it comes too fast.

So it boils down to string processing

match string for three A's and eventually the next.

While the next 3 A's are not in you can just read the available bytes at port, and add to the previous data.

Than hand over for processing the interesting data to a consumer part.

greetings from the Netherlands
Message 4 of 4
(3,336 Views)