Unipay III Overview

This is Unipay III Java SDK for Linux. The basic idea of this SDK is providing as thin as possible layer over the firmware command set. It provide the direct write/read method, command wrapper method.

A configuration file is provided to define the USB device VID, PID and other information. The configureation file default path is curretn working directory, that could be changed by define environment variable IDT_CFG_PATH.

all commands follow a simple mode: a command to unit(OUT) and a response to host(IN).

The main class is VivoDevice that contain the most API need to access the unit.

A helper class VivoProtocol2 is used so build the command and response.

Bootloader class provide an interface to download a firmware file to unit with progress listener interface that tell the caller what package is downloading

RRQUIREMENT:

  1. Ubuntu 1204 32bit desktop
  2. Libusb 1.0 Download libusb from http://www.libusb.org/
  3. JRE 8 or JDK 8
SETUP:
  1. copy JNI lib to /usr/local/lib
  2. 	
    	$ sudo cp libidtechproducts_pos_VivoDevice.so /usr/local/lib/libidtechproducts_pos_VivoDevice.so
    	
  3. Apply file 40-unipayiii.rules to /etc/udev/rules.d/
  4. This rules file make the non-root user could access the Unipay III.

    	
    	$ sudo cp 40-unipayiii.rules  /etc/udev/rules.d/
    	
  5. Refresh udevd
  6. 	
    	$ sudo udevd -d
    	
Demo USAGE :
  1. Install the libusb with command "./configue;make;sudo make install"
  2. Plug in the UnipayIII unit
  3. run "sudo ./runjar.sh"

Configure file

posconfig.json is used as the configure file, that contain the logical name and parameters.

the posconfig.json location is working directory, and the environment variable "IDT_CFG_PATH" is used to change the default location.


export IDT_CFG_PATH="cfg"

this envrionment change the config file position to ./cfg/posconfig.json

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{
"config_version" : 1.0,
"devices" : [
  {
    "name" : "default",
    "interface" : "USBHID",
    "VID" : "0ACD",
    "PID" : "3520"
  },
  {
    "name" : "UnipayIII",
    "interface" : "USBHID",
    "VID" : "0ACD",
    "PID" : "3520",
    "enable_log" : 1
  },
  {
    "name" : "KioskIII",
    "interface" : "USBHID",
    "VID" : "0ACD",
    "PID" : "3710"
  },
],

"log_level" : 1,
"log_file" : ".pos.log",
"log_to_console" : true
}

Example

Ping: this example show the simplest operation : open unit, send a command to unit, then close it.

the source code:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
    private static void ping_test(){
        VivoDevice dev = new VivoDevice();
        try {
            System.out.println("VivoDeivce Test: ping");
            dev.Open("default");

            // use the Ping method
            if ( dev.Ping().GetStatus() == StatusCode.EOK)
                System.out.println("ping success");
            else
                System.out.println("ping fail");

            //DirectWrite/Read method
            VivoProtocol2 p = VivoProtocol2.BuildCommand((byte)0x18,(byte)0x01);
            dev.DirectWrite(p.GetRawData(), 1000);
            byte[] ret = dev.DirectRead(1000);
            System.out.println("out " + ret.toString());

            dev.Close();
        }catch (VivoDeviceException e) {
            System.out.println("Device Error Happen!");
            System.out.println(e);
        }
    }

line 2: it define a variable "VivoDevice".

line 5: it open the a devcie with logial name in the "posconfig.json", that JSON file contain the information of the device, including USB VID/PID.

This example show 2 method to access the devcie: SDK method and directWrite/Read.

line 8: call the SDK method "Ping".

line 15/16: call the DirectWrite/Read to send the ping command.

line 14 : it use a help class VivoProtocol2 to create the ping command with Command/Sub-Command that defined in the product design specification.

line 19: it close the device finally.