How to Develop Serial Port for Terminals: Difference between revisions
Line 47: | Line 47: | ||
[[File:Otg_usb_1.jpg|frameless|left|thumb|caption]] | [[File:Otg_usb_1.jpg|frameless|left|thumb|caption]] | ||
USB to Serial port cable, USB TypeA Male to DB9 Female: | |||
[[File:Usb_db9_1.jpg|frameless|left|thumb|caption]] | [[File:Usb_db9_1.jpg|frameless|left|thumb|caption]] | ||
Line 53: | Line 53: | ||
USB to Serial port cable, USB TypeA Male to DB9 Male: | |||
[[File:Usb_db9_2.jpg|frameless|left|thumb|caption]] | [[File:Usb_db9_2.jpg|frameless|left|thumb|caption]] | ||
UU cable, 2 USB Serial port cable cross connected together: | |||
[[File:UUCable.jpg|frameless|left|thumb|caption]] | [[File:UUCable.jpg|frameless|left|thumb|caption]] |
Revision as of 02:04, 4 June 2022
Demo
Here is a demo about how to develop an app using Java API, please download SerialPortDemo
A serial port test tool Source APP, and APK
Open
Java API
When using the Java API to open a serial port, you need to set the logic ID of a serial port as a parameter.
- SerialPortDevice.ID_USB_SLAVE_SERIAL : works for USB serial port in slave mode.
- SerialPortDevice.ID_USB_HOST_SERIAL : works for USB serial port in master mode.
- SerialPortDevice.ID_SERIAL_EXT : works for internal fiscal/ other serial port module.
- SerialPortDevice.ID_USB_CDC: works for USB Communication Device Class.
C API
When using the C API to open a serial port, you need to set the device name of a serial port as a parameter.
Device Name:
Parameters | |
---|---|
device name | The alias for serial port. Available values: DB9, GS0_01, WIZARHANDQ1, Q1_USB_SERIAL, USB_SERIAL, SERIAL_EXT, USB_SLAVE_SERIAL, USB_HOST_SERIAL
|
Cable Connection
Please check follow pictures
- Q4: use picture 2 and picture 3, the Usb to DB9 cable ; or picture 4 the UU cable
Cables
OTG to USB Host TypeA Female:
USB to Serial port cable, USB TypeA Male to DB9 Female:
USB to Serial port cable, USB TypeA Male to DB9 Male:
UU cable, 2 USB Serial port cable cross connected together: