uic680 programmers manual for android devices … keyboard 2. hid msr 3. usb virtual com ......
TRANSCRIPT
UIC680
Programmer’s Manual
For Android Devices
Revision 2
2014-12-10
Uniform Industrial Corporation
2
Document History Document Version Apply to FW Version Change
01 Android 4.3 and above Initial version
02 Android 4.3 and above Correct the wordings
3
Table of Contents
DOCUMENT HISTORY ....................................................................................................................... 2
TABLE OF CONTENTS ....................................................................................................................... 3
CHAPTER 1 INTRODUCTION ........................................................................................................... 5
UIC680 LIBRARY INTRODUCTION ............................................................................................. 5
HOW TO INSTALL LIBRARY ON YOUR ANDROID DEVELOPMENT TOOLS (ADT) ......................... 5
CHAPTER 2 API FOR HID KEYBOARD .......................................................................................... 6
PARSERHIDDATA ..................................................................................................................... 6
CHAPTER 3 API FOR HID MSR ........................................................................................................ 7
PARSERHIDDATA ..................................................................................................................... 7
INIT ........................................................................................................................................... 8
EXIT .......................................................................................................................................... 9
OPEN ....................................................................................................................................... 10
CLOSE ..................................................................................................................................... 11
READ....................................................................................................................................... 12
WRITE ..................................................................................................................................... 13
ISOPEN ................................................................................................................................... 14
ISALIVE .................................................................................................................................. 15
ISRUNNING ............................................................................................................................. 16
STARTIO ................................................................................................................................. 17
STOPIO ................................................................................................................................... 18
STARTRECEIVER ..................................................................................................................... 19
STOPRECEIVER ....................................................................................................................... 20
CHAPTER 4 API FOR USB SERIAL (CDC) .................................................................................... 21
INIT ......................................................................................................................................... 21
EXIT ........................................................................................................................................ 22
OPEN ....................................................................................................................................... 23
CLOSE ..................................................................................................................................... 24
READ....................................................................................................................................... 25
WRITE ..................................................................................................................................... 26
ISOPEN ................................................................................................................................... 27
ISALIVE .................................................................................................................................. 28
ISRUNNING ............................................................................................................................. 29
STARTIO ................................................................................................................................. 30
4
STOPIO ................................................................................................................................... 31
STARTRECEIVER ..................................................................................................................... 32
STOPRECEIVER ....................................................................................................................... 33
5
Chapter 1 Introduction
� UIC680 library introduction
UIC680 provides three communication interface methods:
1. HID Keyboard
2. HID MSR
3. USB Virtual COM
UIC provides a library for our customers to easily develop their applications on Android devices.
� How to install library on your Android Development Tools (ADT)
Here are the steps to install the library:
1. Copy the libraries below to the path of your project/libs/
� uiclib_usbhid
� uiclib_usbserial
2. Right click and select Project >> Properties.
3. Click Java Build Path >> Libraries >> Android Private Libraries.
4. Check if “uiclib_usbhid” and “uiclib_usbserial” are included.
5. If they are not included, press Add JARs >> Select your
project/libs/uiclib_usbserial.jar and uiclib_usbhid.jar to add it.
6. Then, click Java Build Path >> Order and Export. Check the [Android Private
Libraries] if it’s not checked.
6
Chapter 2 API for HID keyboard
� ParserHIDData
Synopsis
import com.uic.tablet.android.lib.usb.hidkb;
String[] ParserHIDData(byte[] bytes,int length)
Description
Parse the field’s data (tracks, Name, CCN, date, et c…) from the
input data.
Parameters
bytes : HID input data.
Length: HID input data Length.
Return Values
String[] : string array:
String[0]=Task1,
String[1]=Task2,
String[2]=Task3,
String[3]=Name on Card,
String[4]=Credit Card Name,
String[5]=Security Code on Card(CCV),
String[6]=Card Expiration(MM/YYYY),
String[7]=ED Service Code,
String[8]=EDPVKI,
String[9]=EDPVV,
String[10]=EDCVV,
String[11]=other data,
String[12]=data error switch.
Notes
N/A.
7
Chapter 3 API for HID MSR
� ParserHIDData
Synopsis
import com.uic.tablet.android.lib.usb.hidkb;
String[] ParserHIDData(byte[] bytes,int length)
Description
Parse the field’s data (tracks, Name, CCN, date, et c...) from the
input data.
Parameters
bytes : HID input data.
Length: HID input data Length.
Return Values
String[] : string array:
String[0]=Task1,
String[1]=Task2,
String[2]=Task3,
String[3]=Name on Card,
String[4]=Credit Card Name,
String[5]=Security Code on Card(CCV),
String[6]=Card Expiration(MM/YYYY),
String[7]=ED Service Code,
String[8]=EDPVKI,
String[9]=EDPVV,
String[10]=EDCVV,
String[11]=other data,
String[12]=data error switch.
Notes
N/A.
8
� init
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void init(Context context)
Description
Register your application to get the permission of the USB device
and also get the broadcast message when this device is detached.
Parameters
Context: your application’s Activity context.
Return Values
None.
Notes
Your application should call this first (it’s bette r at OnCreate())
before you can use the API provided in this documen t.
9
� exit
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void exit(Context context)
Description
Unregister the USB device.
Parameters
Context: your application’s Activity context.
Return Values
None.
Notes
N/A.
10
� open
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
List<DeviceEntry> open (int pid, int vid)
or
List<DeviceEntry> open ()
Description
Open one specified device with a (pid, vid) pair, o r auto detect
the USB device list on your project under
/res/xml/device_filter.xml.
Parameters
Pid: Device’s PID.
Vid: Device’s VID.
Return Values
List<DeviceEntry>: DeviceEntry where
DeviceEntry is a class that contains these two obje cts:
class DeviceEntry {
public UsbDevice device ;
public UsbSerialDriver driver ;
}
Notes
You should check the size of return List<DeviceEntr y> and must have
at least one item before you can use the USB serial device. You can
also check if the USB device is the one you expecte d and its related
information from the DeviceEntry.device and DeviceE ntry.driver.
11
� close
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void close ()
Description
Close the USB Device.
Parameters
N/A.
Return Values
N/A.
Notes
N/A.
12
� read
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
byte[] read()
Description
Read data from the USB device.
Parameters
N/A .
Return Values
byte[]: binary data from the USB device.
Notes
You can only use this API if you poll the receiver.
13
� write
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
int write(byte[] data)
Description
Write data to the USB device.
Parameters
data: binary data.
Return Values
-1: transmitter isn’t running.
0: successful
Notes
N/A .
14
� isOpen
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
boolean isOpen()
Description
Check if the USB device was opened.
Parameters
N/A
Return Values
True: still open
False: has closed
Notes
You might need to call this API to make sure it has been opened
before you use this USB device.
15
� isAlive
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
boolean isAlive()
Description
Check if the USB serial device is still connected.
Parameters
N/A
Return Values
True: connected
False: disconnected
Notes
You might need to call this API occasionally to see if the USB device
has been unplugged.
16
� isRunning
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
boolean isRunning()
Description
Check if the USB device is still running.
Parameters
N/A
Return Values
True: running
False: not running
Notes
You might need to call this API occasionally to see if the USB device
is still running.
17
� startIO
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void startIO(int maxRxByte)
Description
This API polls to receive data.
Parameters
maxRxByte: Buffer size.
Return Values
None.
Notes
N/A.
18
� stopIO
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void stopIO()
Description
This API stops polling data.
Parameters
None.
Return Values
None.
Notes
N/A.
19
� startReceiver
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void startReceiver(SerialReceiver SerialReceiver)
Description
This API provides an interrupt to receive data, aut o call and put
the received data in the function “OnNewData()” tha t you provided
under SerialReceiver.
Parameters
SerialReceiver: Serial Receiver.
Return Values
None.
Notes
N/A.
20
� stopReceiver
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void stopReceiver()
Description
This API will stop the interrupt to receive data.
Parameters
N/A.
Return Values
N/A.
Notes
N/A.
21
Chapter 4 API for USB Serial (CDC)
� init
Synopsis
Import com.uic.tablet.android.lib.usb.serial;
void init(Context context)
Description
This will register your application to get the perm ission of the
USB device and also get the broadcast message while this device
is detached.
Parameters
Context: your application’s Activity context.
Return Values
None.
Notes
Your application should call this first (it’s bette r at OnCreate())
before you can use the API provided in this documen t.
22
� exit
Synopsis
Import com.uic.tablet.android.lib.usb.serial;
void exit(Context context)
Description
Unregister the USB device.
Parameters
Context: your application’s Activity context .
Return Values
None.
Notes
N/A.
23
� open
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
List<DeviceEntry> open (int pid, int vid)
or
List<DeviceEntry> open ()
Description
Open one specified device with a (pid, vid) pair, o r auto detect
the USB device list on your project under
/res/xml/device_filter.xml.
Parameters
Pid: Device’s PID.
Vid: Device’s VID.
Return Values
List<DeviceEntry>: DeviceEntry where
DeviceEntry is a class that contains these two obje cts:
class DeviceEntry {
public UsbDevice device ;
public UsbSerialDriver driver ;
}
Notes
You should check the size of return List<DeviceEntr y> and must have
at least one item before you can use the USB serial device. You can
also check if the USB device is the one you expecte d and its related
information from the DeviceEntry.device and DeviceE ntry.driver.
24
� close
Synopsis
Import com.uic.tablet.android.lib.usb.serial;
void close ()
Description
Close the USB Device.
Parameters
N/A.
Return Values
N/A.
Notes
N/A.
25
� read
Synopsis
Import com.uic.tablet.android.lib.usb.serial;
byte[] read()
Description
Read data from the USB device.
Parameters
N/A.
Return Values
byte[]: binary data from USB device.
Notes
You only can use this API if you poll the data.
26
� write
Synopsis
Import com.uic.tablet.android.lib.usb.serial;
int write(byte[] data)
Description
Write data to the USB device.
Parameters
data: binary data.
Return Values
-1: transmitter isn’t running.
0: successful
Notes
N/A.
27
� isOpen
Synopsis
Import com.uic.tablet.android.lib.usb.serial;
boolean isOpen()
Description
Check if the USB device was opened.
Parameters
N/A
Return Values
True: still open
False: has closed
Notes
You might need to call this API to make sure it has been opened
before you use this USB device.
28
� isAlive
Synopsis
Import com.uic.tablet.android.lib.usb.serial;
boolean isAlive()
Description
Check if the USB serial device is still connected.
Parameters
N/A
Return Values
True: connected
False: disconnected
Notes
You might need to call this API occasionally to see if the USB device
has been unplugged.
29
� isRunning
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
boolean isRunning()
Description
Check if the USB device is still running.
Parameters
N/A
Return Values
True: running
False: not running
Notes
You might need to call this API occasionally to see if the USB device
is still running.
30
� startIO
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void startIO(int maxRxByte)
Description
This API polls to receive data.
Parameters
maxRxByte: Buffer size.
Return Values
None.
Notes
N/A.
31
� stopIO
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void stopIO()
Description
This API stops polling data.
Parameters
None.
Return Values
None.
Notes
N/A.
32
� startReceiver
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void startReceiver(SerialReceiver SerialReceiver)
Description
This API provides an interrupt to receive data, aut o call and put
the received data in the function “OnNewData()” tha t you provided
under SerialReceiver.
Parameters
SerialReceiver: Serial Receiver.
Return Values
None.
Notes
N/A.
33
� stopReceiver
Synopsis
Import com.uic.tablet.android.lib.usb.hid;
void stopReceiver()
Description
This API will stop the interrupt to receive data.
Parameters
N/A.
Return Values
N/A.
Notes
N/A.