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, write
public 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()
Connection
Connection.getSimpleConnectionName()
public void open() throws ConnectionException
Connection
open
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 Connection
open
in class ConnectionA
ConnectionException
- if the connection cannot be established.ConnectionA.open()
public void close() throws ConnectionException
Connection
close
in interface Connection
close
in class ConnectionA
ConnectionException
- if an I/O error occurs.ConnectionA.close()
public void write(byte[] data, int offset, int length) throws ConnectionException
Connection
length
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 Connection
write
in class ConnectionA
data
- 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
Connection
int singleCharacter = printerConnection.readChar();
readChar
in interface Connection
readChar
in class ConnectionA
ConnectionException
- if an I/O error occurs.Connection.readChar()
public byte[] read(int maxBytesToRead) throws ConnectionException
ConnectionException
public String getManufacturer() throws ConnectionException
ConnectionException
public String getModel() throws ConnectionException
ConnectionException
public String getPrinterName()
public int bytesAvailable() throws ConnectionException
bytesAvailable
in interface Connection
bytesAvailable
in class ConnectionA
ConnectionException
- if an I/O error occurs.Connection.bytesAvailable()
public String toString()
toString
in interface Connection
toString
in class Object
public ConnectionReestablisher getConnectionReestablisher(long thresholdTime) throws ConnectionException
Connection
ConnectionReestablisher
which allows for easy recreation of a connection which may have
been closed.getConnectionReestablisher
in interface Connection
getConnectionReestablisher
in class ConnectionA
thresholdTime
- 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.