《UHFReader18CSharp.DLL动态连接库使用手册V.doc》由会员分享,可在线阅读,更多相关《UHFReader18CSharp.DLL动态连接库使用手册V.doc(36页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、UHFReader18CSharp.DLL动态连接库使用手册V2.51.操作系统:12.函数详单:12.1)通用函数:12.2)EPCC1-G2 协议函数:22.3)18000-6B 协议函数:43.函数的描述:53.1)通用函数:53.1.1) AutoOpenComPort():自动连接串口53.1.2) OpenComPort():连接到指定串口63.1.3) CloseComPort():关闭串口连接73.1.4) CloseSpecComPort():关闭指定串口73.1.5)GetReaderInformation():获得读写器的信息73.1.6) WriteComAdr():写
2、入读写器地址83.1.7) WriteScanTime():设置询查命令最大响应时间93.1.8) SetPowerDbm ():设置读写器功率93.1.9) Writedfre ():设置读写器工作频率93.1.10) Writebaud ():设置串口波特率103.1.11) SetWGParameter():设置韦根参数113.1.12) SetWorkMode():设置工作模式113.1.13) GetWorkModeParameter ():读取工作模式参数123.1.14) ReadActiveModeData ():读取主动模式数据-133.1.15) SetAccuracy()
3、:EAS检测精度测试 -133.1.16) SetOffsetTime ():设置Syris命令响应偏置时间 -133.1.17) SetFhssMode ():设置读写器跳频模式143.1.18) GetFhssMode ():获取读写器跳频模式 -143.1.19) SetTriggerTime ():获取读写器跳频模式 -153.1.20) BuzzerAndLEDControl ():声光控制命令 -153.1.21) SetRelay ():设置继电器动作 -163.1.22) OpenNetPort():连接网口163.1.23) CloseNetPort():关闭网口173.2)
4、 EPCC1-G2 协议函数:173.2.1) Inventory_G2 ():G2询查命令173.2.2) ReadCard_G2 ():G2读取数据命令183.2.3) WriteCard_G2 ():G2写命令193.2.4) EraseCard_G2 ():G2块擦除命令203.2.5) SetCardProtect_G2 ():G2设定存储区读写保护状态命令213.2.6) DestroyCard_G2 ():G2销毁卡片命令223.2.7) WriteEPC_G2 ():G2写EPC号命令233.2.8) SetReadProtect_G2 ():G2单张读保护设置命令233.2.
5、9) SetMultiReadProtect_G2 ():G2单张读保护设置命令(不需卡号)243.2.10) RemoveReadProtect_G2 ():G2解锁读保护命令253.2.11) CheckReadProtected_G2 ():G2测试卡片是否被读保护命令253.2.12) SetEASAlarm_G2 ():G2 EAS报警设置命令263.2.13) CheckEASAlarm_G2 ():G2 EAS报警探测命令273.2.14) LockUserBlock_G2 ():G2 user区块锁命令(永久锁定)273.2.15) WriteBlock_G2 ():G2块写命
6、令283.3) 18000-6B 协议函数:293.3.1) Inventory_6B ():6B寻查命令(单张)293.3.2) Inventory2_6B ():6B按条件寻查电子标签命令303.3.3) ReadCard_6B ():6B读数据命令303.3.4) WriteCard_6B ():6B写数据命令313.3.5) CheckLock_6B ():6B锁定检测命令323.3.6) LockByte_6B ():6B锁定命令324.其他返回值定义335.错误代码定义342UHFReader18CSharp.DLL动态连接库使用手册V2.5上位机应用程序通过UHFReader18
7、CSharp.DLL操作EPCC1-G2、18000-6B格式电子标签读写器。1. 操作系统:WINDOWS 2000/XP2. 函数详单:UHFReader18CSharp.DLL包括了如下的操作函数:2.1)通用函数:1)Function int StaticClassReaderB.AutoOpenComPort(int* Port,unsigned char * ComAdr, unsigned char * Baud ,int* FrmHandle);2)Function int StaticClassReaderB.OpenComPort(int Port, unsigned ch
8、ar *ComAdr, unsigned char * Baud,int* FrmHandle);3)Function int StaticClassReaderB.CloseComPort(void);4) Function int StaticClassReaderB.WINAPI CloseSpecComPort(int FrmHandle);5)Function int StaticClassReaderB.GetReaderInformation(unsigned char *ComAdr, unsigned char *VersionInfo, unsigned char *Rea
9、derType, unsigned char *TrType,unsigned char * dmaxfre , unsigned char *dminfre, unsigned char *powerdBm,unsigned char *ScanTime, int FrmHandle);6) Function int StaticClassReaderB.WriteComAdr(unsigned char *ComAdr, unsigned char *ComAdrData, int FrmHandle);7)Function int StaticClassReaderB.WriteScan
10、Time(unsigned char *ComAdr, unsigned char *ScanTime, int FrmHandle);8)Function int StaticClassReaderB.SetPowerDbm (unsigned char *ComAdr, unsigned char * powerDbm, int FrmHandle);9)Function int StaticClassReaderB.Writedfre (unsigned char *ComAdr, unsigned char * dmaxfre, unsigned char * dminfre,int
11、FrmHandle);10)Function int StaticClassReaderB.Writebaud (unsigned char *ComAdr, unsigned char * baud, int FrmHandle);11) Function int StaticClassReaderB.SetWGParameter(unsigned char *ComAdr, unsigned char Wg_mode,unsigned char Wg_Data_Inteval,unsigned char Wg_Pulse_Width, unsigned char Wg_Pulse_Inte
12、val,int FrmHandle);12)Function int StaticClassReaderB.SetWorkMode(unsigned char *ComAdr, unsigned char * Parameter, int FrmHandle);13)Function int StaticClassReaderB.GetWorkModeParameter(unsigned char *ComAdr, unsigned char * Parameter, int FrmHandle);14)Function int StaticClassReaderB.ReadActiveMod
13、eData(unsigned char *ActiveModeData, unsigned char * Datalength, int FrmHandle);15) Function int StaticClassReaderB.SetAccuracy(unsigned char * ComAdr, unsigned char Accuracy , long FrmHandle);16) Function int StaticClassReaderB.SetOffsetTime(unsigned char * ComAdr, unsigned char OffsetTime, long Fr
14、mHandle);17) Function int StaticClassReaderB.SetFhssMode(unsigned char * ComAdr, unsigned char FhssMode, long FrmHandle);18) Function int StaticClassReaderB.GetFhssMode(unsigned char * ComAdr, unsigned char *FhssMode, long FrmHandle);19) Function int StaticClassReaderB.SetTriggerTime(unsigned char *
15、 ComAdr, unsigned char *TriggerTime, long FrmHandle);20) Function int StaticClassReaderB.BuzzerAndLEDControl(unsigned char * ComAdr, unsigned char AvtiveTime, unsigned char SilentTime, unsigned char Times, int FrmHandle);21) Function int StaticClassReaderB.SetRelay(unsigned char * ComAdr, unsigned c
16、har RelayStatue, long FrmHandle);22) Function int StaticClassReaderB.OpenNetPort (int Port, LPSTR IPaddr, ,unsigned char *ComAdr, int FrmHandle);23) Function int StaticClassReaderB.CloseNetPort (int FrmHandle);2.2)EPCC1-G2 协议函数:1)Function int StaticClassReaderB. Inventory_G2 (unsigned char *ComAdr,
17、unsigned char AdrTID,unsigned char LenTID,unsigned char TIDFlag,unsigned char * EPClenandEPC, int * Totallen, int *CardNum,int FrmHandle);2)Function int StaticClassReaderB. ReadCard_G2 (unsigned char *ComAdr, unsigned char * EPC, unsigned char * Mem, unsigned char * WordPtr, unsigned char * Num, uns
18、igned char * Password , unsigned char maskadr, unsigned char maskLen, unsigned char maskFlag,unsigned char * Data , unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);3)Function int StaticClassReaderB.WriteCard_G2 (unsigned char *ComAdr, unsigned char * EPC, unsigned char * Mem, uns
19、igned char * WordPtr, unsigned char * Writedatalen, unsigned char *Writedata,unsigned char * Password, unsigned char maskadr, unsigned char maskLen, unsigned char maskFlag, int WrittenDataNum, unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);4)Function int StaticClassReaderB.Erase
20、Card_G2 (unsigned char *ComAdr, unsigned char * EPC, unsigned char * Mem, unsigned char * WordPtr, unsigned char * Num, unsigned char * Password, unsigned char maskadr, unsigned char maskLen, unsigned char maskFlag, unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);5)Function int S
21、taticClassReaderB.SetCardProtect_G2 (unsigned char *ComAdr, unsigned char * EPC, unsigned char * select, unsigned char * setprotect, unsigned char * Password, unsigned char maskadr, unsigned char maskLen, unsigned char maskFlag, unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);6)F
22、unction int StaticClassReaderB.DestroyCard_G2 (unsigned char *ComAdr, unsigned char * EPC, unsigned char * Password, unsigned char maskadr, unsigned char maskLen, unsigned char maskFlag, unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);7)Function int StaticClassReaderB. WriteEPC_G
23、2 (unsigned char *ComAdr, unsigned char * Password, unsigned char * WriteEPC, unsigned char * WriteEPClen, unsigned char * errorcode,int FrmHandle);8)Function int StaticClassReaderB.SetReadProtect_G2(unsigned char *ComAdr, unsigned char * EPC, unsigned char * Password, unsigned char maskadr, unsigne
24、d char maskLen, unsigned char maskFlag, unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);9)Function int StaticClassReaderB.SetMultiReadProtect_G2 (unsigned char *ComAdr, unsigned char * Password, unsigned char * errorcode,int FrmHandle);10)Function int StaticClassReaderB.RemoveRea
25、dProtect_G2(unsigned char * ComAdr , unsigned char * Password, unsigned char * errorcode,int FrmHandle);11)Function int StaticClassReaderB.CheckReadProtected_G2(unsigned char * ComAdr, unsigned char *readpro,unsigned char * errorcode,int FrmHandle);12)Function int StaticClassReaderB.SetEASAlarm_G2(u
26、nsigned char *ComAdr, unsigned char * EPC, unsigned char * Password, unsigned char maskadr, unsigned char maskLen, unsigned char maskFlag,unsigned char * EAS, unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);13)Function int StaticClassReaderB.CheckEASAlarm_G2(unsigned char *ComAdr
27、, unsigned char * errorcode,int FrmHandle);14)Function int StaticClassReaderB.LockUserBlock_G2(unsigned char *ComAdr, unsigned char * EPC, unsigned char * Password, unsigned char maskadr, unsigned char maskLen, unsigned char maskFlag, unsigned char * BlockNum,unsigned char * EPClength, unsigned char
28、 * errorcode,int FrmHandle);15)Function int StaticClassReaderB. WriteBlock_G2 (unsigned char *ComAdr, unsigned char * EPC, unsigned char * Mem, unsigned char * WordPtr, unsigned char * Writedatalen, unsigned char *Writedata,unsigned char * Password, unsigned char maskadr, unsigned char maskLen, unsi
29、gned char maskFlag, int WrittenDataNum, unsigned char * EPClength, unsigned char * errorcode,int FrmHandle);2.3)18000-6B 协议函数:1)Function int StaticClassReaderB.Inventory_6B(unsigned char *ComAdr, unsigned char * ID_6B ,int FrmHandle);2)Function int StaticClassReaderB.Inventory2_6B(unsigned char *Com
30、Adr, unsigned char * Condition , unsigned char * StartAddress, unsigned char * mask , unsigned char * ConditionContent,unsigned char * ID_6B , int * Cardnum,int FrmHandle);3)Function int StaticClassReaderB. ReadCard_6B(unsigned char *ComAdr, unsigned char * ID_6B , unsigned char * StartAddress, unsi
31、gned char * Num, unsigned char * Data, unsigned char * errorcode, int FrmHandle);4)Function int StaticClassReaderB.WriteCard_6B (unsigned char *ComAdr, unsigned char * ID_6B , unsigned char * StartAddress, unsigned char * Writedata, unsigned char * Writedatalen, unsigned char * writtenbyte, unsigned
32、 char * errorcode, int FrmHandle);5)Function int StaticClassReaderB.LockByte _6B (unsigned char *ComAdr, unsigned char * ID_6B , unsigned char * Address, unsigned char * errorcode, int FrmHandle);6)Function int StaticClassReaderB. CheckLock_6B(unsigned char *ComAdr, unsigned char * ID_6B , unsigned
33、char * Address, unsigned char * ReLockState,unsigned char * errorcode, int FrmHandle);3. 函数的描述:3.1)通用函数:) AutoOpenComPort():自动连接串口功能描述:该函数用于自动识别与读写器连接的串口并且执行初始化操作,然后通过连接串口和读写器以创建通信连接。数据传输协议是57600 bps,8位数据,1停止位,没有奇偶校验位。在调用其它函数之前,您必须先连接串口和读写器。应用:Function int StaticClassReaderB.AutoOpenComPort(int* Por
34、t, unsigned char *ComAdr, unsigned char * Baud ,int* FrmHandle);参数:Port:输出变量,COM1COM12与读写器连接的串口号。ComAdr:输入/输出变量,远距离读写器的地址。以广播地址(0xFF)调用此函数,函数将检测各个端口,并将检测到的连接有读写器的端口以及该端口上读写器的实际地址回写到指针Port和ComAdr所指变量中;以其它地址调用此函数,将在各个端口检测是否连接了具有指定ComAdr地址的读写器,并将检测到的端口号回写到指针Port所指变量中。Baud:输入变量,用该值设置或更改串口通讯控件的波特率。baudra
35、te实际波特率09600bps119200 bps238400 bps456000 bps557600 bps6115200 bps FrmHandle:输出变量,返回与读写器连接端口对应的句柄,应用程序通过该句柄可以操作连接在相应端口的读写器。如果打开不成功,返回的句柄值为-1.COM1-COM12的含义如下:#define COM1 1#define COM2 2#define COM3 3#define COM4 4#define COM5 5#define COM6 6#define COM7 7#define COM8 8#define COM9 9返回:如果该函数调用成功,返回一个
36、零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。) OpenComPort():连接到指定串口功能描述:该函数用于指定串口初始化,并通过连接串口和读写器以创建通信连接。数据传输协议是57600bps,8位数据,1位停止位,没有奇偶校验位。在调用其它函数之前,您必须先连接串口和读写器。应用:Function int StaticClassReaderB.OpenComPort(int Port, unsigned char *ComAdr, unsigned char * Baud,int FrmHandle);参数:Port:输入变量,COM1COM12常数。Co
37、mAdr:输入/输出变量,远距离读写器的地址。以广播地址(0xFF)调用此函数,函数将检测指定端口,并将检测到的连接在此端口上的读写器的实际地址回写到指针ComAdr所指变量中;以其它地址调用此函数,将检测指定端口上是否连接了具有指定ComAdr地址的读写器。Baud:输入变量,用该值设置或更改串口通讯控件的波特率。baudrate实际波特率09600bps119200 bps238400 bps456000 bps557600 bps6115200 bpsFrmHandle:输出变量,返回与读写器连接端口对应的句柄,应用程序通过该句柄可以操作连接在相应端口的读写器。如果打开不成功,返回的句柄
38、值为-1.COM1-COM12的定义如下:#define COM1 1#define COM2 2#define COM3 3#define COM4 4#define COM5 5#define COM6 6#define COM7 7#define COM8 8#define COM9 9返回:如果该函数调用成功,返回一个零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。) CloseComPort():关闭串口连接功能描述:该函数用于撤销串口和读写器的连接并释放相应资源。在一些开发环境里,串口资源必须在离开该程序前被释放,否则可能会造成系统不稳定。应用:Fun
39、ction int StaticClassReaderB.CloseComPort(void);参数:无返回:如果该函数调用成功,返回一个零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。3.1.4) CloseSpecComPort():关闭指定串口功能描述:该函数用于关闭指定串口。应用:Function int StaticClassReaderB.CloseSpecComPort(int FrmHandle);参数:FrmHandle:输入变量,COM1COM12常数。COM1-COM12的定义如下:#define COM1 1#define COM2 2#d
40、efine COM3 3#define COM4 4#define COM5 5#define COM6 6#define COM7 7#define COM8 8#define COM9 9返回:如果该函数调用成功,返回一个零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。3.1.5)GetReaderInformation():获得读写器的信息功能描述:执行该命令后,将获得读写器的信息,这其中包括读写器地址(ComAdr)和读写器软件版本(VersionInfo)的信息等多项信息。应用:Function int StaticClassReaderB.GetRea
41、derInformation(unsigned char *ComAdr, unsigned char *VersionInfo, unsigned char *ReaderType, unsigned char *TrType,unsigned char * dmaxfre , unsigned char *dminfre, unsigned char *powerdBm,unsigned char *ScanTime, int FrmHandle);参数:ComAdr:输入/输出变量,远距离读写器的地址。以广播地址(0xFF)调用此函数,ComAdr将返回读写器的实际地址,以其它地址调用此
42、函数,将由ComAdr地址指定的读写器执行此函数命令。VersionInfo:指向输出数组变量(输出的是每字节都转化为字符的数据),远距离读写器版本信息,长度2个字节。第1个字节为版本号,第2个字节为子版本号。ReaderType:输出变量,读写器类型代码,0x61代表UHFReader18。TrType:指向输出数组变量(输出的是每字节都转化为字符的数据),读写器协议支持信息,长度2个字节,具体定义请参见用户手册。(bit1为1表示支持18000-6c协议,其它位保留。Bit0为1表示18000-6B协议。)Dmaxfre:输出变量,当前读写器使用的最高频率。 Dminfre:输出变量,当前
43、读写器使用的最低频率。实际频率计算公式为:Fs = 902.6 + N x 0.4 (MHz) 其中N0, 62。N代表dmaxfre或dminfre。PowerdBm: 输出变量,读写器的输出功率。范围是0到18,当PowerdBm为0x00时,表示读写器的输出功率未知。ScanTime:输出变量,读写器询查命令最大响应时间。FrmHandle:输入变量,返回与读写器连接端口对应的句柄,应用程序通过该句柄可以操作连接在相应端口的读写器。如果打开不成功,返回的句柄值为-1. 返回:如果该函数调用成功,返回一个零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。 3.1
44、.6) WriteComAdr():写入读写器地址功能描述:执行该命令后,读写器将会把读写器地址改为用户给定的值,并把这个值写入EEPROM保存。出厂时默认值是0x00。允许用户的修改范围是0x000xfe。当用户写入的值是0xff时,读写器将会自动恢复成默认值0x00。应用:Function int StaticClassReaderB.WriteComAdr(unsigned char *ComAdr, unsigned char *ComAdrData, int FrmHandle);参数:ComAdr : 输入变量,原先的读写器地址ComAdrData:输入变量,一个字节,待写入的读写
45、器地址FrmHandle:输入变量,返回与读写器连接端口对应的句柄,应用程序通过该句柄可以操作连接在相应端口的读写器。如果打开不成功,返回的句柄值为-1.返回:如果该函数调用成功,返回一个零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。3.1.7) WriteScanTime():设置询查命令最大响应时间功能描述:询查命令的最大响应时间范围是3255*100ms,默认值为30*100ms。应用:Function int StaticClassReaderB.WriteScanTime(unsigned char *ComAdr, unsigned char *Sc
46、anTime, int FrmHandle);参数:ComAdr : 输入变量,读写器地址ScanTime:输入变量,一个字节,询查命令响应时间FrmHandle:输入变量,返回与读写器连接端口对应的句柄,应用程序通过该句柄可以操作连接在相应端口的读写器。如果打开不成功,返回的句柄值为-1.返回:如果该函数调用成功,返回一个零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。3.1.8) SetPowerDbm ():设置读写器功率功能描述:本命令用来设置读写器功率。应用:Function int StaticClassReaderB. SetPowerDbm (unsigned char *ComAdr, unsigned char * powerDbm, int FrmHandle);参数:ComAdr : 输入变量,读写器地址Powerdbm:输入变量,一个字节。读写器的输出功率。取值范围是018。FrmHandle:输入变量,返回与读写器连接端口对应的句柄,应用程序通过该句柄可以操作连接在相应端口的读写器。如果打开不成功,返回的句柄值为-1.返回:如果该函数调用成功,返回一个零值。否则,返回非零值请查看其他返回值定义,返回的错误代码请查看错误代码定义。3.1.9) Writedfre ():设置读写器工作频率功能描述:此命令设置读写器工作地上限频