rfi341_protocol.h

00001 /*
00002  Desc: Driver for the SICK RFI341 unit
00003  Author: Nico Blodow and Radu Bogdan Rusu
00004  Date: 9 Mar 2007
00005  CVS: $Id: rfi341_protocol.h 6499 2008-06-10 01:13:51Z thjc $
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     // Creates socket, connects
00027     // Connects first at 'connect_speed'
00028     int Connect (int connect_speed);
00029 
00030     // but for transfer, we might want to use a different 'transfer_speed'
00031     int SetupSensor (int transfer_speed);
00032 
00033     int Disconnect ();
00034 
00035     // assembles a command and sends it on the wire
00036     int SendCommand (const char* cmd);
00037     // reads the result of a query from the device
00038     int ReadResult  ();
00039     player_rfid_data_t ReadTags ();
00040 
00041   private:
00042     // assembles STX's, message, checksum ready to be sent. Cool.
00043     int assemblecommand (unsigned char* command, int len);
00044 
00045     int number_of_tags;
00046     char **tags;
00047 
00048     // Initial serial port attributes
00049     struct termios initial_options;
00050 
00051     // Internal Parameters:
00052     int verbose;
00053     int fd;
00054     const char* port;
00055     int portspeed;
00056 
00057     // for reading:
00058     unsigned char buffer[4096];
00059     unsigned int bufferlength;
00060     int checksum;
00061 
00062     // for sending:
00063     unsigned char command[BUF_SIZE];
00064     int commandlength;
00065 };

Last updated 12 September 2005 21:38:45