IC卡读卡器与编程语言

北京友我科技RFID读写器 转载请注明出处,本篇地址:https://www.youwokeji.com.cn/ywdn/NoteDetails.asp?id=19

  由于需求的千差万别,IC卡读卡器在实际使用中一般都需要经过二次开发,而软件工程师一般都精通一种或几种编程语言,有时候恰恰要使用不熟悉的编程语言。有时候也有一些工程师问这个IC卡读卡器支不支持这种编程语言,其实答案是肯定的。

  IC卡读卡器SDK中一般都带有DLL文件,实际上这个DLL文件的调用与编程语言是没有关系的,而与编程语言有关系的就是API函数的声明,只要我们了解相关编程语言的语法规则,基本可以用任何编程语言来开发了。

  下面举个例子来说明:

  M1卡的防碰撞并选卡函数YW_AntiCollideAndSelect


函数的C语言声明如下:int stdcall  YW_AntiCollideAndSelect(int ReaderID, unsigned char MultiCardMode, unsigned char *CardMem, unsigned char *SNLen, unsigned char *SN);


delphi声明:function YW_AntiCollideAndSelect(ReaderID: Integer;MultiCardMode:Byte;var CardMem: Byte;var SNOLen:Byte;SNO: PChar): Integer;stdcall;external 'YW60x.dll';


VB声明:Public Declare Function YW_AntiCollideAndSelect Lib "YW60x.dll" (ByVal ReaderID As Long, ByVal MultiCardMode As Byte, ByRef CardMem As Byte, ByRef SNOLen As Byte)


C#声明:[DllImport("YW60x.dll")]


public static extern int YW_AntiCollideAndSelect(int ReaderID,byte MultiCardMode, ref byte CardMem, ref byte SNLen, byte [] SN);


Power Builder 9 声明:public FUNCTION long YW_AntiCollideAndSelect (long lReaderID , char MultiCardMode, ref char CardMem, ref char SNOLen, ref char SNO[]) library "YW60x.dll"


JAVA声明:

public int YW_AntiCollideAndSelect(int ReaderID,byte MultiCardMode, Pointer CardMem, Pointer SNLen, Pointer SN)


{


int ret;


try


{


JNative fuc = new JNative("YW60x.dll", "YW_AntiCollideAndSelect");


fuc.setRetVal(Type.INT);


fuc.setParameter(0, ReaderID);


fuc.setParameter(1, MultiCardMode);


fuc.setParameter(2,CardMem);


fuc.setParameter(3,SNLen);


fuc.setParameter(4,SN);


fuc.invoke();


ret = fuc.getRetValAsInt();


}


catch(NativeException e)


{


ret = -1;


}


catch(IllegalAccessException e)


{


ret = -2;


}


return ret;


}


只要明白各种编程语言中数据类型的转换,就可以自己将这些读卡器SDK中的API函数转换成自己熟悉的声明函数。


支持的RFID读写器:
SDT-HA, YW-605RA, YW-605RB, YW-605RC, YW-605SA, YW-605SB, YW-605SC, YW-605UA, YW-605UB, YW-605UC, YW-605HA, YW-605HB, YW-605HC, YW-620HA, YW-620HB, YW-620HC, YW-608RA, YW-608RB, YW-608RC, YW-608SA, YW-608SB, YW-608SC, YW-608UA, YW-608UB, YW-608HB, YW-608HC, YW-610SA, YW-610SB, YW-610SC, YW-602-R, YW-602-3, YW-602-8