Wireless Communication Library Support Forum

Frameworks => Serial Framework => Topic started by: x49 on November 30, 2018, 11:42:20 AM

Title: Seria Read Problem
Post by: x49 on November 30, 2018, 11:42:20 AM
Hi

i use the Serial Client Demo to test the component but already in the Demo program I receive a lot of datasets that contains only a part of the rfid dongle. Is it normal?How can i see the end of the received Message/Text?

BR

Georg
Title: Re: Seria Read Problem
Post by: Mike Petrichenko on November 30, 2018, 12:36:33 PM
Hi,

yes, that is normal. In fact there is no way for hardware to know when your message ends (except you do not use something like EOF). So there are 2 ways:

1. You have to know your message length (if the lengthis fixed).
2. You should send length in first 2 bytes if the length is not fixed.
3. Use EOF (for example CRLF) to indicate end of message.

It is good to allocate internal buffer (string type is enough if you send strings, otherwise bytes array is good idea also). And copy received data into this buffer until you get your EOF or until length reached. The process your message and clear the internal buffer.
Title: Re: Seria Read Problem
Post by: Mike Petrichenko on November 30, 2018, 12:38:00 PM
I forgot to say that in case you use hardware EOF you can use events (for XCHAR, EOF and others) to check when message ends.