pojiro
I think this is the basic question. I don’t know the I2C protocol details.
I would like to know the linux case.
Do we need to write the atomic operation for i2c bus in Elixir?
Or if we just use cicuits_i2c, it is done by the library or Linux driver?
Thank you
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 4- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
fhunleth
I might need more information on what you’re trying to achieve.
Linux schedules messages to devices in the order that they’re requested. If multiple OS or Erlang processes send messages on an I2C bus, they’ll be interleaved. Circuits.I2C directly uses the Linux APIs so it behaves identically.
There’s a way tell Linux to make more than one I2C bus transaction at a time using the
I2C_RDWRioctl. TheCircuits.I2C.write_read/5function uses this ioctl. The main reason is to do an I2C repeated start which is often expected by I2C devices. It also ensures that the write and read operations are issued back-to-back.The
I2C_RDWRlets you string together more I2C bus operations and this might be what you’re looking for with your question.A PR that adds a
Circuits.I2C.transfer/4that takes a list of I2C operations would be interesting. But before going down that route, it would be good to confirm that this is the right thing to do. Every time I’ve thought I’ve needed to implement this, I’ve found that making multipleCircuits.I2Ccalls is sufficient. Also take a look at the error semantics as described ini2c-core-base.c.Hope this helps.
pojiro
I don’t do achieve something and don’t have any problems.
I just want to know that the parallel accessing the same bus is safe or not.
For example, there are two GenServers, each of them are open same i2c bus, like “i2c-1”, and store the handle to their state. Then both of them write or read the bus with the hundle in parallel.
The bus hundle, reference, includes the file discripter, right?.
I’d like to know that the same timing access to it is safe or not. Does a Linux I2C driver garantee the atomicity?
fhunleth
You can open as many I2C bus references as you’d like. There won’t be any issues. It’s common to call
Circuits.I2C.open/2for each I2C device that you’re using from Elixir. What you’re describing with two GenServers is the normal way, and that’s how most Elixir libraries that use I2C are written.Trying to pass around I2C bus references to reduce calls to
Circuits.I2C.open/2is unnecessary. I probably would only do that if it were really convenient.The Linux kernel ensures that each read and write completes before the next transfer starts. The low level I2C hardware controller can only issue one at a time anyway.
Yes, there’s a file handle behind each I2C bus reference.
pojiro
I appreciate your answer!!
Thank you