rfi341_protocol.h
00001
00002
00003
00004
00005
00006
00007 #include <termios.h>
00008 #include <sys/types.h>
00009 #include <libplayercore/playercore.h>
00010
00011 #define BUF_SIZE 1024
00012
00013 #define STX 0x02
00014 #define ETX 0x03
00015 #define ACK 0x06
00016 #define NAK 0x15
00017 #define SYN 0x16
00018 #define ESC 0x18
00019
00021 class rfi341_protocol
00022 {
00023 public:
00024 rfi341_protocol (const char* port_name, int debug_mode);
00025
00026
00027
00028 int Connect (int connect_speed);
00029
00030
00031 int SetupSensor (int transfer_speed);
00032
00033 int Disconnect ();
00034
00035
00036 int SendCommand (const char* cmd);
00037
00038 int ReadResult ();
00039 player_rfid_data_t ReadTags ();
00040
00041 private:
00042
00043 int assemblecommand (unsigned char* command, int len);
00044
00045 int number_of_tags;
00046 char **tags;
00047
00048
00049 struct termios initial_options;
00050
00051
00052 int verbose;
00053 int fd;
00054 const char* port;
00055 int portspeed;
00056
00057
00058 unsigned char buffer[4096];
00059 unsigned int bufferlength;
00060 int checksum;
00061
00062
00063 unsigned char command[BUF_SIZE];
00064 int commandlength;
00065 };