public class RobotUsbDeviceTty extends RobotUsbDeviceImplBase implements RobotUsbDevice
RobotUsbDeviceTty is an implementation of RobotUsbDevice that
sits on top of a serial file handle (such as /dev/tty) and presents the persona of
a (fake) USB device.RobotUsbDevice.Channel, RobotUsbDevice.FirmwareVersion, RobotUsbDevice.USBIdentifiers| Modifier and Type | Field and Description |
|---|---|
protected int |
baudRate |
static boolean |
DEBUG |
protected boolean |
debugRetainBuffers |
protected java.io.File |
file |
protected int |
msDefaultTimeout |
protected java.lang.String |
productName |
protected java.util.Queue<java.lang.Byte> |
readAhead |
protected java.lang.Object |
readLock |
protected SerialPort |
serialPort |
protected java.lang.Object |
startStopLock |
static java.lang.String |
TAG |
protected RobotUsbDevice.USBIdentifiers |
usbIdentifiers |
protected java.lang.Object |
writeLock |
deviceType, deviceTypes, extantDevices, firmwareVersion, serialNumber| Constructor and Description |
|---|
RobotUsbDeviceTty(SerialPort serialPort,
SerialNumber serialNumber,
java.io.File file) |
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes the device
|
boolean |
getDebugRetainBuffers() |
int |
getMsDefaultTimeout() |
java.lang.String |
getProductName() |
java.lang.String |
getTag() |
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[] data,
int ibFirst,
int cbToRead,
long msTimeout,
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 baudRate)
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 dataBits,
byte stopBits,
byte parity)
Set the Data Characteristics
|
void |
setDebugRetainBuffers(boolean retain) |
void |
setLatencyTimer(int latencyTimer)
Set the latency timer
|
void |
setMsDefaultTimeout(int msDefaultTimeout) |
void |
setProductName(java.lang.String productName) |
void |
setUsbIdentifiers(RobotUsbDevice.USBIdentifiers usbIdentifiers) |
void |
skipToLikelyUsbPacketStart()
Skips to the beginning of a USB packet, if not already there.
|
void |
write(byte[] data)
Write to device
|
dumpBytesReceived, dumpBytesSent, getDeviceType, getDeviceType, getExtantDevices, getFirmwareVersion, getSerialNumber, isOpen, removeFromExtantDevices, setDeviceType, setFirmwareVersionclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetDeviceType, getFirmwareVersion, getSerialNumber, setDeviceType, setFirmwareVersionpublic static final java.lang.String TAG
public static boolean DEBUG
protected final java.io.File file
protected SerialPort serialPort
protected int baudRate
protected int msDefaultTimeout
protected RobotUsbDevice.USBIdentifiers usbIdentifiers
protected final java.lang.Object startStopLock
protected final java.lang.Object readLock
protected final java.lang.Object writeLock
protected java.util.Queue<java.lang.Byte> readAhead
protected boolean debugRetainBuffers
protected java.lang.String productName
public RobotUsbDeviceTty(SerialPort serialPort, SerialNumber serialNumber, java.io.File file)
public java.lang.String getTag()
getTag in class RobotUsbDeviceImplBasepublic void close()
RobotUsbDeviceclose in interface RobotUsbDevicepublic boolean isOpen()
RobotUsbDeviceisOpen in interface RobotUsbDevicepublic boolean isAttached()
RobotUsbDeviceisAttached in interface RobotUsbDevicepublic void resetAndFlushBuffers()
RobotUsbDeviceresetAndFlushBuffers in interface RobotUsbDevicepublic void write(byte[] data)
throws RobotUsbException
RobotUsbDevicewrite in interface RobotUsbDevicedata - byte arrayRobotUsbExceptionpublic int read(byte[] data,
int ibFirst,
int cbToRead,
long msTimeout,
TimeWindow timeWindow)
throws RobotUsbException,
java.lang.InterruptedException
RobotUsbDeviceread in interface RobotUsbDevicedata - byte array into which to read the dataibFirst - first index in data at which to read the datacbToRead - number of bytes to readmsTimeout - 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 readRobotUsbExceptionjava.lang.InterruptedExceptionpublic boolean mightBeAtUsbPacketStart()
RobotUsbDevicemightBeAtUsbPacketStart in interface RobotUsbDevicepublic void skipToLikelyUsbPacketStart()
RobotUsbDeviceskipToLikelyUsbPacketStart in interface RobotUsbDevicepublic void requestReadInterrupt(boolean interruptRequested)
RobotUsbDevicerequestReadInterrupt in interface RobotUsbDevicepublic void setDebugRetainBuffers(boolean retain)
setDebugRetainBuffers in interface RobotUsbDevicepublic boolean getDebugRetainBuffers()
getDebugRetainBuffers in interface RobotUsbDevicepublic void logRetainedBuffers(long nsOrigin,
long nsTimerExpire,
java.lang.String tag,
java.lang.String format,
java.lang.Object... args)
logRetainedBuffers in interface RobotUsbDevicepublic void setBaudRate(int baudRate)
throws RobotUsbException
RobotUsbDevicesetBaudRate in interface RobotUsbDevicebaudRate - baud rateRobotUsbExceptionpublic void setDataCharacteristics(byte dataBits,
byte stopBits,
byte parity)
throws RobotUsbException
RobotUsbDevicesetDataCharacteristics in interface RobotUsbDevicedataBits - data bitsstopBits - stop bitsparity - parityRobotUsbExceptionpublic void setLatencyTimer(int latencyTimer)
throws RobotUsbException
RobotUsbDevicesetLatencyTimer in interface RobotUsbDevicelatencyTimer - latency timerRobotUsbExceptionpublic void setBreak(boolean enable)
throws RobotUsbException
RobotUsbDevicesetBreak in interface RobotUsbDeviceenable - whether or not to set a break stateRobotUsbExceptionpublic void setMsDefaultTimeout(int msDefaultTimeout)
public int getMsDefaultTimeout()
public RobotUsbDevice.USBIdentifiers getUsbIdentifiers()
RobotUsbDevicegetUsbIdentifiers in interface RobotUsbDevicepublic void setUsbIdentifiers(RobotUsbDevice.USBIdentifiers usbIdentifiers)
public void setProductName(java.lang.String productName)
public java.lang.String getProductName()
getProductName in interface RobotUsbDevice