elixir-circuits / circuits_uart

Discover and use UARTs and serial ports in Elixir
Apache License 2.0
189 stars 48 forks source link

Windows spurious EV_RXCHAR #34

Closed TypedLambda closed 6 years ago

TypedLambda commented 6 years ago

I get the spurious EV_RXCHAR event under windows, after which the Uart interface stops recieving any mode data.

https://github.com/nerves-project/nerves_uart/blob/501836d9814b730420df96cc563d20434139e09d/src/uart_comm_win.c#L746

i fixed it by calling start_async_reads(port) again to continue polling. seems to work, but I'm not a windows expert ;-)

Windows seems to occasionaly set this flag...

Starting async read
WaitCommEvent returned asynchronously
uart_add_wfmo_handles
  adding write handle
  adding read handle (active mode)
Calling WFMO count=3
WFMO returned 1
uart_process_handle: write event
Back from write 1, 997
uart_add_wfmo_handles
  adding read handle (active mode)
Calling WFMO count=2
WFMO returned 1
uart_process_handle: event event
Got an events event: 1 0 4!!
spurious EV_RXCHAR
uart_add_wfmo_handles
  adding read handle (active mode)
Calling WFMO count=2
WFMO returned 0
Going to write 37 bytes
WriteFile asynchronous completion
uart_add_wfmo_handles
  adding write handle
  adding read handle (active mode)
Calling WFMO count=3
WFMO returned 1
uart_process_handle: write event
Back from write 1, 997
uart_add_wfmo_handles
  adding read handle (active mode)
Calling WFMO count=2
fhunleth commented 6 years ago

Fixed in e2be5d3c1e13842f03b178d73520d4e9588f5aa9