Closed TheRaven500 closed 4 months ago
That's easy enough, but I'd make it a switch, e.g. -l
:
pinctrl -l get $SWITCHPIN
Slight change of plan - it's now pinctrl level $SWITCHPIN
(or pinctrl lev $SWITCHPIN
). Levels for multiple GPIOs are returned separated by spaces.
Ok, you are very fast! :smile: I will try it as soon as possible. But i am sure it will work perfect. Thanks alot for your work. Edit: How can i test it? :thinking:
How can i test it? 🤔
Sorry - GitHub doesn't send notifications for comment edits.
You're going to have to build it yourself, but it is quick and easy (honestly):
utils
directory, and run the following:
git clone -b is82 https://github.com/pelwell/utils.git
cd utils
sudo apt install cmake
cmake .
make
sudo make install
And that should be it.
Because of that i made a "double post" sorry. :wink: Thank you very much, i had to add "libfdt-dev" also for building:
git clone -b is82 https://github.com/pelwell/utils.git
cd utils
sudo apt install cmake libfdt-dev
cmake .
make
sudo make install
Works and looks good! :sunglasses: Two things:
0 1
, something has to treat the first (or last) element specially. I opted for 0 1
to keep it simple , but it could also be 0 1
. Hmmph - I'll give it some thought.I think in most cases you need only one output. As explained in the other discussion, i am searching an alternative to replace sysfs in bash scripts. I do just something like:
if [ "$(pinctrl lev ${GPIOPIN})" = "1" ]; then
So for me it is better to have just "1" and not " 1". But you are the expert and know what is the better option. :smiley:
I can also live with " 1".
BTW: I have replaced sysfs for now with raspi-gpio and this has reduced the cpu load from about 35% down to 3% on a Pi4!
You've acted as the voice of my conscience, and I've now done it right. To download and build the changes, starting in the utils directory:
git fetch origin
git reset --hard origin/is82
make
sudo make install
What has changed? :thinking:
The spaces should only appear between entries - if you aren't seeing this then your update hasn't worked.
Looks like something has not worked. :wink: It is still " 1".
OK - it's going to be hard to figure out what has failed, so we can just delete it all and start again. Running from the utils directory:
cd ..
rm -rf utils
git clone -b is82 https://github.com/pelwell/utils.git
cd utils
cmake .
make
sudo make install
Does it work for you? Because for me not. Still " 1". Strange... :thinking:
I also tried to run it directly from the build path:
/tmp/utils/pinctrl/pinctrl lev 12
OK, with an extended testing regime I did find a bug. And I added the example in the help text.
git fetch origin
git reset --hard origin/is82
make
sudo make install
Now it looks ok (or maybe perfect) :+1: :smiley:
That's merged now.
Ok, i think then it is fixed. Thank you very much for your time and your patience. :+1:
Is it possible to add option to only show 0 or 1 for the status? I work very often with bash scripts and GPIOs. In this scripts i need the level of the GPIO input (0 or 1). ATM i do it like this:
pinctrl get $SWITCHPIN|awk '{print $3}'|grep -o '.\{1\}$'
It works, but it is ugly. :smile: Maybe something like:pinctrl get $SWITCHPIN level
Or "lo" for LevelOnly:pinctrl get $SWITCHPIN lo
But this sounds also a bit like "low".