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

New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
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
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

Other popular topics Top

Qqwy
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
sen
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
gausby
I asked this very same question on twitter and got some interesting feedback, but I thought it would be a good question to ask here as we...
1207 40165 209
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44265 214
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement