RishiGupta12 / SerialPundit

Serial port communication in Java - FTDI D2XX, HID API, X/Y modem
GNU Affero General Public License v3.0
125 stars 56 forks source link

Get InputStream from SerialComManager #32

Closed russellhoff closed 6 years ago

russellhoff commented 6 years ago

I'm about to make use of marine api.

To start off, an InputStream is needed, but I don't know whether the first line is correct or not:

InputStream is = (InputStream) scm.getIOStreamInstance(SerialComManager.InputStream, handleGps, SMODE.NONBLOCKING);
SentenceReader sr = new SentenceReader(is);
sr.addSentenceListener(this);
sr.start();

If not, is there any other way?

Thanks!

RishiGupta12 commented 6 years ago

Example1: https://github.com/RishiGupta12/SerialPundit/tree/master/applications/byte-stream-binary-jar-integrate Example2: https://github.com/RishiGupta12/SerialPundit/blob/master/tests/test53-byteStream/src/test53/Test53.java Example3: https://github.com/RishiGupta12/SerialPundit/blob/master/tests/test54-closeport-Blockingread/src/test54/Test54.java

Expect some delay in my responses as I will be travelling to other country for vacations.

russellhoff commented 6 years ago

Thank you for your help @RishiGupta12, I hope those examples are enough.

russellhoff commented 6 years ago

I've taken a look at the examples, and SerialComInByteStream is always used. What I need is to get a java.io.InputStream. Is a simple cast enough (InputStream is = (InputStream) scm.getIOStreamInstance(SerialComManager.InputStream, handleGps, SMODE.NONBLOCKING);)?

RishiGupta12 commented 6 years ago
  1. SerialComInByteStream extends InputStream in serial pundit. Any methods of InputStream are supported by SerialComInByteStream class (line 35 https://github.com/RishiGupta12/SerialPundit/blob/master/modules/serial/src/com/serialpundit/serial/SerialComInByteStream.java#L35)