Author Topic: Seria Read Problem  (Read 59 times)

Offline x49

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
Seria Read Problem
« 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

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3092
  • Karma: 1000
    • Wireless Communication Libraries
Re: Seria Read Problem
« Reply #1 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.

Offline Mike Petrichenko

  • Bluetooth Framework Developer
  • Administrator
  • Hero Member
  • *****
  • Posts: 3092
  • Karma: 1000
    • Wireless Communication Libraries
Re: Seria Read Problem
« Reply #2 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.

 

Sitemap 1 2 3 4 5 6 7 8 9