public class ReaderM
extends java.lang.Thread
SerialPortController
Modifier and Type | Field and Description |
---|---|
(package private) int |
baudRate
The baud rate of the serial port.
|
(package private) int |
com
The communication port number.
|
(package private) char |
dataCount
The current count of data bytes that have been read in from a packet.
|
(package private) static char |
DLE
"Data Link Escape" character, signals that next value is a control value.
|
(package private) static char |
EOT
"End of Transmission" character, signals end of a single packet.
|
boolean |
isStart
True when the thread has been started.
|
(package private) SerialPortReader |
portReader
SerialPortReader takes care of serial port communication on a lower level.
|
(package private) static char |
SOH
"Start of Header" character, signals start of non-data header value.
|
Constructor and Description |
---|
ReaderM(int com,
int baudRate,
int window)
Construct a ReaderM.
|
Modifier and Type | Method and Description |
---|---|
CircularFifoQueue<int[]> |
getBuffer()
Return the sample buffer.
|
int |
getBufIndex()
Return the current index in the circular buffer.
|
int[] |
getNextUnreadSample()
Get the next unread sample from the sample buffer.
|
void |
preProcess(int[] raw)
Grab the individual raw sensor (accelerometer and gyroscope) values and
store them into the circular sample buffer as a 6 integer array.
|
void |
run()
Read the packets from the IMU and decode them.
|
void |
stopRead()
Close the serial port and end the connection.
|
int |
UCharToInt(char a,
char b)
Convert two 'unsigned char's to an integer by shifting and adding.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public boolean isStart
char dataCount
int com
int baudRate
SerialPortReader portReader
static final char DLE
static final char SOH
static final char EOT
public ReaderM(int com, int baudRate, int window)
com
- The comm port number to connect tobaudRate
- The baud rate at which the connection runswindow
- The window size of the circular sample bufferpublic void run()
run
in interface java.lang.Runnable
run
in class java.lang.Thread
public void preProcess(int[] raw)
raw
- The integer array containing all the sensor values (ADC values)public CircularFifoQueue<int[]> getBuffer()
public void stopRead()
public int getBufIndex()
public int[] getNextUnreadSample()
public int UCharToInt(char a, char b)
a
- The most significant 8 bits of the integer in char formb
- The least significant 8 bits of the integer in char form