Class ReaderM
- java.lang.Object
-
- java.lang.Thread
-
- ptolemy.actor.lib.jjs.modules.IMUSensor.ReaderM
-
- All Implemented Interfaces:
java.lang.Runnable
public class ReaderM extends java.lang.ThreadStart a SerialPortreader and interpret the incoming bytes from the serial port.- Since:
- Ptolemy II 11.0
- Version:
- $Id$, $Id$
- Author:
- Hunter Massey and Rajesh Kuni
- See Also:
SerialPortController- Pt.AcceptedRating:
- Pt.ProposedRating:
- Yellow Hunter
-
-
Field Summary
Fields Modifier and Type Field Description booleanisStartTrue when the thread has been started.
-
Constructor Summary
Constructors Constructor Description ReaderM(int com, int baudRate, int window)Construct a ReaderM.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CircularFifoQueue<int[]>getBuffer()Return the sample buffer.intgetBufIndex()Return the current index in the circular buffer.int[]getNextUnreadSample()Get the next unread sample from the sample buffer.voidpreProcess(int[] raw)Grab the individual raw sensor (accelerometer and gyroscope) values and store them into the circular sample buffer as a 6 integer array.voidrun()Read the packets from the IMU and decode them.voidstopRead()Close the serial port and end the connection.intUCharToInt(char a, char b)Convert two 'unsigned char's to an integer by shifting and adding.-
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
-
run
public void run()
Read the packets from the IMU and decode them.- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
preProcess
public 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.- Parameters:
raw- The integer array containing all the sensor values (ADC values)
-
getBuffer
public CircularFifoQueue<int[]> getBuffer()
Return the sample buffer.- Returns:
- The circular sample buffer
-
stopRead
public void stopRead()
Close the serial port and end the connection.
-
getBufIndex
public int getBufIndex()
Return the current index in the circular buffer.- Returns:
- the current write index into the circular buffer
-
getNextUnreadSample
public int[] getNextUnreadSample()
Get the next unread sample from the sample buffer.- Returns:
- the current read index into the circular buffer
-
UCharToInt
public int UCharToInt(char a, char b)Convert two 'unsigned char's to an integer by shifting and adding. As a note, Java does not actually have unsigned values but we treat these chars as such.- Parameters:
a- The most significant 8 bits of the integer in char formb- The least significant 8 bits of the integer in char form- Returns:
- The integer value from the two input unsigned chars
-
-