rs232.h
Go to the documentation of this file.
00001 #ifndef __RS232_H__
00002 #define __RS232_H__
00003 
00032 #include <sys/ioctl.h>
00033 #include <sys/time.h>
00034 #include <ros/ros.h>
00035 #ifdef APPLE
00036 #include ETC_DIR "/drivers/termios/termios.h"
00037 #else
00038 #include <termios.h>
00039 #endif
00040 
00041 #include "../ipc/semaphores.h"
00042 #include "../common_errors.h"
00043 
00045 #define DEFAULT_BAUDRATE 19200
00046 
00047 #define SP_READ_TIMEOUT 2000
00048 
00049 #define SPLT_READ_TIMEOUT 10000
00050 
00051 #define SP_MSG_SIZE 64
00052 
00053 #define SP_MAX_FILENAME_SIZE 64
00054 
00055 class Rs232 {
00056     public:
00071         int initCommunication(int baudrate, char *serialDevice, char *semFile);
00072 
00076         int endCommunication();
00077 
00078         /* Read and Write from/to the Serial Port functions */
00079 
00090         int writeToRS232(char *command, int commandSize);
00091 
00102         int readFromRS232(char * buff);
00103 
00123         int askToRS232(char *command, int commandsize, char *response);
00124 
00125         // Functions added by David GarcĂ­a to use with protocol not ended with "CRLF"
00126 
00139         int readSerial(char *response, int responseSize);
00140 
00162         int askToSerial(char *command, int commandSize, char *response, int responseSize);
00163 
00170         long int timeDifferenceMsec(struct timeval *before, struct timeval *after);
00171 
00172     private:
00173         // RSd file descriptor of the serial port
00174         // semID semaphore identifier
00175         int _RSd, _semID;
00176 };
00177 
00178 #endif


sr_communications
Author(s): Raul Perula-Martinez , Victor Gonzalez
autogenerated on Wed Aug 26 2015 16:26:47