日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

Java JNI调用IC卡读卡器

發布時間:2024/3/12 java 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Java JNI调用IC卡读卡器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

Java JNI調用IC卡讀卡器

Java調用IC卡讀卡器的DLL一般有以下2種方式:

1.使用JNative第三方庫調用IC卡讀卡器dll的接口.

2.使用JNI調用IC卡讀卡器dll的接口.

JNative調用IC卡讀卡器dll很方便,只要知道接口名稱和參數類型即可調用, 缺點是僅支持32位的程序, 不支持64位。

JNI調用IC卡讀卡器的DLL,既支持64位程序也支持32位程序, 調用也非常方便,下面將介紹JNI調用IC卡讀卡器DLL的方式。
對于經常使用的普通IC卡為例, 首先聲明相關的api接口:

public native int YW_USBHIDInitial();

public native int YW_USBHIDFree();

public native int YW_Buzzer(int ReaderID,int Time_ON, int Time_OFF, int Cycle);

public native int YW_Led(int ReaderID,int LEDIndex, int Time_ON, int Time_OFF, int Cycle, int LedIndexOn);

public native int YW_AntennaStatus(int ReaderID,boolean Status);

public native int YW_SearchCardMode(int ReaderID,int Mode);

public native int YW_RequestCard(int ReaderID,int RequestMode, short CardType[]);

public native int YW_AntiCollide(int ReaderID, byte LenSNO[], byte SNO[]);

public native int YW_CardSelect(int ReaderID,byte LenSNO, byte SNO[]);

public native int YW_DownLoadKey(int ReaderID,int KeyIndex, byte Key[]);

public native int YW_KeyDown_Authorization(int ReaderID,int KeyMode, int BlockAddr, byte KeyIndex);

public native int YW_KeyAuthorization(int ReaderID,int KeyMode, int BlockAddr, byte[]Key);

public native int YW_ReadaBlock(int ReaderID,int BlockAddr, int LenData, byte pData[]);

public native int YW_WriteaBlock(int ReaderID,int BlockAddr, int LenData, byte pData[]);

public native int YW_Purse_Initial(int ReaderID,int BlockAddr, int IniMoney);

public native int YW_Purse_Read(int ReaderID,int BlockAddr, int Money[]);

public native int YW_Purse_Decrease(int ReaderID,int BlockAddr, int Decrement);

public native int YW_Purse_Charge(int ReaderID,int BlockAddr, int Charge);

public native int YW_CardHalt(int ReaderID);

public native int YW_Restore(int ReaderID,int BlockAddr);

public native int YW_Transfer(int ReaderID,int BlockAddr);

public native int YW_AntiCollideAndSelect(int ReaderID,byte ReturnMode, byte CardMem[], byte SNLen[], byte SN[]);

然后靜態裝載dll,64位程序裝載64位的dll,32位裝載32位的dll。

static {

System.loadLibrary(“YW60X-32”);

}

經過以上聲明后,就可以直接調用接口了,如:

YOWORFID rfidreader = new YOWORFID();

rfidreader.YW_USBHIDInitial();int rt =0;rt =rfidreader.YW_RequestCard(ReaderID,Requestmode,Cardtype);rt = rfidreader.YW_AntiCollide(ReaderID,LenSn,CardNo);HexToStr(CardNo,LenSn[0]);rt =rfidreader.YW_CardSelect(ReaderID,LenSn[0],CardNo);rt =rfidreader.YW_KeyAuthorization(ReaderID,96,4,Key);System.out.printf("KeyAuthorization=%d",rt);System.out.println(); rt =rfidreader.YW_ReadaBlock(ReaderID,4,16,BlockData);System.out.printf("YW_ReadaBlock=%d",rt);System.out.println();if(rt>0){HexToStr(BlockData,16);} rfidreader.YW_Led(ReaderID,1,1,1,3,0);rfidreader.YW_USBHIDFree();

以下java代碼例子包含了讀卡和寫卡的,可以使用32位或者64的dll,Java JNI調用IC卡讀卡器例程

下載Java JNI調用IC卡讀卡器例程

總結

以上是生活随笔為你收集整理的Java JNI调用IC卡读卡器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。