19 #include "sys/select.h" 26 _fd(-1), _device_string(
""), _baudrate(9600)
53 _fd=open(devicestring.c_str(), O_RDWR | O_NONBLOCK);
65 boost::mutex::scoped_lock lock(
_mutex);
68 wrote = write(
_fd, value.c_str(), value.length());
75 boost::mutex::scoped_lock lock(
_mutex);
78 wrote = write(
_fd, data, len);
85 boost::mutex::scoped_lock lock(
_mutex);
89 struct timeval timeout = {0, 100000};
92 if(select(
_fd+1, &fds, NULL, NULL, &timeout))
94 rec = read(
_fd, buffer, nBytes);
95 value = std::string(buffer, rec);
120 std::vector<ioData_t> data;
124 for(
size_t i = 0; i < data.size(); i++)
125 this->
sendData(data[i].buf, data[i].len);
140 std::vector<ioData_t> vec;
167 tcflush(
_fd, TCIOFLUSH);
180 case 0: ret=B0;
break;
181 case 50: ret=B50;
break;
182 case 75: ret=B75;
break;
183 case 110: ret=B110;
break;
184 case 134: ret=B134;
break;
185 case 150: ret=B150;
break;
186 case 200: ret=B200;
break;
187 case 300: ret=B300;
break;
188 case 1200: ret=B1200;
break;
189 case 1800: ret=B1800;
break;
190 case 2400: ret=B2400;
break;
191 case 4800: ret=B4800;
break;
192 case 9600: ret=B9600;
break;
193 case 19200: ret=B19200;
break;
194 case 38400: ret=B38400;
break;
195 case 57600: ret=B57600;
break;
196 case 115200: ret=B115200;
break;
197 case 230400: ret=B230400;
break;
int openPort(std::string devicestring, int baudrate)
void enqueueData(std::vector< ioData_t > data)
static const int maxUpdateRate
ConcurrentQueue< std::vector< struct ioData > > _oQueue
speed_t getBaudFromInt(int baud)
struct termios port_settings
boost::shared_ptr< boost::thread > _thread
int sendData(std::string value)
std::string _device_string
int readData(std::string &value, size_t nBytes)