Class SerialPortReader
- java.lang.Object
-
- java.lang.Thread
-
- ptolemy.actor.lib.jjs.modules.IMUSensor.SerialPortReader
-
- All Implemented Interfaces:
java.lang.Runnable
public class SerialPortReader extends java.lang.Thread
Read in bytes from the serial port connection and provide them to the ReaderM class for decoding of the unique packet format used by the IMU sensors.- Since:
- Ptolemy II 11.0
- Version:
- $Id$, $Id$
- Author:
- Hunter Massey
- See Also:
SerialPortController
,ReaderM
- Pt.AcceptedRating:
- Pt.ProposedRating:
- Yellow Hunter
-
-
Constructor Summary
Constructors Constructor Description SerialPortReader()
Construct a serial port reader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
closePort()
Closes the serial port connection.int
init(int portNumber)
Initialize the serial port and connect a BufferedInputStream to the serialPort.java.lang.String
readFromPort()
Takes the next single value from the buffer of Characters read from the input stream.void
run()
Run method for this class.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, suspend, toString, yield
-
-
-
-
Method Detail
-
init
public int init(int portNumber)
Initialize the serial port and connect a BufferedInputStream to the serialPort.- Parameters:
portNumber
- The number of theport- Returns:
- 1 if the initialization was successfull, -1 otherwise.
-
run
public void run()
Run method for this class. Starts a thread that constantly reads in from serial port stream A BufferedInputStream connected to the serial port is read into a LinkedBlockingQueue.- Specified by:
run
in interfacejava.lang.Runnable
- Overrides:
run
in classjava.lang.Thread
-
readFromPort
public java.lang.String readFromPort()
Takes the next single value from the buffer of Characters read from the input stream.- Returns:
- the character read from serial port as a String
-
closePort
public void closePort()
Closes the serial port connection. Called by class that owns this object to stop serial port connection
-
-