n0gg1n
Hey everyone!
I just want to simulate an uart device on the host pc to test my code locally.
I’m using tty0tty to simulate the uart interface.
My code so far:
defmodule UartSimulator do
use GenServer
@path_tty0tty "/bin/tty0tty"
def start_link() do
{:ok, pid} = GenServer.start_link(__MODULE__, %{})
end
def init(state) do
tty0tty = Port.open({:spawn, path_tty0tty}, [:binary])
port = File.open!("/dev/pts/2", [:write])
{:ok, %{state | tty0tty: tty0tty, port: port}}
end
def handle_cast({:data_reporting_mode, mode, activity}, %{port: port} = state) do
IO.binwrite(port, "hello world")
{:noreply, state}
end
end
Is this the way to go?
And how can I implement this module in my testing environment? I’m getting the error that the module is not available.
Trending in Questions
I’m aware of 2 such projects, are there others?
git: GitHub - team-alembic/realworld: A fullstack Phoenix LiveView application with back...
New
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hi everyone.
My team and I have been working on a fairly modest app based around video streaming and chat, but we’ve landed a customer t...
New
I really like the adapter patterns that ecto, nebulex, waffle, etc. use and would love find something similar for a key management servic...
New
Hello folks!
So at work, we are seeing some situations where we have to define some “fixed” strings that are used across the codebase in...
New
How Can I Optimise Compile Time Dependencies
I have been building an elixir application for about 2 years now. Many modules and files ha...
New
Other Trending Topics
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
I fully migrated to my own harness from Anthropic/Gemini and I think it’s time to share it. Welcome DSH, the DeepSeek Harness, fully writ...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
There has been a thread to discuss the Stack Overflow Developer Survey on this forum every year since 2018, so here’s yet another one for...
New
I love Elixir. It’s one of 2 programming languages I’ve ever fallen in love with.
But I don’t use it anymore.
Serverless was the promis...
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
- #ai
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixirconf-us
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #security
- #metaprogramming











Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
fhunleth
Hi @n0gg1n,
I use
tty0ttyto test circuits_uart on CI. I start it outside of Elixir, though, since it requires super user privileges to load its special Linux kernel module. After it’s loaded, you should notice new serial ports on your machine calledtnt0,tnt1, etc. They’re connected in pairs. Whatever you send outtnt0comes intnt1and vice versa.I have some docs at GitHub - elixir-circuits/circuits_uart: Discover and use UARTs and serial ports in Elixir · GitHub that might also be helpful.
n0gg1n
Hey @fhunleth,
thanks for your answer! I just wanted to temporary open an uart emulation port with the tty0tty pts program. Unfortunately it didn’t work out the way I wanted. I’m now using the kernel module and it works.
Thanks for your great work!