[Rxtx] lifetime of the serialEvent(SerialPortEvent args0)
Michael Erskine
msemtd at googlemail.com
Fri Jul 30 12:32:53 MDT 2010
On 30 July 2010 01:41, Nejd Zrelli <n.zrelli at tu-bs.de> wrote:
> The strange thing i
> get is that the serialEvent() will be partially executed!! some
> instructions will be simply ignored! i don't know why..
Hi Zrelli,
Do you mean that the serialEvent is triggered prior to a complete
message being received? That is entirely probable and you should
structure your data received handler to cope with that. Every protocol
handler I write takes the form of a state machine: bytes come in and
messages come out -- this is a general purpose pattern for all
structured communications, be it serial, TCP/IP, or what have you.
BTW: if you protocol required data sends at regular periods then use a
separate thread rather than abusing the event handler thread. Use
timeouts appropriate to the devices that are communicating.
Regards,
Michael Erskine.
More information about the Rxtx
mailing list