Set low_latency flag to serial port on windows in C ++

I have a program that opens a serial port using boost asio.

The serial port defaults to a delay that supports idle lines. On Windows platforms, I saw a delay of 30 ms, and on Linux platforms, the delay was 20 ms.

On Linux, I found that the ioctl class from linux.h has a way to set sequential settings using some flags (and what I need: low_latency).

The code is as follows:

boost::asio::basic_serial_port<boost::asio::serial_port_service>::native_type native = serial_port_.native(); // serial_port_ is the boost serial port class.
struct serial_struct serial;
ioctl(native, TIOCGSERIAL, &serial);
serial.flags |= ASYNC_LOW_LATENCY; // (0x2000)
ioctl(native, TIOCSSERIAL, &serial);

I want to reduce latency on my windows platform. Is there an equivalent way that does the same for Windows with C ++?

By the way, I saw that there are some solutions that offer changing the serial port properties in the Windows device manager, but I do not have these properties, as these solutions showed, and I need a solution for the code.

+3
source share
2 answers

Take the built-in descriptor that you get from boost asio in windows and pass it to SetCommTimeouts: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363437(v=vs.85).aspx

In particular, look at the ReadIntervalTimeout structure of the COMMTIMEOUT structure: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363190(v=vs.85).aspx

ReadIntervalTimeout , . ReadFile , . , ReadFile . , - . MAXDWORD, ReadTotalTimeoutConstant ReadTotalTimeoutMultiplier, , , .

GetCommTimeouts: http://msdn.microsoft.com/en-us/library/windows/desktop/aa363261(v=vs.85).aspx

+1

NT4/Win2k/WinXP, , , , .

COMMTIMEOUT , , 10 16 , , SMP- . , - 1 . COMMTIMEOUT .

, IO Completion Ports . , , IOCP. .

boost:: asio, . Windows IOCP Windows asio, IOCP .

0

All Articles