View Source Circuits.UART.Framing.Line (circuits_uart v1.5.3)
Each message is one line. This framer appends and removes newline sequences as part of the framing. Buffering is performed internally, so users can get the complete messages under normal circumstances. Attention should be paid to the following:
- Lines must have a fixed max length so that a misbehaving sender can't
cause unbounded buffer expansion. When the max length is passed, a
{:partial, data}
is reported. The application can decide what to do with this. - The separation character varies depending on the target device. See "Separator" section to see how to specify this.
- It may be desirable to set a
:rx_framing_timeout
to prevent characters received in error from collecting during idle times. When the receive timer expires,{:partial, data}
is reported. - Line separators must be ASCII characters (0-127) or be valid UTF-8 sequences. If the device only sends ASCII, high characters (128-255) should work as well. [Note: please report if using extended characters.]
Separator
Some devices require "\r\n"
sequences. If you are using one of these
devices, a LTE modem for example, you can specify the separator like so:
Circuits.UART.open(uart, tty_name, framing: {Circuits.UART.Framing.Line, separator: "\r\n"})
By default the separator is "\n"
. Currently only one or two character
separators are supported.
Summary
Functions
Callback implementation for Circuits.UART.Framing.add_framing/2
.
Callback implementation for Circuits.UART.Framing.flush/2
.
Callback implementation for Circuits.UART.Framing.frame_timeout/1
.
Callback implementation for Circuits.UART.Framing.init/1
.
Callback implementation for Circuits.UART.Framing.remove_framing/2
.
Functions
Callback implementation for Circuits.UART.Framing.add_framing/2
.
Callback implementation for Circuits.UART.Framing.flush/2
.
Callback implementation for Circuits.UART.Framing.frame_timeout/1
.
Callback implementation for Circuits.UART.Framing.init/1
.
Callback implementation for Circuits.UART.Framing.remove_framing/2
.