VSpeeds::VSpeeds(const char * in_spd) { std::vector<std::string> spds; boost::algorithm::split(spds, in_spd, boost::is_any_of("/")); if (spds.size() == 3) { (*this) = VSpeeds(speed_t(spds[0]), speed_t(spds[1]), speed_t(spds[2])); } else if (spds.size() == 5) { (*this) = VSpeeds(speed_t(spds[2]), speed_t(spds[3]), speed_t(spds[4]), speed_t(spds[1]), speed_t(spds[0])); } }
VSpeeds & VSpeeds::operator = (const wchar_t * in_spd) { std::vector<std::wstring> spds; boost::algorithm::split(spds, in_spd, boost::is_any_of(L"/")); if (spds.size() == 3) { (*this) = VSpeeds(speed_t(spds[0]), speed_t(spds[1]), speed_t(spds[2])); } else if (spds.size() == 5) { (*this) = VSpeeds( speed_t(spds[2]), speed_t(spds[3]), speed_t(spds[4]), speed_t(spds[1]), speed_t(spds[0])); } return (*this); }
void SerialPort::setSerialSettings(int bitRate,int charLength,SerialPort::ParitySettings parity,int numStopbits,bool enableHandshake) { /* Initialize a termios structure: */ struct termios term; tcgetattr(port,&term); /* Set rate of bits per second: */ #ifdef __SGI_IRIX__ term.c_ospeed=bitRate; term.c_ispeed=bitRate; #else /* Find the closest existing bitrate to the given one: */ static speed_t bitRates[][2]={{0,B0},{50,B50},{75,B75},{110,B110},{134,B134},{150,B150}, {200,B200},{300,B300},{600,B600},{1200,B1200},{1800,B1800}, {2400,B2400},{4800,B4800},{9600,B9600},{19200,B19200}, {38400,B38400},{57600,B57600},{115200,B115200},{230400,B230400}}; int l=0; int r=19; while(r-l>1) { int m=(l+r)>>1; if(speed_t(bitRate)>=bitRates[m][0]) l=m; else r=m; } cfsetospeed(&term,bitRates[l][1]); #endif /* Set character size: */ term.c_cflag&=~CSIZE; switch(charLength) { case 5: term.c_cflag|=CS5; break; case 6: term.c_cflag|=CS6; break; case 7: term.c_cflag|=CS7; break; case 8: term.c_cflag|=CS8; break; } /* Set parity settings: */ switch(parity) { case PARITY_ODD: term.c_cflag|=PARENB|PARODD; break; case PARITY_EVEN: term.c_cflag|=PARENB; break; default: ; } /* Set stop bit settings: */ if(numStopbits==2) term.c_cflag|=CSTOPB; /* Set handshake settings: */ if(enableHandshake) { #ifdef __SGI_IRIX__ term.c_cflag|=CNEW_RTSCTS; #else term.c_cflag|=CRTSCTS; #endif } /* Set the port: */ tcsetattr(port,TCSADRAIN,&term); }
bool speed_t::operator < (int in_spd) const { return (*this) < speed_t(in_spd); }
bool speed_t::operator != (int in_spd) const { return (*this) != speed_t(in_spd); }