Class that implements the USB specific communication and extends the AComm class. More...
Classes | |
| class | DescriptorValidateResult |
Public Member Functions | |
| short | V_ID () |
| Vendor ID. More... | |
| short | P_ID () |
| int | BytesAvailable () |
| boolean | Connected () |
| String | Descriptor () |
| Returns a string description of the USB connection. More... | |
| UsbConnection (Context context, String descriptorHint) | |
| Initializes a new instance of the class based on the descriptor hint. More... | |
| UsbConnection (Context context) | |
| Initialize a new class instance using default vendor IDs. The target is the first printer that matches one of the known vendor IDs. More... | |
| UsbConnection (Context context, short vendorId) | |
| Initialize a new class instance using the specified vendor ID. The target is the first printer that matches the vendor ID. More... | |
| UsbConnection (Context context, short vendorId, short productId) | |
| Initialize a new class instance using the specified vendor ID and product ID. The target is the first printer that matches both IDs. More... | |
| void | RequestUSBPermission (String ACTION_USB_PERMISSION) |
| void | Open () |
| void | Close () |
| byte[] | Read () |
| void | Write (byte[] dataOut) |
| void | startReceivingTask () |
Public Member Functions inherited from com.UniPRT.Sdk.Comm.AComm | |
| void | Read (OutputStream binDataIn) throws IOException |
| void | WaitForData (int msTimeOut) |
| Waits until data available BytesAvailable in current thread. Current thread sleeps until data received or timeout reached. Blocking call. More... | |
| void | Write (InputStream binReader) throws IOException |
| Write from input stream to output stream. More... | |
| void | WriteAndWaitForResponse (OutputStream binDataIn, InputStream binDataOut, int responseStartTimeOut, int responseEndTimeOut, String completetionToken) throws IOException |
| Write binDataOut stream data to output stream and return data received in binDataIn stream. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More... | |
| byte[] | WriteAndWaitForResponse (byte[] dataOut, int responseStartTimeOut, int responseEndTimeOut, String completetionToken) throws IOException |
| Write byte data to output stream and return data received. Data returned is any data received or up to completion token if received. Wait for response timeout before returning. More... | |
Static Public Member Functions | |
| static DescriptorValidateResult | DescriptorValidate (String descriptorHint) |
| Validates a descriptor string from the descriptorHint. More... | |
| static boolean | contains (short[] array, short target) |
Public Attributes | |
| UsbManager | mUsbManager |
| UsbDevice | mUsbDevice |
Static Public Attributes | |
| static final short | TSC_USB_VID = 0x1203 |
| static final short | PTX_USB_VID = 0x14AE |
Private Member Functions | |
| UsbConnection (Context context, short[] vendorIds, short productId) | |
Private Attributes | |
| short | _v_id = 0x0000 |
| short | _p_id = 0x0000 |
| boolean | _is_connected = false |
| UsbInterface | mUsbIntf |
| UsbDeviceConnection | mUsbConnection |
| UsbEndpoint | mUsbEndpointIn |
| UsbEndpoint | mUsbEndpointOut |
| BroadcastReceiver | usbPermissionReceiver |
| Context | context |
| PendingIntent | permissionIntent |
| final Semaphore | semaphore = new Semaphore(1) |
| final ExecutorService | executor = Executors.newSingleThreadExecutor() |
| Future<?> | cancelFuture |
| ByteArrayOutputStream | byteArrayOutputStream = new ByteArrayOutputStream() |
| final Object | lock = new Object() |
Static Private Attributes | |
| static final int | BLOCK_SIZE = 512 |
Class that implements the USB specific communication and extends the AComm class.
| com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection | ( | Context | context, |
| String | descriptorHint | ||
| ) |
Initializes a new instance of the class based on the descriptor hint.
| context | The application context. |
| descriptorHint | The descriptor hint string. |
References com.UniPRT.Sdk.Comm.UsbConnection.context, and com.UniPRT.Sdk.Comm.UsbConnection.DescriptorValidate().
| com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection | ( | Context | context | ) |
Initialize a new class instance using default vendor IDs. The target is the first printer that matches one of the known vendor IDs.
| context | The software context. |
References com.UniPRT.Sdk.Comm.UsbConnection.context, com.UniPRT.Sdk.Comm.UsbConnection.PTX_USB_VID, and com.UniPRT.Sdk.Comm.UsbConnection.TSC_USB_VID.
| com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection | ( | Context | context, |
| short | vendorId | ||
| ) |
Initialize a new class instance using the specified vendor ID. The target is the first printer that matches the vendor ID.
| context | The software context. |
| vendorId | The vendor ID of the target printer (e.g., TSC or PRINTRONIX). |
References com.UniPRT.Sdk.Comm.UsbConnection.context.
| com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection | ( | Context | context, |
| short | vendorId, | ||
| short | productId | ||
| ) |
Initialize a new class instance using the specified vendor ID and product ID. The target is the first printer that matches both IDs.
| context | The software context. |
| vendorId | The vendor ID of the target printer (e.g., TSC or PRINTRONIX). |
| productId | The product ID of the target printer. |
References com.UniPRT.Sdk.Comm.UsbConnection.context.
|
private |
| int com.UniPRT.Sdk.Comm.UsbConnection.BytesAvailable | ( | ) |
Get the number of bytes available to read.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.UsbConnection.byteArrayOutputStream.
| void com.UniPRT.Sdk.Comm.UsbConnection.Close | ( | ) |
Close the connection.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.UsbConnection._is_connected, com.UniPRT.Sdk.Comm.UsbConnection.byteArrayOutputStream, com.UniPRT.Sdk.Comm.UsbConnection.cancelFuture, com.UniPRT.Sdk.Comm.UsbConnection.executor, com.UniPRT.Sdk.Comm.UsbConnection.mUsbConnection, com.UniPRT.Sdk.Comm.UsbConnection.mUsbIntf, and com.UniPRT.Sdk.Comm.UsbConnection.semaphore.
| boolean com.UniPRT.Sdk.Comm.UsbConnection.Connected | ( | ) |
Check if connection is established.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.UsbConnection._is_connected.
|
static |
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection().
| String com.UniPRT.Sdk.Comm.UsbConnection.Descriptor | ( | ) |
Returns a string description of the USB connection.
Format returned:
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.UsbConnection._p_id, and com.UniPRT.Sdk.Comm.UsbConnection._v_id.
|
static |
Validates a descriptor string from the descriptorHint.
descriptorHint accepted values:
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection().
| void com.UniPRT.Sdk.Comm.UsbConnection.Open | ( | ) |
Open the connection.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.UsbConnection._is_connected, com.UniPRT.Sdk.Comm.UsbConnection.mUsbConnection, com.UniPRT.Sdk.Comm.UsbConnection.mUsbDevice, com.UniPRT.Sdk.Comm.UsbConnection.mUsbEndpointIn, com.UniPRT.Sdk.Comm.UsbConnection.mUsbEndpointOut, com.UniPRT.Sdk.Comm.UsbConnection.mUsbIntf, com.UniPRT.Sdk.Comm.UsbConnection.mUsbManager, and com.UniPRT.Sdk.Comm.UsbConnection.startReceivingTask().
| short com.UniPRT.Sdk.Comm.UsbConnection.P_ID | ( | ) |
References com.UniPRT.Sdk.Comm.UsbConnection._p_id.
| byte [] com.UniPRT.Sdk.Comm.UsbConnection.Read | ( | ) |
Read all available bytes.
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.UsbConnection.byteArrayOutputStream, and com.UniPRT.Sdk.Comm.UsbConnection.semaphore.
| void com.UniPRT.Sdk.Comm.UsbConnection.RequestUSBPermission | ( | String | ACTION_USB_PERMISSION | ) |
| void com.UniPRT.Sdk.Comm.UsbConnection.startReceivingTask | ( | ) |
References com.UniPRT.Sdk.Comm.UsbConnection.BLOCK_SIZE, com.UniPRT.Sdk.Comm.UsbConnection.byteArrayOutputStream, com.UniPRT.Sdk.Comm.UsbConnection.cancelFuture, com.UniPRT.Sdk.Comm.UsbConnection.executor, com.UniPRT.Sdk.Comm.UsbConnection.lock, com.UniPRT.Sdk.Comm.UsbConnection.mUsbConnection, com.UniPRT.Sdk.Comm.UsbConnection.mUsbEndpointIn, and com.UniPRT.Sdk.Comm.UsbConnection.semaphore.
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.Open().
| short com.UniPRT.Sdk.Comm.UsbConnection.V_ID | ( | ) |
Vendor ID.
References com.UniPRT.Sdk.Comm.UsbConnection._v_id.
| void com.UniPRT.Sdk.Comm.UsbConnection.Write | ( | byte[] | dataOut | ) |
Write all bytes from the array passed in.
| dataOut | Byte array to write. |
Implements com.UniPRT.Sdk.Comm.IComm.
References com.UniPRT.Sdk.Comm.UsbConnection.lock, com.UniPRT.Sdk.Comm.UsbConnection.mUsbConnection, and com.UniPRT.Sdk.Comm.UsbConnection.mUsbEndpointOut.
|
private |
|
private |
|
private |
|
staticprivate |
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.startReceivingTask().
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
| UsbDevice com.UniPRT.Sdk.Comm.UsbConnection.mUsbDevice |
|
private |
|
private |
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.Open(), and com.UniPRT.Sdk.Comm.UsbConnection.Write().
|
private |
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.Close(), and com.UniPRT.Sdk.Comm.UsbConnection.Open().
| UsbManager com.UniPRT.Sdk.Comm.UsbConnection.mUsbManager |
|
private |
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.RequestUSBPermission().
|
static |
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection().
|
private |
|
static |
Referenced by com.UniPRT.Sdk.Comm.UsbConnection.UsbConnection().
|
private |