public class SerialCommunicator.SerialReader
extends java.lang.Object
implements gnu.io.SerialPortEventListener
Constructor and Description |
---|
SerialReader(PacketHandler ph,
java.io.InputStream in) |
Modifier and Type | Method and Description |
---|---|
void |
clearBuffer()
Clear the input buffer; This function should be called when a
communication error occurs.
|
int[] |
readOrDie(int howMany,
long timeoutBetweenBytes)
Try reading some bytes from the serial port we are connected to,
returning them as an array of integers from 0 to 255; If we have been
waiting for too long, throw a
TimeoutException instead |
void |
serialEvent(gnu.io.SerialPortEvent arg0)
This method is a listener method, which automatically gets called
when a new SerialPortEvent occurs.
|
public SerialReader(PacketHandler ph, java.io.InputStream in)
public void clearBuffer()
public int[] readOrDie(int howMany, long timeoutBetweenBytes) throws java.util.concurrent.TimeoutException, java.io.IOException
TimeoutException
insteadhowMany
- how many bytes to wait fortimeoutBetweenBytes
- the maximum time period for which to wait
for another byte before throwing a TimeoutException
java.util.concurrent.TimeoutException
java.io.IOException
public void serialEvent(gnu.io.SerialPortEvent arg0)
serialEvent
in interface gnu.io.SerialPortEventListener
arg0
- the SerialPortEvent
object, containing the
information about the event that occured.