public final class SerialComUSB extends Object
Encapsulates USB related operations and values.
An end product may be based on dedicated USB-UART bridge IC for providing serial over USB or may use general purpose microcontroller like PIC18F4550 from Microchip technology Inc. and program appropriate firmware (USB CDC) into it to provide UART communication over USB port.
[1] If your USB-UART converter based design is not working, consider not connecting USB connector shield directly to ground. Further, double check if termination resistors in D+/D- lines are really required or not.
| Modifier and Type | Field and Description |
|---|---|
static int |
DEV_ADDED
The value indicating that a USB device has been added into system.
|
static int |
DEV_ANY
The value indicating that the USB device can have any vendor id and product id.
|
static int |
DEV_REMOVED
The value indicating that a USB device has been removed from system.
|
static int |
V_ALL
Value indicating all vendors (vendor neutral operation).
|
static int |
V_ATML
Value indicating vendor - Atmel corporation.
|
static int |
V_CYPRS
Value indicating vendor - Cypress semiconductor corporation.
|
static int |
V_EXAR
Value indicating vendor - Exar corporation.
|
static int |
V_FTDI
Value indicating vendor - Future technology devices international, Ltd.
|
static int |
V_MCHIP
Value indicating vendor - Microchip technology Inc.
|
static int |
V_MOSCHP
Value indicating vendor - MosChip semiconductor.
|
static int |
V_NXP
Value indicating vendor - NXP semiconductors.
|
static int |
V_PL
Value indicating vendor - Prolific technology Inc.
|
static int |
V_QHE
Value indicating vendor - QinHeng electronics.
|
static int |
V_RNSAS
Value indicating vendor - Renesas electronics (NEC electronics).
|
static int |
V_SLABS
Value indicating vendor - Silicon Laboratories.
|
static int |
V_TI
Value indicating vendor - Texas instruments, Inc.
|
static int |
V_WCH
Value indicating vendor - WinChipHead.
|
| Constructor and Description |
|---|
SerialComUSB(SerialComPortJNIBridge mComPortJNIBridge)
Allocates a new SerialComUSB object.
|
| Modifier and Type | Method and Description |
|---|---|
SerialComUSBPowerInfo |
getCDCUSBDevPowerInfo(String comPort)
Read all the power management related information about a particular USB device.
|
String[] |
getFirmwareRevisionNumber(int usbvid,
int usbpid,
String serialNumber)
Gets the USB device firmware revision number as reported by USB device descriptor in its
device descriptor using bcdDevice field.
|
int |
getLatencyTimer(String comPort)
Gets the current latency timer value for FTDI devices.
|
boolean |
rescanUSBDevicesHW()
Causes re-scan for USB devices.
|
boolean |
setLatencyTimer(String comPort,
byte timerValue)
Sets the latency timer value for FTDI devices.
|
public static final int V_ALL
Value indicating all vendors (vendor neutral operation).
public static final int V_FTDI
Value indicating vendor - Future technology devices international, Ltd. It manufactures FT232 USB-UART bridge IC.
public static final int V_SLABS
Value indicating vendor - Silicon Laboratories. It manufactures CP2102 USB-UART bridge IC.
public static final int V_MCHIP
Value indicating vendor - Microchip technology Inc. It manufactures MCP2200 USB-UART bridge IC.
public static final int V_PL
Value indicating vendor - Prolific technology Inc. It manufactures PL2303 USB-UART bridge IC.
public static final int V_EXAR
Value indicating vendor - Exar corporation. It manufactures XR21V1410 USB-UART bridge IC.
public static final int V_ATML
Value indicating vendor - Atmel corporation. It manufactures AT90USxxx and other processors which can be used as USB-UART bridge.
public static final int V_MOSCHP
Value indicating vendor - MosChip semiconductor. It manufactures MCS7810 USB-UART bridge IC.
public static final int V_CYPRS
Value indicating vendor - Cypress semiconductor corporation. It manufactures CY7C65213 USB-UART bridge IC.
public static final int V_TI
Value indicating vendor - Texas instruments, Inc. It manufactures TUSB3410 USB-UART bridge IC.
public static final int V_WCH
Value indicating vendor - WinChipHead. It manufactures CH340 USB-UART bridge IC.
public static final int V_QHE
Value indicating vendor - QinHeng electronics. It manufactures HL-340 converter product.
public static final int V_NXP
Value indicating vendor - NXP semiconductors. It manufactures LPC134x series of microcontrollers.
public static final int V_RNSAS
Value indicating vendor - Renesas electronics (NEC electronics). It manufactures μPD78F0730 microcontroller which can be used as USB-UART converter.
public static final int DEV_ANY
The value indicating that the USB device can have any vendor id and product id.
public static final int DEV_ADDED
The value indicating that a USB device has been added into system.
public static final int DEV_REMOVED
The value indicating that a USB device has been removed from system.
public SerialComUSB(SerialComPortJNIBridge mComPortJNIBridge)
Allocates a new SerialComUSB object.
mComPortJNIBridge - interface to native library for serial port communication.public String[] getFirmwareRevisionNumber(int usbvid, int usbpid, String serialNumber) throws SerialComException
Gets the USB device firmware revision number as reported by USB device descriptor in its device descriptor using bcdDevice field.
Application can get this firmware revision number and can self adopt to a particular hardware device. For example if a particular feature is present in firmware version 1.00 than application create a button in GUI, however for revision 1.11 it creates a different button in GUI window.
Embedded system device vendors sometimes use bcdDevice value to indicate the 'embedded bootloader' version so that the firmware image flash loader program can identify the bootloader in use and use the appropriate protocol to flash firmware in flash memory. Typically, USB Device Firmware Upgrade (DFU) which is an official USB device class specification of the USB Implementers Forum is used.
On custom hardware the RTS and DTR pins of USB-UART device can be used to control GPIO or boot mode pins to enter a particular boot mode. For example, open the host serial port, make DTR low and RTS high and then reset microcontroller board. The microcontroller will see levels at its boot pins and will enter into a particular boot mode.
usbvid - USB vendor ID to match.usbpid - USB product ID to match.serialNumber - serial number of USB device (case insensitive, optional) to match.SerialComException - if an I/O error occurs.public SerialComUSBPowerInfo getCDCUSBDevPowerInfo(String comPort) throws SerialComException
Read all the power management related information about a particular USB device. The returned instance of SerialComUSBPowerInfo class contains information about auto suspend, selective suspend, current power status etc.
comPort - serial port name/path (COMxx, /dev/ttyUSBx) which is associated with a particular
USB CDC/ACM interface in the USB device to be analyzed for power management.SerialComException - if an I/O error occurs.public boolean rescanUSBDevicesHW()
throws SerialComException
Causes re-scan for USB devices. It is equivalent to clicking the "Scan for hardware changes" button in the Device Manager. Only USB hardware is checked for new devices. This can be of use when trying to recover devices programmatically.
This is applicable to Windows operating system only.
SerialComException - if an I/O error occurs.public boolean setLatencyTimer(String comPort, byte timerValue) throws SerialComException
Sets the latency timer value for FTDI devices. When using FTDI USB-UART devices, optimal values of latency timer and read/write block size may be required to obtain optimal data throughput.
Note that built-in drivers in Linux kernel image may not allow changing timer values as it may have been hard-coded. Drivers supplied by FTDI at their website should be used if changing latency timer values is required by application.
SerialComException - if an I/O error occurs.public int getLatencyTimer(String comPort) throws SerialComException
Gets the current latency timer value for FTDI devices.
SerialComException - if an I/O error occurs.Copyright © 2016. All rights reserved.