-
- All Implemented Interfaces:
-
com.qualcomm.hardware.modernrobotics.comm.ReadWriteRunnable
,com.qualcomm.robotcore.eventloop.SyncdDevice
,java.lang.Runnable
public class ReadWriteRunnableStandard implements ReadWriteRunnable
Main loop that copies the read/write buffer from/to the device
Note that this implementation is specific to Modern Robotics, as it has knowledge of the Modern Robotics datagram formats, etc.
-
-
Field Summary
Fields Modifier and Type Field Description public final static String
TAG
protected volatile SyncdDevice.ShutdownReason
shutdownReason
protected volatile boolean
acceptingWrites
protected ReadWriteRunnable.Callback
callback
protected RobotUsbModule
owner
-
Constructor Summary
Constructors Constructor Description ReadWriteRunnableStandard(Context context, SerialNumber serialNumber, RobotUsbDevice device, int monitorLength, int startAddress, boolean debug)
Constructor
-
Method Summary
Modifier and Type Method Description SyncdDevice.ShutdownReason
getShutdownReason()
boolean
getAcceptingWrites()
void
setAcceptingWrites(boolean acceptingWrites)
void
setCallback(ReadWriteRunnable.Callback callback)
RobotUsbModule
getOwner()
void
setOwner(RobotUsbModule owner)
boolean
writeNeeded()
void
resetWriteNeeded()
void
write(int address, Array<byte> data)
Write to device void
suppressReads(boolean suppress)
Array<byte>
readFromWriteCache(int address, int size)
Read from the device write cache Array<byte>
read(int address, int size)
Read from device void
executeUsing(ExecutorService service)
void
close()
Close this read-write-runnable ReadWriteRunnableSegment
createSegment(int key, int address, int size)
void
destroySegment(int key)
ReadWriteRunnableSegment
getSegment(int key)
void
queueSegmentRead(int key)
void
queueSegmentWrite(int key)
void
run()
Main read / write loop void
drainPendingWrites()
-
Methods inherited from class java.lang.Runnable
run
-
Methods inherited from class com.qualcomm.robotcore.eventloop.SyncdDevice
getOwner, getShutdownReason, setOwner
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
-
Constructor Detail
-
ReadWriteRunnableStandard
ReadWriteRunnableStandard(Context context, SerialNumber serialNumber, RobotUsbDevice device, int monitorLength, int startAddress, boolean debug)
Constructor- Parameters:
serialNumber
- USB serial numberdevice
- FTDI devicemonitorLength
- length of memory map to continually monitorstartAddress
- starting address of changing buffer values.
-
-
Method Detail
-
getShutdownReason
SyncdDevice.ShutdownReason getShutdownReason()
-
getAcceptingWrites
boolean getAcceptingWrites()
-
setAcceptingWrites
void setAcceptingWrites(boolean acceptingWrites)
-
setCallback
void setCallback(ReadWriteRunnable.Callback callback)
-
getOwner
RobotUsbModule getOwner()
-
setOwner
void setOwner(RobotUsbModule owner)
-
writeNeeded
boolean writeNeeded()
-
resetWriteNeeded
void resetWriteNeeded()
-
write
void write(int address, Array<byte> data)
Write to device
- Parameters:
address
- address to writedata
- data to write
-
suppressReads
void suppressReads(boolean suppress)
-
readFromWriteCache
Array<byte> readFromWriteCache(int address, int size)
Read from the device write cache
- Parameters:
address
- address of byte to readsize
- number of bytes to read
-
read
Array<byte> read(int address, int size)
Read from device
- Parameters:
address
- address to readsize
- number of bytes to read
-
executeUsing
void executeUsing(ExecutorService service)
-
close
void close()
Close this read-write-runnable
-
createSegment
ReadWriteRunnableSegment createSegment(int key, int address, int size)
-
destroySegment
void destroySegment(int key)
-
getSegment
ReadWriteRunnableSegment getSegment(int key)
-
queueSegmentRead
void queueSegmentRead(int key)
-
queueSegmentWrite
void queueSegmentWrite(int key)
-
run
void run()
Main read / write loop
-
drainPendingWrites
void drainPendingWrites()
-
-
-
-