elixir-circuits / circuits_uart

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

Program exits when framing is incorrect. #41

Closed acrogenesis closed 6 years ago

acrogenesis commented 6 years ago

If we set the option for framing with \n, framing: {Nerves.UART.Framing.Line, separator: "\n"}, but send no new line we get this error:

** (exit) exited in: GenServer.call(#PID<0.166.0>, {:read, 3000}, 3100)
    ** (EXIT) time out
    (elixir) lib/gen_server.ex:834: GenServer.call/3
    (hello_uart) lib/hello_uart.ex:24: HelloUart.uart_loop/1

The example can be found in: https://github.com/DisruptiveAngels/uart-example/blob/d990251ce6fd4992f91c3fee490253e0f1a8d06d/lib/hello_uart.ex

fhunleth commented 6 years ago

Thanks for the error report and example. What OS and hardware are you using?

acrogenesis commented 6 years ago
macOS 10.13.4
Erlang/OTP 20 [erts-9.3] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:10] [hipe] [kernel-
poll:false]
Elixir (1.6.4)

I think what's happening is that it's waiting for the \n but because it wasn't sent it just timeouts. Perhaps it should just send whats on the buffer or a timeout error.

acrogenesis commented 6 years ago

For testing this we run the example on my Mac and on another pc connected through USB/uart and on the pc we run Arduino to easily send messages without line ending, \n, and \r\n

acrogenesis commented 6 years ago

So I was debugging the error more and noticed I was using the version 1.0.1 when I updated it started working as expected. Submited PR #43

fhunleth commented 6 years ago

Wow, I am so glad this fixed it. I was sure that there was something more to it. Thanks for following up especially with the news that it's already fixed!!