Frameworks > Serial Framework

Seria Read Problem

(1/1)

x49:
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

Mike Petrichenko:
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.

Mike Petrichenko:
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.

Navigation

[0] Message Index

Sitemap 1 2 3 4 5 6 7 
Go to full version