Jim

Jim

Elixir_ale question - do I need an interrupt driven solution?

Hi All…

I started an embedded project last year and got taken off it, and now I need to jump in again. This project, among many other things, needs to talk to a CAN bus. I’m prototyping on a Raspberry Pi 3 B+ and I have a CAN card that interfaces using SPI.

Having read through some posts, there is an implication that elixir_ale is not interrupt driven. I assume that my code would need to poll the SPI controller. In general, does this work, or will I need an interrupt driven solution?

If I do need an interrupt driven solution, I assume that means a kernel driver. Is there one available or would I have to write one?

Thanks very much…

Most Liked

fhunleth

fhunleth

Co-author of Nerves

Elixir is far enough away from hardware that I’m not sure interrupt-driven vs. non-interrupt-driven is going to be the main issue. You can poll GPIOs with elixir_ale or tell elixir_ale to send a message when the GPIO changes. The latter way is “kind of” interrupt-driven since nothing in the system is actively polling the GPIO. There’s a lot of software between the hardware and your Elixir code, so it won’t work as well as you’d expect. I think that it’s passable for event rates under 100 per second.

I’d personally look for a Linux kernel driver for this. Linux kernel drivers just work so much better when dealing with the low-level details of reacting to a GPIO changing and initiating SPI transactions. When the messages are fully received, Elixir makes handling the messages really convenient and is pretty efficient.

Just to add here, there was some work to make a NIF version of elixir_ale. An initial prototype worked really well - it was a couple orders of magnitude faster than elixir_ale. I had been helping someone out on it, but I think they’ve long since lost interest/gotten busy with other things. It would be another option if the kernel driver option won’t work for you and unfinished code doesn’t scare you.

Frank

Last Post!

Jim

Jim

Thanks Frank, I think you’re right, a device driver is the way to go. I have written serial drivers in the past, I suppose an SPI driver would work about the same way. I suspect there is one available, I’ll hunt around. Seems a common enough need.

Where Next?

Popular in Questions Top

vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
ashish173
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
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
pmjoe
I have a relationship of love and hate with Elixir. Lots of things are just absolutely right, but there are some things that are kind of ...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54260 488
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 49266 226
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
jason.o
In the code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New

We're in Beta

About us Mission Statement