Is it possible to evaluate parity and space using boost.asio?

I have not seen to set the serial port correctly using the termios structure, so I look at third-party libraries.

I was advised to try boost.asio, but when viewing the examples it seems that it does not support the label and space, is that true?

If possible, someone can show a code example on how to make a character and a space in boost.asio. I use 8 data bits, 115220 baud and 1 stop bit.

Does anyone know of any third-party libraries supporting label and space in linux that I can use instead of boost?

+5
source share
1 answer

.

,

MARK SPACE, , POSIX. Unix/Linux , termios . ( , PARMRK MARK .)

, , Boost.Asio.

: :

8M1 (8 , MARK, 1 ) 8N2. -. 1 ( ), .

, asio as. :

basic_serial_port::native_handle

Get the native serial port representation.

native_handle_type native_handle();
This function may be used to obtain the underlying representation of the serial port. This is intended to allow access to native serial port functionality that is not otherwise provided.

,

boost_1_45_0/boost/asio/serial_port_base.hpp

, , , linux:

switch (value_)
  {
  case none:
    storage.c_iflag |= IGNPAR;
    storage.c_cflag &= ~(PARENB | PARODD);
    break;
  case even:
    storage.c_iflag &= ~(IGNPAR | PARMRK);
    storage.c_iflag |= INPCK;
    storage.c_cflag |= PARENB;
    storage.c_cflag &= ~PARODD;
    break;
  case odd:
    storage.c_iflag &= ~(IGNPAR | PARMRK);
    storage.c_iflag |= INPCK;
    storage.c_cflag |= (PARENB | PARODD);
    break;
  default:
    break;
  }

, native_handle, - :

cflag |= PARENB | CMSPAR // To select SPACE parity
cflag &= ~PARODD

cflag |= PARENB | CMSPAR | PARODD // to select MARK parity

( , ) . libserial

+5

All Articles