public class UsbConnection extends ConnectionA implements com.zebra.sdk.comm.internal.ConnectionI
| Constructor and Description |
|---|
UsbConnection(String symbolicName)
Initializes a new instance of the
UsbConnection class. |
UsbConnection(String symbolicName,
int maxTimeoutForRead,
int timeToWaitForMoreData)
Initializes a new instance of the
UsbConnection class. |
| Modifier and Type | Method and Description |
|---|---|
int |
bytesAvailable()
Returns number of bytes currently read from printer.
|
void |
close()
Closes this connection and releases any system resources associated with the connection.
|
ConnectionReestablisher |
getConnectionReestablisher(long thresholdTime)
Returns a
ConnectionReestablisher which allows for easy recreation of a connection which may have
been closed. |
String |
getManufacturer()
Returns the printer's manufacturer.
|
int |
getMaxTimeoutForRead()
Returns the maximum time, in milliseconds, to wait for any data to be received.
|
String |
getSerialNumber() |
String |
getSimpleConnectionName()
Return a human-readable description of the connection.
|
void |
open()
Opens the connection to a device.
|
byte[] |
read(int maxBytesToRead)
Reads up to maxBytesToRead into byte array
Performing reads using DriverPrinterConnection and UsbConnection concurrently could cause indeterminate reads |
int |
readChar()
Reads the next byte of data from the connection, similar to a Java InputStream.
|
void |
setMaxTimeoutForRead(int maxTimeoutForRead)
Set the maximum time, in milliseconds, to wait for any data to be received
|
String |
toString()
Returns the Connection Builder name of the USB device.
|
void |
write(byte[] data)
Writes
data.length bytes from the specified byte array to this output stream. |
void |
write(byte[] data,
int offset,
int length)
Writes
length bytes from data starting at offset. |
addWriteLogStream, getMaxDataToWrite, getTimeToWaitForMoreData, isConnected, read, read, read, sendAndWaitForResponse, sendAndWaitForResponse, sendAndWaitForValidResponse, sendAndWaitForValidResponse, setMaxDataToWrite, setReadTimeout, setTimeToWaitForMoreData, waitForData, writegetMaxDataToWrite, read, setMaxDataToWrite, setReadTimeoutgetTimeToWaitForMoreData, isConnected, read, read, sendAndWaitForResponse, sendAndWaitForResponse, sendAndWaitForValidResponse, sendAndWaitForValidResponse, setTimeToWaitForMoreData, waitForData, writepublic UsbConnection(String symbolicName)
throws ConnectionException
UsbConnection class. This constructor will attempt a connection to
the printer specified in the symbolic name.symbolicName - the USB symbolic name for the device returned by the UsbDiscoverer.getZebraUsbPrinters()
member function.ConnectionException - if the system is not running the Windows operating system or if the device cannot be
found.public UsbConnection(String symbolicName,
int maxTimeoutForRead,
int timeToWaitForMoreData)
throws ConnectionException
UsbConnection class. This constructor will attempt a connection to
the printer specified in the symbolic name.symbolicName - the USB symbolic name for the device returned by the UsbDiscoverer.getZebraUsbPrinters()
member function.maxTimeoutForRead - Maximum time to wait for read datatimeToWaitForMoreData - maximum time to wait for more data after initial data is sent from printerConnectionException - if the system is not running the Windows operating system or if the device cannot be
found.public void open()
throws ConnectionException
Connectionopen method is called when this connection has already been
opened, this call is ignored. When a handle to the connection is no longer needed, you must call Connection.close()
to free up system resources.open in interface Connectionopen in class ConnectionAConnectionException - if the connection cannot be established.ConnectionA.open()public void close()
throws ConnectionException
Connectionclose in interface Connectionclose in class ConnectionAConnectionException - if an I/O error occurs.ConnectionA.close()public void write(byte[] data)
throws ConnectionException
Connectiondata.length bytes from the specified byte array to this output stream. The connection must be
open before this method is called. If write is called when a connection is closed, a
ConnectionException is thrown.write in interface Connectionwrite in class ConnectionAdata - the data.ConnectionException - if an I/O error occurs.ConnectionA.write(byte[])public void write(byte[] data,
int offset,
int length)
throws ConnectionException
Connectionlength bytes from data starting at offset. The connection must be
open before this method is called. If write is called when a connection is closed, a
ConnectionException is thrown.write in interface Connectionwrite in class ConnectionAdata - the data.offset - the start offset in the data.length - number of bytes to write.ConnectionException - if an I/O error occurs.ConnectionA.write(byte[], int, int)public int readChar()
throws ConnectionException
Connectionint singleCharacter = printerConnection.readChar();
readChar in interface ConnectionreadChar in class ConnectionAConnectionException - if an I/O error occurs.Connection.readChar()public byte[] read(int maxBytesToRead)
throws ConnectionException
read in interface com.zebra.sdk.comm.internal.ConnectionIread in class ConnectionAmaxBytesToRead - number of bytes to readConnectionException - if an I/O error occurs.public int bytesAvailable()
throws ConnectionException
bytesAvailable in interface ConnectionbytesAvailable in class ConnectionAConnectionException - if an I/O error occurs.Connection.bytesAvailable()public String getSimpleConnectionName()
ConnectiongetSimpleConnectionName in interface ConnectionConnection.getSimpleConnectionName()public String getSerialNumber()
public String toString()
toString in interface ConnectiontoString in class Objectpublic ConnectionReestablisher getConnectionReestablisher(long thresholdTime) throws ConnectionException
ConnectionConnectionReestablisher which allows for easy recreation of a connection which may have
been closed.
getConnectionReestablisher in interface ConnectiongetConnectionReestablisher in class ConnectionAthresholdTime - how long the Connection reestablisher will wait before attempting to reconnection to the
printerConnectionException - if the ConnectionReestablisher could not be created.ConnectionA.getConnectionReestablisher(long thresholdTime)public void setMaxTimeoutForRead(int maxTimeoutForRead)
ConnectionsetMaxTimeoutForRead in interface ConnectionsetMaxTimeoutForRead in class ConnectionAmaxTimeoutForRead - the maximum time, in milliseconds, to wait for any data to be received.ConnectionA.setMaxTimeoutForRead(int)public int getMaxTimeoutForRead()
ConnectiongetMaxTimeoutForRead in interface ConnectiongetMaxTimeoutForRead in class ConnectionAConnectionA.getMaxTimeoutForRead()public String getManufacturer()
ConnectionAgetManufacturer in interface com.zebra.sdk.comm.internal.ConnectionIgetManufacturer in class ConnectionAConnectionI.getManufacturer()
© 2017 ZIH Corp. All Rights Reserved.