public class RobotUsbDevicePretendModernRobotics extends java.lang.Object implements RobotUsbDevice
RobotUsbDevice.Channel, RobotUsbDevice.FirmwareVersion, RobotUsbDevice.USBIdentifiers
Modifier and Type | Field and Description |
---|---|
protected CircularByteBuffer |
circularByteBuffer |
protected boolean |
debugRetainBuffers |
protected DeviceManager.UsbDeviceType |
deviceType |
protected RobotUsbDevice.FirmwareVersion |
firmwareVersion |
protected boolean |
interruptRequested |
protected MarkedItemQueue |
markedItemQueue |
protected ModernRoboticsDatagram.AllocationContext<ModernRoboticsRequest> |
requestAllocationContext |
protected ModernRoboticsDatagram.AllocationContext<ModernRoboticsResponse> |
responseAllocationContext |
protected SerialNumber |
serialNumber |
Constructor and Description |
---|
RobotUsbDevicePretendModernRobotics(SerialNumber serialNumber) |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the device
|
boolean |
getDebugRetainBuffers() |
DeviceManager.UsbDeviceType |
getDeviceType() |
RobotUsbDevice.FirmwareVersion |
getFirmwareVersion()
Returns the firmware version of this USB device, or null if no such version is known.
|
java.lang.String |
getProductName() |
SerialNumber |
getSerialNumber() |
RobotUsbDevice.USBIdentifiers |
getUsbIdentifiers()
Returns the USB-level vendor and product id of this device.
|
boolean |
isAttached()
Returns whether or not this USB device is known to be physically attached
|
boolean |
isOpen()
Returns whether the device is open or not
|
void |
logRetainedBuffers(long nsOrigin,
long nsTimerExpire,
java.lang.String tag,
java.lang.String format,
java.lang.Object... args) |
boolean |
mightBeAtUsbPacketStart()
Answers as to whether we're it's probably the case we're at the start of a Usb
packet.
|
int |
read(byte[] bytes,
int ibFirst,
int cbToRead,
long timeout,
TimeWindow timeWindow)
Reads a requested number of bytes from the device.
|
void |
requestReadInterrupt(boolean interruptRequested)
Interrupts any reads that are currently pending inside the device, possibly waiting
on a perhaps lengthy timeout.
|
void |
resetAndFlushBuffers()
Resets the remote USB device comm-layer as best we can.
|
void |
setBaudRate(int i)
Sets the rate of data transmission used to communicate with the device.
|
void |
setBreak(boolean enable)
Sets or unsets a break state on the communication line
|
void |
setDataCharacteristics(byte b,
byte b1,
byte b2)
Set the Data Characteristics
|
void |
setDebugRetainBuffers(boolean retain) |
void |
setDeviceType(DeviceManager.UsbDeviceType deviceType) |
void |
setFirmwareVersion(RobotUsbDevice.FirmwareVersion version)
Sets the firmware version of this USB device.
|
void |
setLatencyTimer(int i)
Set the latency timer
|
void |
skipToLikelyUsbPacketStart()
Skips to the beginning of a USB packet, if not already there.
|
void |
write(byte[] bytes)
Write to device
|
protected RobotUsbDevice.FirmwareVersion firmwareVersion
protected CircularByteBuffer circularByteBuffer
protected MarkedItemQueue markedItemQueue
protected boolean interruptRequested
protected SerialNumber serialNumber
protected DeviceManager.UsbDeviceType deviceType
protected boolean debugRetainBuffers
protected ModernRoboticsDatagram.AllocationContext<ModernRoboticsRequest> requestAllocationContext
protected ModernRoboticsDatagram.AllocationContext<ModernRoboticsResponse> responseAllocationContext
public RobotUsbDevicePretendModernRobotics(SerialNumber serialNumber)
public SerialNumber getSerialNumber()
getSerialNumber
in interface RobotUsbDevice
public java.lang.String getProductName()
getProductName
in interface RobotUsbDevice
public void setDeviceType(DeviceManager.UsbDeviceType deviceType)
setDeviceType
in interface RobotUsbDevice
public DeviceManager.UsbDeviceType getDeviceType()
getDeviceType
in interface RobotUsbDevice
public void close()
RobotUsbDevice
close
in interface RobotUsbDevice
public boolean isOpen()
RobotUsbDevice
isOpen
in interface RobotUsbDevice
public boolean isAttached()
RobotUsbDevice
isAttached
in interface RobotUsbDevice
public void setDebugRetainBuffers(boolean retain)
setDebugRetainBuffers
in interface RobotUsbDevice
public boolean getDebugRetainBuffers()
getDebugRetainBuffers
in interface RobotUsbDevice
public void logRetainedBuffers(long nsOrigin, long nsTimerExpire, java.lang.String tag, java.lang.String format, java.lang.Object... args)
logRetainedBuffers
in interface RobotUsbDevice
public void setBaudRate(int i)
RobotUsbDevice
setBaudRate
in interface RobotUsbDevice
i
- baud ratepublic void setDataCharacteristics(byte b, byte b1, byte b2)
RobotUsbDevice
setDataCharacteristics
in interface RobotUsbDevice
b
- data bitsb1
- stop bitsb2
- paritypublic void setLatencyTimer(int i)
RobotUsbDevice
setLatencyTimer
in interface RobotUsbDevice
i
- latency timerpublic void setBreak(boolean enable)
RobotUsbDevice
setBreak
in interface RobotUsbDevice
enable
- whether or not to set a break statepublic void skipToLikelyUsbPacketStart()
RobotUsbDevice
skipToLikelyUsbPacketStart
in interface RobotUsbDevice
public boolean mightBeAtUsbPacketStart()
RobotUsbDevice
mightBeAtUsbPacketStart
in interface RobotUsbDevice
public void write(byte[] bytes)
RobotUsbDevice
write
in interface RobotUsbDevice
bytes
- byte arraypublic int read(byte[] bytes, int ibFirst, int cbToRead, long timeout, TimeWindow timeWindow)
RobotUsbDevice
read
in interface RobotUsbDevice
bytes
- byte array into which to read the dataibFirst
- first index in data at which to read the datacbToRead
- number of bytes to readtimeout
- amount of time to wait, in ms, for data to become available to readtimeWindow
- optional place to return information as to when the data was readpublic void resetAndFlushBuffers()
RobotUsbDevice
resetAndFlushBuffers
in interface RobotUsbDevice
public RobotUsbDevice.FirmwareVersion getFirmwareVersion()
RobotUsbDevice
getFirmwareVersion
in interface RobotUsbDevice
RobotUsbDevice.setFirmwareVersion(FirmwareVersion)
public void setFirmwareVersion(RobotUsbDevice.FirmwareVersion version)
RobotUsbDevice
setFirmwareVersion
in interface RobotUsbDevice
RobotUsbDevice.getFirmwareVersion()
public void requestReadInterrupt(boolean interruptRequested)
RobotUsbDevice
requestReadInterrupt
in interface RobotUsbDevice
public RobotUsbDevice.USBIdentifiers getUsbIdentifiers()
RobotUsbDevice
getUsbIdentifiers
in interface RobotUsbDevice