|
|
|
|
|
by elcritch
2459 days ago
|
|
Drop by the Nerves channel on the Elixir-Lang Slack. It’s pretty active and people are pretty helpful. PS: I enjoy writing streaming code in Elixir (vs more procedural or OO methods). This is a snippet I use to decode a SLIP encoded binary UART stream with an CRC check: Stream.repeatedly(fn -> receive_data_packet(timeout) end)
|> Stream.transform(<<@frame_end, @frame_end>>, &frame_splitter(&1, &2, {separator, max_buffer}))
|> Stream.map(&decode_slip(&1))
|> Stream.map(&frame_header(&1))
|> Stream.reject(&( &1[:code] == -1))
|> Stream.each(fn x -> if !x[:crc_check] do Logger.error("parser crc error: #{inspect x}") end end)
|> Stream.reject(&( &1[:crc_check] == false))
...
|
|