Class that implements the USB specific communication and extends the AComm class. More...
Public Member Functions | |
| UsbConnection () | |
| Initialize new class instance based on vendorId and productId. The target of this instance is the first printer that matches the vendorId and productId. More... | |
| UsbConnection (short vendorId) | |
| UsbConnection (short vendorId, short productId) | |
| UsbConnection (string descriptor) | |
| Initialize new class instance based on descriptor string. More... | |
| override void | Close () |
| Closes a connection. | |
| override void | Open () |
| Opens a connection. | |
| override byte[] | Read () |
| Read all bytes available. | |
| virtual void | Read (BinaryWriter binDataIn) |
| Reads all bytes available into the stream passed in. | |
| virtual void | WaitForData (int msTimeOut) |
| Waits until data available BytesAvailable in current thread. Current thread sleeps until data received or timeout reached. Blocking call. More... | |
| virtual void | Write (BinaryReader binReader) |
| Write from input stream to output stream More... | |
| override void | Write (byte[] dataOut) |
| Writes all bytes from the array passed in. | |
| virtual void | WriteAndWaitForResponse (BinaryWriter binDataIn, BinaryReader binDataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
| 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... | |
| virtual byte[] | WriteAndWaitForResponse (byte[] dataOut, int responseStartTimeOut, int responseEndTimeOut, string completetionToken) |
| 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 List<(short vendorID, short productID)> | AvaliableDevices () |
| Return the v_id and p_id of valid devices in the format of List<(short v_id, short p_id)>. More... | |
| static List< short > | DescriptorValidate (string descriptorHint) |
| Validate descriptor string from descriptorHint that may or may not have a v_id and p_id. Returns tuple. More... | |
Public Attributes | |
| override string | Descriptor => $"USB:V_ID:{_v_id}; P_ID:{_p_id}" |
| Returns a string description of the connection. Format: "USB:V_ID:_v_id; P_ID:_p_id" e.g. "USB:V_ID:4611; P_ID:1234". More... | |
Static Public Attributes | |
| static readonly short | PTX_USB_VID = 0x14ae |
| USB v_id of PRINTRONIX printer (0x14ae) | |
| static readonly short | TSC_USB_VID = 0x1203 |
| USB v_id of TSC printer (0x1203) | |
Properties | |
| override int | BytesAvailable [get] |
| override bool | Connected [get] |
| short | P_ID [get] |
| Product ID. | |
| short | V_ID [get] |
| Vendor ID. | |
Class that implements the USB specific communication and extends the AComm class.
| UniPRT.Sdk.Comm.UsbConnection.UsbConnection | ( | string | descriptor | ) |
Initialize new class instance based on descriptor string.
| [in] | descriptor | Acceptable Formats:
|
| UniPRT.Sdk.Comm.UsbConnection.UsbConnection | ( | ) |
Initialize new class instance based on vendorId and productId. The target of this instance is the first printer that matches the vendorId and productId.
| [in] | vendorId | Specifies whether a TSC printer or a PRINTRONIX printer is to be connected. When this parameter is omitted, either a TSC printer or a PRINTRONIX printer is the target |
| [in] | productId | Specify the productId of the printer. When this parameter is omitted, the first printer whose vendorId matches is the target |
|
static |
Return the v_id and p_id of valid devices in the format of List<(short v_id, short p_id)>.
The "v_id" refers to the Vendor ID, and "p_id" refers to the Product ID.
|
static |
Validate descriptor string from descriptorHint that may or may not have a v_id and p_id. Returns tuple.
descriptorHint accepted values:
|
virtualinherited |
Waits until data available BytesAvailable in current thread. Current thread sleeps until data received or timeout reached. Blocking call.
| [in] | msTimeOut | Millisecond timeout before return if no data received. |
Implements UniPRT.Sdk.Comm.IComm.
|
virtualinherited |
Write from input stream to output stream
| [in] | binReader | Source data to send |
Implements UniPRT.Sdk.Comm.IComm.
|
virtualinherited |
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.
| [out] | binDataIn | Destination stream to store response received from connection. |
| [in] | binDataOut | Source stream data to write to connection. |
| [in] | responseStartTimeOut | Timeout, milliseconds, to wait for first data to be received. Time to first byte. |
| [in] | responseEndTimeOut | Timeout, milliseconds, of no new data received. Time after last byte. |
| [in] | completetionToken | String token denoting the end of the response expected. This can be empty string if simply want to wait for response after writing data to connection. |
Implements UniPRT.Sdk.Comm.IComm.
|
virtualinherited |
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.
| byte[] | Array of bytes received from connection. Data returned is any data received or up to completetionToken if token received |
| [in] | dataOut | Source byte array to write to connection. |
| [in] | responseStartTimeOut | Timeout, milliseconds, to wait for first data to be received. Time to first byte. |
| [in] | responseEndTimeOut | Timeout, milliseconds, of no new data received. Time after last byte. |
| [in] | completetionToken | String token denoting the end of the response expected. This can be empty string if simply want to wait for response after writing data to connection. |
Implements UniPRT.Sdk.Comm.IComm.
| override string UniPRT.Sdk.Comm.UsbConnection.Descriptor => $"USB:V_ID:{_v_id}; P_ID:{_p_id}" |
Returns a string description of the connection. Format: "USB:V_ID:_v_id; P_ID:_p_id" e.g. "USB:V_ID:4611; P_ID:1234".
Format returned: