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
Have you seen this blog post?
It’s my goto binary pattern matching blog post.
5
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
3
hive
Thanks! That talk is very useful.
1
hive
Nice. Thank you!
1
Popular in Chat/Questions
I’ve bought the following books:
Programming Elixir 1.6
Programming Phoenix 1.4
Programming Ecto
Functional Web Development with Elixir...
New
Hi everyone,
How can i retrieve the name from a structure like this?
%{"id" => "1570", "name" => "Croque Monsieur"}
My test loo...
New
Besides Basic types - The Elixir programming language are there any other well recommended “elixir by example” style resources / books ? ...
New
I love the Phoenix and Elixir docs, but I always tend to learn faster when I watch a video of someone explaining things and then I implem...
New
I’m planning on purchasing Elixir in action second edition, and I was wondering if anyone could tell me based off the first edition, does...
New
I’m coming from Ruby and Rails. I have read some Elixir and Phoenix books. They shed a lot of light about building applications in Elixir...
New
Anybody know of a Pragmatic Studio 40% off coupon code for video course like Phoenix?
New
Hello everyone. So I just got done reading all of the introduction to Elixir and working through the basics of the language. I am not new...
New
Greetings everyone,
At my current workplace we're evaluating different ways of building a microservices architecture for some parts rel...
New
I was wondering if there are any beginner-friendly, exercise-based resources for learning Elixir out there. I’m looking for something lik...
New
Other popular topics
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
New
Hi there,
I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 record...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
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
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New







