public class UsbConnection extends ConnectionA
| 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()
Internal use only
|
String |
getModel()
Internal use only
|
String |
getPrinterName()
Returns printer's symbolic name
|
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.
|
String |
toString()
Returns the Connection Builder name of the USB device.
|
void |
write(byte[] data,
int offset,
int length)
Writes
length bytes from data starting at offset. |
getMaxTimeoutForRead, getTimeToWaitForMoreData, isConnected, read, read, sendAndWaitForResponse, sendAndWaitForResponse, sendAndWaitForValidResponse, sendAndWaitForValidResponse, setMaxTimeoutForRead, setTimeToWaitForMoreData, waitForData, write, 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 intial data is sent from printerConnectionException - if the system is not running the Windows operating system or if the device cannot be
found.public String getSimpleConnectionName()
ConnectionConnection.getSimpleConnectionName()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,
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
ConnectionExceptionpublic String getManufacturer() throws ConnectionException
ConnectionExceptionpublic String getModel() throws ConnectionException
ConnectionExceptionpublic String getPrinterName()
public int bytesAvailable()
throws ConnectionException
bytesAvailable in interface ConnectionbytesAvailable in class ConnectionAConnectionException - if an I/O error occurs.Connection.bytesAvailable()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)
© 2015 ZIH Corp. All Rights Reserved.