[Rock-dev] non standard serial settings with iodrivers_base

Leif Christensen leif.christensen at dfki.de
Wed Oct 30 14:47:47 CET 2013


Hi,

I have a sensor which needs 8-oddparity-1 (don't ask) serial settings.
If I see this correctly, iodrivers_base always assumes standard 8-N-1
settings in openSerialIO.

I'm helping myself by getting fd after the call to openURI in my
open-method, and tweaking the termios flags there:

> void Driver::open(std::string const& uri){
>   openURI(uri);
>   int fd = getFileDescriptor();
>  
>   iodrivers_base::FileGuard guard(fd);
> 
>   struct termios tio;
>   tcgetattr(fd,&tio);
>   tio.c_cflag |= (PARENB | PARODD | CS8); // odd parity, 8 data bits
>   tio.c_iflag |= (INPCK | IGNPAR); // parity checks, drop false bytes
>   tio.c_iflag &= ~PARMRK; // don't mark wrong parity bytes
> 
>   if (tcsetattr(fd, TCSANOW, &tio)!=0)
>     throw iodrivers_base::UnixError("Driver::openSerial cannot set serial options");
> 
>   guard.release();
> }

a) are there possible pitfalls in doing so?

b) is there a standard way of setting termios flags in iodrivers_base?

c) Why are breaks ignored by default (IGNBRK, which is different to raw
settings from e.g. cfmakeraw())

LG,
Leif
-- 
 Leif Christensen

 DFKI Bremen
 Robotics Innovation Center
 Robert-Hooke-Straße 5
 28359 Bremen, Germany

 Phone: +49 (0)421 17845-4149
 Fax:   +49 (0)421 17845-4150
 E-Mail: leif.christensen at dfki.de

 Weitere Informationen: http://www.dfki.de/robotik
 -----------------------------------------------------------------------
 Deutsches Forschungszentrum fuer Kuenstliche Intelligenz GmbH
 Firmensitz: Trippstadter Straße 122, D-67663 Kaiserslautern
 Geschaeftsfuehrung: Prof. Dr. Dr. h.c. mult. Wolfgang Wahlster
 (Vorsitzender) Dr. Walter Olthoff
 Vorsitzender des Aufsichtsrats: Prof. Dr. h.c. Hans A. Aukes
 Amtsgericht Kaiserslautern, HRB 2313
 Sitz der Gesellschaft: Kaiserslautern (HRB 2313)
 USt-Id.Nr.:    DE 148646973
 Steuernummer:  19/673/0060/3
 -----------------------------------------------------------------------



More information about the Rock-dev mailing list