chriskohlhoff / asio

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

Serial port functions not working in windows #1451

Open alexbernardino opened 8 months ago

alexbernardino commented 8 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 8 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).