public abstract class ModernRoboticsUsbDevice extends ArmableUsbDevice implements ReadWriteRunnable.Callback
Modifier and Type | Class and Description |
---|---|
static interface |
ModernRoboticsUsbDevice.CreateReadWriteRunnable |
Modifier and Type | Field and Description |
---|---|
protected ModernRoboticsUsbDevice.CreateReadWriteRunnable |
createReadWriteRunnable |
protected ReadWriteRunnable |
readWriteRunnable |
protected java.util.concurrent.ExecutorService |
readWriteService |
Constructor and Description |
---|
ModernRoboticsUsbDevice(Context context,
SerialNumber serialNumber,
SyncdDevice.Manager manager,
OpenRobotUsbDevice openRobotUsbDevice,
ModernRoboticsUsbDevice.CreateReadWriteRunnable createReadWriteRunnable) |
Modifier and Type | Method and Description |
---|---|
protected void |
armDevice(RobotUsbDevice device) |
protected void |
disarmDevice()
Closes down the device in an orderly and reliable way.
|
ModernRoboticsUsbDevice.CreateReadWriteRunnable |
getCreateReadWriteRunnable() |
abstract java.lang.String |
getDeviceName()
Device Name
|
OpenRobotUsbDevice |
getOpenRobotUsbDevice() |
protected RobotUsbDevice |
getPretendDevice(SerialNumber serialNumber)
intended as subclass hook
|
ReadWriteRunnable |
getReadWriteRunnable() |
int |
getVersion()
Version
|
void |
initializeHardware() |
byte[] |
read(int address,
int size)
Read from device
|
byte |
read8(int address)
Read a single byte from device
|
void |
readComplete() |
byte |
readFromWriteCache(int address)
Read from the device write cache
|
byte[] |
readFromWriteCache(int address,
int size)
Read from the device write cache
|
void |
shutdownComplete() |
void |
startupComplete() |
void |
write(int address,
byte[] data)
Write to device
|
void |
write8(int address,
byte data)
Write a single byte to the device
|
void |
write8(int address,
double data)
Write a single byte to the device
|
void |
write8(int address,
int data)
Write a single byte to the device
|
void |
writeComplete() |
protected java.util.concurrent.ExecutorService readWriteService
protected volatile ReadWriteRunnable readWriteRunnable
protected final ModernRoboticsUsbDevice.CreateReadWriteRunnable createReadWriteRunnable
public ModernRoboticsUsbDevice(Context context, SerialNumber serialNumber, SyncdDevice.Manager manager, OpenRobotUsbDevice openRobotUsbDevice, ModernRoboticsUsbDevice.CreateReadWriteRunnable createReadWriteRunnable) throws RobotCoreException, java.lang.InterruptedException
RobotCoreException
java.lang.InterruptedException
public void initializeHardware()
protected RobotUsbDevice getPretendDevice(SerialNumber serialNumber)
protected void armDevice(RobotUsbDevice device) throws RobotCoreException, java.lang.InterruptedException
RobotCoreException
java.lang.InterruptedException
protected void disarmDevice() throws java.lang.InterruptedException
java.lang.InterruptedException
public ReadWriteRunnable getReadWriteRunnable()
public OpenRobotUsbDevice getOpenRobotUsbDevice()
public ModernRoboticsUsbDevice.CreateReadWriteRunnable getCreateReadWriteRunnable()
public abstract java.lang.String getDeviceName()
public int getVersion()
public void write8(int address, byte data)
address
- address to writepublic void write8(int address, int data)
address
- address to writedata
- data to write (will be cast to a byte)public void write8(int address, double data)
address
- address to writedata
- data to write (will be cast to a byte)public void write(int address, byte[] data)
address
- address to writedata
- data to writejava.lang.IllegalArgumentException
- if address is out of rangepublic byte readFromWriteCache(int address)
address
- address of byte to readpublic byte[] readFromWriteCache(int address, int size)
address
- address of byte to readsize
- number of bytes to readpublic byte read8(int address)
address
- address to readjava.lang.IllegalArgumentException
- if address is out of range, or if read failedpublic byte[] read(int address, int size)
address
- address to readsize
- number of bytes to readjava.lang.IllegalArgumentException
- if address is out of range, or if read failedpublic void startupComplete() throws java.lang.InterruptedException
startupComplete
in interface ReadWriteRunnable.Callback
java.lang.InterruptedException
public void readComplete() throws java.lang.InterruptedException
readComplete
in interface ReadWriteRunnable.Callback
java.lang.InterruptedException
public void writeComplete() throws java.lang.InterruptedException
writeComplete
in interface ReadWriteRunnable.Callback
java.lang.InterruptedException
public void shutdownComplete() throws java.lang.InterruptedException
shutdownComplete
in interface ReadWriteRunnable.Callback
java.lang.InterruptedException