[prev in list] [next in list] [prev in thread] [next in thread]
List: rxtx
Subject: Re: [Rxtx] clear input buffer on startup.
From: "M.Dec-GM" <mariusz.dec () gmail ! com>
Date: 2011-01-20 6:17:38
Message-ID: 07CF7AAE837349EF920DB9DEAE0952BB () mdam3
[Download RAW message or body]
----- Original Message -----
From: "Gerrit Polder" <gerrit.polder@solcon.nl>
To: <rxtx@qbang.org>
Sent: Wednesday, January 19, 2011 9:37 PM
Subject: [Rxtx] clear input buffer on startup.
> how can I clear the input buffer on startup,
Before opening port you are creating a new instance of the port in Java and
OS.
In this "time point" java starts RXTX native part and this part of RXTX
connects to device layer in OS.
Next step is opening the port.
If you have incoming data in this moment, it means that device layer don't
cleans buffers while starting (driver's feature - programmer's
mistake/error) or external device is sending data and OS is receiving it.
So in fact, flushing/cleaning input buffer helps a little because you never
don't know what has happened.
!! I haven't never seen waste data in RXTX buffer on open(), so it looks
that RXTX and my OS drivers (FTDI) are ok. !!
What to do:
Data in EACH transmission needs header and trailer, checksum and length of
the block are very useful as well.
If you are receiving data, you have to identify what data means - you have
to identify block and read from this block
Your incoming part of the app should look for the first header and flush
data until header will be identified.
Later you should wait for the trailer or read data using packet length
(usually after header), finally check the cheksum (usually on the end, may
be in the role of the trailer).
Succesfullly checked data should be transferred to app, damaged data should
be flushed.
Regards
Mariusz
_______________________________________________
Rxtx mailing list
Rxtx@qbang.org
http://mailman.qbang.org/mailman/listinfo/rxtx
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic