Re: serial port question.
- From: chris dewbery <chris.dewbery@xxxxxxxxxxxxxx>
- Date: Wed, 31 May 2006 11:49:18 +1200
But what about reads? How do I know how much more to read when I am
sent a variable amount of data?
i'm not sure exactly what you are asking so i could be completely off target
this really depends on the format of the data and the protocol you are using,
perhaps you should look at using a packet framing using a method such as SLIP,
or just read the data into a circular buffer and then break the buffer into
an alternative method is to use an interpacket gap time, however then you must
guarantee that an entire packet can be delivered without exceeding the gap time.
also i suggest looking at the select() call if you haven't done so already.
this will allow you to wait for data to arrive before calling the read() command.