终端一体化运控平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

264 lines
10 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Runtime.InteropServices;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace BPASmartClient.Nfc
  8. {
  9. public class Reader
  10. {
  11. /*System Setting*/
  12. [DllImport("function.dll")]
  13. public static extern int SetSerNum(byte[] newValue, [In] byte[] buffer);
  14. /*
  15. 函数功能:设置 8个字节的产品序列号。
  16. 输入参数:      描述
  17. newValue 8个字节的读写器序列号
  18. buffer 用来返回接收到的数据的指针
  19. 输出参数:
  20. buffer 返回STATUS后的状态
  21. * 如果设置成功,则*buffer=0x 80
  22. 如果设置失败,则*buffer为底层(读卡器单片机)上传的错误代码
  23. 返回值:
  24. 0x00,设置成功
  25. 0x01,设置失败
  26. */
  27. [DllImport("function.dll")]
  28. public static extern int GetSerNum([In] byte[] buffer);
  29. /*
  30. 函数功能:
  31. 读取由厂家预设的1个字节的读卡器地址和8个字节序列号.
  32. 输入参数:
  33. buffer 传入一个指针,用来返回接收到的数据
  34. 输出参数:
  35. buffer buffer[0] 读写器地址
  36. buffer[1...8] 8个字节的读写器序列号
  37. 返回值:
  38. 0x00,操作成功
  39. 0x01,操作失败
  40. */
  41. [DllImport("function.dll")]
  42. public static extern int GetVersionNum([In] byte[] strVersionNum);
  43. /*
  44. 函数功能:
  45. 读取读写器的版本号.
  46. 输入参数:
  47. VersionNum 待读入的版本号
  48. 输出参数:
  49. *VersionNum
  50. * 如果 :操作失败, 则VersionNum [0] 为 错误代码
  51. 如果 :操作成功, 则VersionNum [0..N] 为读入的版本号
  52. 返回值:
  53. 0x00,操作成功
  54. 0x01,操作失败
  55. */
  56. [DllImport("function.dll")]
  57. public static extern int ControlLED(int freq, int duration, [In] byte[] buffer);
  58. /*
  59. 函数功能: 设置读卡器的错误提示
  60. 输入参数:
  61. buffer 待返回的参数
  62. 输出参数:
  63. buffer 如果 :操作失败, 则buffer [0] 为 错误代码(参考2.2)
  64. 如果 :操作成功, 则buffer [0] 为成功标志 ,即为0x80
  65. 返回值:
  66. 0x00,操作成功,
  67. 0x01,操作失败
  68. */
  69. [DllImport("function.dll")]
  70. public static extern int ControlBuzzer(int freq, int duration, [In] byte[] buffer);
  71. /*
  72. 函数功能: 控制读卡器的正确提示
  73. 输入参数:
  74. buffer 待返回的参数
  75. 输出参数:
  76. buffer 如果 :操作失败, 则buffer [0] 为 错误代码(参考2.2)
  77. 如果 :操作成功, 则buffer [0] 为成功标志 ,即为0x80
  78. 返回值:
  79. 0x00,操作成功,
  80. 0x01,操作失败
  81. */
  82. /*14443A-MF*/
  83. [DllImport("function.dll")]
  84. public static extern int MF_Read(byte mode, byte blk_add, byte num_blk, [In] byte[] snr, [In] byte[] buffer);
  85. [DllImport("function.dll")]
  86. public static extern int MF_Write(byte mode, byte blk_add, byte num_blk, [In] byte[] snr, [In] byte[] buffer);
  87. [DllImport("function.dll")]
  88. public static extern int MF_InitValue(byte mode, byte SectNum, [In] byte[] snr, [In] byte[] value);
  89. [DllImport("function.dll")]
  90. public static extern int MF_Dec(byte mode, byte SectNum, [In] byte[] snr, [In] byte[] value);
  91. [DllImport("function.dll")]
  92. public static extern int MF_Inc(byte mode, byte SectNum, [In] byte[] snr, [In] byte[] value);
  93. [DllImport("function.dll")]
  94. public static extern int MF_Request([In] byte[] commHandle, int DeviceAdddress, byte inf_mode, [In] byte[] Buffer);
  95. [DllImport("function.dll")]
  96. public static extern int MF_Select([In] byte[] commHandle, int DeviiceAddress, byte inf_mode, [In] byte[] buffer);
  97. [DllImport("function.dll")]
  98. public static extern int MF_Halt();
  99. [DllImport("function.dll")]
  100. public static extern int MF_Anticoll([In] byte[] commHandle, int DeviceAddress, [In] byte[] snr, [In] byte[] status);
  101. [DllImport("function.dll")]
  102. public static extern int MF_Restore([In] byte[] commHandle, int DeviceAddress, byte mode, byte cardlength, [In] byte[] carddata);
  103. [DllImport("function.dll")]
  104. public static extern int MF_Getsnr(int mode, int halt, [In] byte[] snr, [In] byte[] value);
  105. /*Ultralight*/
  106. [DllImport("function.dll")]
  107. public static extern int UL_Request(byte mode, [In] byte[] snr);
  108. [DllImport("function.dll")]
  109. public static extern int UL_HLRead(byte mode, byte blk_add, [In] byte[] snr, [In] byte[] buffer);
  110. [DllImport("function.dll")]
  111. public static extern int UL_HLWrite(byte mode, byte blk_add, [In] byte[] snr, [In] byte[] buffer);
  112. /*ISO14443TypeB*/
  113. [DllImport("function.dll")]
  114. public static extern int TypeB_Request([In] byte[] buffer);
  115. [DllImport("function.dll")]
  116. public static extern int TYPEB_SFZSNR(byte mode, byte halt, [In] byte[] snr, [In] byte[] value);
  117. [DllImport("function.dll")]
  118. public static extern int TypeB_TransCOS([In] byte[] cmd, int cmdSize, [In] byte[] buffer);
  119. /*ISO15693*/
  120. [DllImport("function.dll")]
  121. public static extern int ISO15693_Inventory([In] byte[] Cardnumber, [In] byte[] pBuffer);
  122. /*
  123. 函数功能:此命令通过防冲突用于得到读卡区域内所有卡片的序列号(能得到的卡片数量与模块天线的输出功率有关,一般能对2~6卡进行防冲突)
  124. 输入参数:
  125. Cardnumber 返回的卡的数量(一个字节)
  126. pBuffer 返回的数据(包括FLAG和DSFID和8*n个字节的卡号)
  127. 输出参数:
  128. 如果:操作成功
  129. Cardnumber 返回的卡的数量(一个字节)
  130. pBuffer 返回的数据(包括FLAG和DSFID和8*n个字节的卡号)
  131. 如果:操作失败,则*nrOfCard为错误代码
  132. 返回值:
  133. 0x00,操作成功,
  134. 0x01,操作失败
  135. */
  136. [DllImport("function.dll")]
  137. public static extern int ISO15693_Read(byte flags, byte blk_add, byte num_blk, [In] byte[] uid, [In] byte[] buffer);
  138. /*
  139. 函数功能:
  140. 用来读取1个或多个扇区的值,如果要读每个块的安全位,
  141. 将FLAGS中Option_flag置为1,即FLAG = 0X42,每个扇区将返回5个字节,包括1个表示安全状态字节和4个字节的块内容,这时候每次最多能读12个块。
  142. 如果FLAG = 02,将只返回4字节的块内容,这时候每次最多能读63个块。
  143. 输入参数:
  144. flags 0x02 不带uid
  145. 0x22 带uid
  146. 0x42 不带uid但是要读安全位
  147. blk_add, 要读的起始块号
  148. num_blk, 块的数量
  149. *uid UID信息
  150. *buffer 返回值
  151. 输出参数:
  152. 操作成功,buffer[0] 返回的flag buffer[1..N] Data
  153. 操作失败,buffer[0]为错误代码
  154. 返回值:
  155. 0x00,操作成功,
  156. 0x01,操作失败
  157. */
  158. [DllImport("function.dll")]
  159. public static extern int ISO15693_Write(byte flag, byte blk_add, byte num_blk, [In] byte[] uid, [In] byte[] data);
  160. /*
  161. 函数功能: 对一个块进行写操作(每次只能写一个块)
  162. 输入参数:
  163. flags 0x02 不带uid
  164. 0x22 带uid
  165. 0x42 不带uid但是要读安全位
  166. blk_add, 要写的起始块号
  167. num_blk, 写的块的数量
  168. *uid UID信息
  169. *data 返回值
  170. 输出参数:
  171. 如果:操作失败,则data[0]为错误代码
  172. 返回值:
  173. 0x00,操作成功,
  174. 0x01,操作失败
  175. */
  176. [DllImport("function.dll")]
  177. public static extern int ISO15693_GetSysInfo(byte flag, [In] byte[] uid, [In] byte[] Buffer);
  178. [DllImport("function.dll")]
  179. public static extern int ISO15693_Lock(byte flags, byte num_blk, [In] byte[] uid, [In] byte[] buffer);
  180. [DllImport("function.dll")]
  181. public static extern int ISO15693_Select(byte flags, [In] byte[] uid, [In] byte[] buffer);
  182. [DllImport("function.dll")]
  183. public static extern int ISO15693_WriteAFI(byte flags, byte afi, [In] byte[] uid, [In] byte[] buffer);
  184. [DllImport("function.dll")]
  185. public static extern int ISO15693_LockAFI(byte flags, [In] byte[] uid, [In] byte[] buffer);
  186. [DllImport("function.dll")]
  187. public static extern int ISO15693_WriteDSFID(byte flags, byte DSFID, [In] byte[] uid, [In] byte[] buffer);
  188. [DllImport("function.dll")]
  189. public static extern int ISO15693_LockDSFID(byte flags, [In] byte[] uid, [In] byte[] buffer);
  190. [DllImport("function.dll")]
  191. public static extern int ISO15693_GetMulSecurity(byte flag, byte blkAddr, byte blkNum, [In] byte[] uid, [In] byte[] pBuffer);
  192. }
  193. }