circuits_uart
circuits_uart copied to clipboard
Add find_pid/1
This is an idea for minor enhancement.
I thought it would be nice to have a function to find pid by port name since we most likely know which port we are using. We can achieve it just by doing pattern-matching against the result of find_pids/0
. What do you think?
It is nice to have but after all I did not use it in my project because I realized I could avoid starting twice for the same port at the higher layer using Registry
.
Since I intended find_pids/0
as a debug tool, I think that it can be changed or extended as needed to make life easier when debugging. I was just about to say that find_pid/1
would be fine to add, but then you said that you ended up not using it. Maybe we hold off with it for now.
As a debugging tool find_pid/1
should be OK, but yeah maybe we can wait until somebody else finds it necessary.
I personally decided not to use it in my code because I got confused when I used Circuits.UART
(active mode) in a GenServer
. I was able to avoid the :eagain
error using existing find_pids/0
but then that GenServer
stopped receiving the message from the UART. Maybe I did something wrong but after all, registering my processes in my own registry was easier for me in understanding what is going on.
P.S. Maybe the issue I had above was merely because the UART process does not know about my new GenServer
process 🤔