Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

Receive incorrect information through serial


@pooya_B wrote:

I need fast processing and I can not use the set of checks. I tried this way before and it slowed down data receiving a lot and there was a problem in processing my information.


You are talking over a serial port.  Even at 115200 baud, you are only getting a byte every 868us.  It doesn't take nearly this long to do a simple sum check.  But I think you missed the point:  You have to do some type of checks to make sure you got a proper frame or all of your data will be skewed.

 

 


@pooya_B wrote:

To start the message, I send two values in binary, the decimal is 65 and 122, and then two bytes of data related to my analog data. A fixed value of 112 is sent to separate the previous data value and two bytes of data for temperature, then another fixed value of 90 and two bytes of data are sent for time.


That's weird to have set bytes inside of your data, even to separate the types of data.  I would propose moving the 112 and 90 to the end of the frame.  This will make life easier on the receiver.  It can read a single byte at a time until 0x41 (65) is read, then read another byte and verify it is 0x7A (112), then read the other 8 bytes, verifying the last two are 0x70 (112) and 0x5A (90).  If the verification passes, then you can process the 6 bytes in the middle however you need to.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
Download All
Message 11 of 14
(855 Views)

Can we assume that once we have a correct frame, all following frames will be aligned too?

 

Maybe what you should do is continuously read the data into a U8 array buffer, then take successive 10 element subsets, mask off the data using bitwise operations and compare with you packet pattern. Whenever a match is found, parse the data and send it to further processing, else continue. Once you have an aligned frame, you can guess the position of the next frame with high probability.

0 Kudos
Message 12 of 14
(846 Views)

Hi

thank you very much, your solution was excellent and the information clutter was fixed.

0 Kudos
Message 13 of 14
(844 Views)

Thank you very much for your help. My problem was solved.

0 Kudos
Message 14 of 14
(843 Views)