Go to the documentation of this file.00001
00041 #ifndef SERIAL_H_
00042 #define SERIAL_H_
00043
00044 #include <stdint.h>
00045 #include <stdio.h>
00046
00047 #include <stdio.h>
00048 #include <string.h>
00049 #include <unistd.h>
00050 #include <fcntl.h>
00051 #include <errno.h>
00052 #include <termios.h>
00053 #include <stdlib.h>
00054 #include <assert.h>
00055
00056 namespace sawyer{
00057 class base_data{
00058 public:
00059
00060 static const size_t MAX_MSG_LENGTH = 256;
00061 struct RawData{
00062 unsigned char data[MAX_MSG_LENGTH];
00063 int length;
00064 RawData():
00065 data(),length(0)
00066 { memset(data, 0xba, base_data::MAX_MSG_LENGTH);}
00067 }rawData;
00068 void clear(){memset(rawData.data, 0xba, MAX_MSG_LENGTH);rawData.length=0;}
00069 };
00070 class roch_driver: public base_data{
00071
00072 public:
00073
00078 roch_driver &instance()
00079 {
00080 static roch_driver instance;
00081 return instance;
00082 }
00083 int OpenSerial(void **handle, const char *port_name);
00084
00085 int SetupSerial(void *handle);
00086
00087 int WriteData(void *handle, const char *buffer, int length);
00088
00089 int ReadData(void *handle, char *buffer, int length);
00090
00091 int CloseSerial(void *handle);
00092 base_data::RawData getGpInputData() const {
00093 return rawData_.rawData; }
00094 base_data rawData_;
00095
00096 };
00097 };
00098 #endif