chriskohlhoff / asio

Asio C++ Library
http://think-async.com/Asio
4.72k stars 1.19k forks source link

Serial port functions not working in windows #1451

Open alexbernardino opened 3 months ago

alexbernardino commented 3 months ago

Boost asio 1.84.0 serial port read functions are not working in windows. The runtime blocks in line 438 of win_iocp_iocontext.ipp : BOOL ok = ::GetQueuedCompletionStatus(iocp.handle, &bytes_transferred, &completion_key, &overlapped, msec < gqcstimeout ? msec : gqcstimeout);

alexbernardino commented 3 months ago

Managed to make it work by explicitly initializing flow_control after opening the port: sp.set_option(serial_port_base::flow_control{}, ec);

On contrary to linux and mac, in windows in seems necessary to do this explicit initialization, no matter what option is used in flow control (hardware, software, none).