Module_RFID.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /*
  2. * Module_RFID.h
  3. *
  4. * Created on: 2019¦~10¤ë24¤é
  5. * Author: Eason Yang
  6. */
  7. #ifndef LIB_RFID_H_
  8. #define LIB_RFID_H_
  9. #include <sys/time.h>
  10. #include <sys/timeb.h>
  11. #include <sys/types.h>
  12. #include <sys/stat.h>
  13. #include <sys/types.h>
  14. #include <sys/ioctl.h>
  15. #include <sys/socket.h>
  16. #include <sys/ipc.h>
  17. #include <sys/shm.h>
  18. #include <sys/shm.h>
  19. #include <sys/mman.h>
  20. #include <linux/wireless.h>
  21. #include <arpa/inet.h>
  22. #include <netinet/in.h>
  23. #include <unistd.h>
  24. #include <stdarg.h>
  25. #include <stdio.h> /* Standard input/output definitions */
  26. #include <stdlib.h>
  27. #include <unistd.h> /* UNIX standard function definitions */
  28. #include <fcntl.h> /* File control definitions */
  29. #include <termios.h> /* POSIX terminal control definitions */
  30. #include <errno.h> /* Error number definitions */
  31. #include <string.h> /* String function definitions */
  32. #include <time.h>
  33. #include <ctype.h>
  34. #include <ifaddrs.h>
  35. #include <stdbool.h>
  36. typedef struct Rfid
  37. {
  38. uint8_t snType; // 4 bytes or 6 bytes or 7 bytes or 10 bytes
  39. uint8_t cardType; // 0: NONE 1: ISO14443A 2: ISO14443B 4: FELICA
  40. uint8_t currentCard[32]; // Current charging cycle start card number
  41. uint8_t targetBlock; // RFID read/write target block
  42. uint8_t keyType; // 0: Key-A 1: Key-B
  43. uint8_t data_Block[32]; // RFID operation block data
  44. }RFID;
  45. //==================================
  46. // Card Length
  47. //==================================
  48. #define RFID_SN_TYPE_4BYTE 4
  49. #define RFID_SN_TYPE_6BYTE 6
  50. #define RFID_SN_TYPE_7BYTE 7
  51. #define RFID_SN_TYPE_10BYTE 10
  52. //==================================
  53. // Card Type
  54. //==================================
  55. #define NONE 0
  56. #define ISO14443A 1
  57. #define IS014443B 2
  58. #define FELICA 3
  59. char ClaCheckSum(unsigned char *buffer, int len);
  60. int system_command(int uart, unsigned char* cmd,int length, unsigned char* rx);
  61. bool getRequestCardSN(int Fd, int moduleType,RFID *rfid);
  62. bool ISO14443A_REQUEST_SN(int Fd, int moduleType, unsigned char *serialNumber);
  63. bool ISO14443B_REQUEST_SN(int Fd, int moduleType, unsigned char *serialNumber);
  64. bool FELICA_REQUEST_SN(int Fd, int moduleType, unsigned char *serialNumber);
  65. bool getBlockRead(int Fd, int moduleType,int block, unsigned char keyid, unsigned char *data);
  66. bool setBlockWrite(int Fd, int moduleType,int block, unsigned char keyid, unsigned char *data);
  67. void setBuzzer(int Fd, int moduleType, unsigned char time);
  68. void sethaltCard(int Fd, int moduleType);
  69. #endif