I. Windows 32 (Java language)-driven development
In the Java folder of D3, there are two folders: classpackage and example. The file is readme.txt.
Javard800.dll in classpackage is a Windows dynamic link library for Java JNI.
Javard800.java in classpackage is a JNI interface for Java.
Javard800demo. Java in example is a test program written in Java.
The Calling sequence is as follows:
Javard800demo. Java ---> javard800.java ---> javard800.dll
Javard800.dll File Download
/* * @(#)JavaRD800.java 1.0 03/11/27 * * You can modify the template of this file in the * directory ..\JCreator\Templates\Template_1\Project_Name.java * * You can also create your own project template by making a new * folder in the directory ..\JCreator\Template\. Use the other * templates as examples. * */public class JavaRD800{public JavaRD800(){}static{System.loadLibrary("javaRD800");}public native int dc_init(int lPort,int lBaud);public native short dc_exit(int lDevice);public native short dc_card(int lDevice,short iMode,int[] pSnr);public native short dc_authentication(int lDevice,short iMode,short iSecNr);public native short dc_halt(int lDevice);public native short dc_read(int lDevice,short iAdr,char[] pData);public native short dc_write(int lDevice,short iAdr,char[] pData);public native short dc_increment(int lDevice,short iAdr,int lValue);public native short dc_decrement(int lDevice,short iAdr,int lValue);public native short dc_initval(int lDevice,short iAdr,int lValue);public native short dc_readval(int lDevice,short iAdr,int[] pValue);public native short dc_transfer(int lDevice,short iAdr);public native short dc_restore(int lDevice,short iAdr);public native short dc_load_key(int lDevice,short iMode,short iSecNr,char[] pKey);public native short dc_beep(int lDevice,short iMsec);public native short dc_high_disp(int lDevice,short iOffset,short iDispLen,char[] pDispStr);public native short dc_request(int lDevice,short iMode,int[] pTagType);public native short dc_anticoll(int lDevice,short iBcnt,int[] pSnr);public native short dc_select(int lDevice,int lSnr,short[] pSize);public native short dc_gettime(int lDevice,char[] pTimeStr);public native short dc_gettimehex(int lDevice,char[] pTimeStr);public native short dc_settime(int lDevice,char[] pTimeStr);public native short dc_settimehex(int lDevice,char[] pTimeStr);public native short dc_setbright(int lDevice,short iBright);public native short dc_ctl_mode(int lDevice,short iMode);public native short dc_disp_mode(int lDevice,short iMode);public native short dc_cpureset(int lDevice,short[] pLen,char[] pData);public native short dc_cpuapdu(int lDevice,short iLen,char[] pSData,short[] pLen,char[] pRData);public native short dc_cpuapdusource(int lDevice,short iLen,char[] pSData,short[] pLen,char[] pRData);public native short dc_cpudown(int lDevice);public native short dc_swr_eeprom(int lDevice,int lOffset,int lLen,char[] pBuffer);public native short dc_srd_eeprom(int lDevice,int lOffset,int lLen,char[] pBuffer);public native short dc_disp_str(int lDevice,char[] pDispStr);}
class JavaRD800Demo{public static void main(String[] args){short status;int lDevice = 0;int[] pSnr = new int[1];char[] pSBuffer = new char[16];char[] pRBuffer = new char[16];JavaRD800 rd = new JavaRD800();lDevice = rd.dc_init(100,115200);if(lDevice <= 0){System.out.print("dc_init error!\n");return;}System.out.print("dc_init ok!\n");rd.dc_beep(lDevice,(short)10); status = rd.dc_card(lDevice,(short)0,pSnr);if(status != 0){System.out.print("dc_card error!\n");rd.dc_exit(lDevice);return;}System.out.print("dc_card ok!\n");System.out.println(pSnr[0]);pSBuffer[0] = 0xFF;pSBuffer[1] = 0xFF;pSBuffer[2] = 0xFF;pSBuffer[3] = 0xFF;pSBuffer[4] = 0xFF;pSBuffer[5] = 0xFF;pSBuffer[6] = 0x00;status = rd.dc_load_key(lDevice,(short)0,(short)0,pSBuffer);if(status != 0){System.out.print("dc_load_key error!\n");rd.dc_exit(lDevice);return;}System.out.print("dc_load_key ok!\n");status = rd.dc_authentication(lDevice,(short)0,(short)0);if(status != 0){System.out.print("dc_authentication error!\n");rd.dc_exit(lDevice);return;}System.out.print("dc_authentication ok!\n");for(int i=0;i<16;i++){pSBuffer[i] = 'M';}status = rd.dc_write(lDevice,(short)2,pSBuffer);if(status != 0){System.out.print("dc_write error!\n");rd.dc_exit(lDevice);return;}System.out.print("dc_write ok!\n");status = rd.dc_read(lDevice,(short)2,pRBuffer);if(status != 0){System.out.print("dc_read error!\n");rd.dc_exit(lDevice);return;}System.out.print("dc_read ok!\n");System.out.println(pRBuffer);status = rd.dc_exit(lDevice);if(status != 0){System.out.print("dc_exit error!\n");rd.dc_exit(lDevice);return;}System.out.print("dc_exit ok!\n");}}
1.2 hands-on Testing
Create a new Java project in eclipse. Place javard800demo. Java and javard800.java In the SRC folder and javard800.dll in the project root directory.
Compiled successfully!
An error occurred while running! The system prompts that the dependent class library cannot be found.
1.3. analyze and solve problems
It is estimated that the DLL file is missing. The dcrf32.dll file is missing when downloading the DLL file dependency viewer.
This file does not exist in the Java folder, you can find this file in D3 ---> win32-dll directory, copy this file to the project root directory.
The Calling sequence is as follows:
JavaRD800Demo. java ---> javaRD800.java ---> javaRD800.dll ---> dcrf32.dll
Ii. _x86 (C Language) driver development (ubuntu_12.04 perform the following operations after Sudo-S)