hive
Wanted: Tutorial on Pattern Matching to parse a binary protocol
Hi Folks,
Does anyone have a good pointer to a guide or tutorial on pattern matching to parse a binary protocol? I’m trying to monitor a serial protocol using Circuits.UART.
Here is an example of the protocol I’m trying to parse: Infinity Framing Protocol · nebulous/infinitude Wiki · GitHub
Thanks!
Most Liked
axelson
Scenic Core Team
hauleth
In this case parsing these messages is ultra easy:
def parse(<<destination_address,
destination_bus,
source_address,
source_bus,
length,
pid,
ext,
function,
data::binary-size(length),
checksum::32>>
) do
if valid_checksum?(<<destination_address,
destination_bus,
source_address,
source_bus,
length,
pid,
ext,
function,
data::binary>>) do
{:ok, %{
destination_address: destination_address,
destination_bus: destination_bus,
source_address: source_address,
source_bus: source_bus,
pid: pid,
ext: ext,
function: function,
data: data
}}
else
{:error, :invalid_checksum}
end
end
Unfortunately, the spec didn’t specified which CRC16 they meant so I cannot provide that one.
4
tomkonidas
Last Post!
hive
Popular in Chat/Questions
Hi all,
I am currently on this course
https://www.ludu.co/course/discover-elixir-phoenix
Half a way thru, and struggled a bit.. someti...
New
Hi all,
I am a Fullstack JS developer for last 2 years. I need a good guide to learn elixer. Any suggestions please
New
The title of this topic may sound silly at the first glance. But why I trying to ask you guys is how to go to the next level?
I am curre...
New
Besides https://elixir-lang.org/getting-started/basic-types.html are there any other well recommended “elixir by example” style resources...
New
I want to learn DSL. Don’t know how to write one. What;s the best introductory resource?
I see some macro being used here.
Is DSL only ...
New
Hello all,
I recently did my first app in Phoenix and Liveview, many thanks to all the users who assisted me. I found that the tutorial ...
New
Hello, I want to get started with elixir today. Having learnt the basics of Erlang (my first ever language) and seen what it’s can do, I’...
New
Other popular topics
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hi All,
I set a environment variables in dev.exs , like below code.
when i start server, how can i set the ${enable} value?
thanks.
d...
New
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
After calling mix ecto.create I get this error:
17:00:32.162 [error] GenServer #PID<0.412.0> terminating
** (Postgrex.Error) FATAL...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #forms
- #api
- #metaprogramming
- #security
- #hex









