One button connect script using GPIO Pins

Does anyone have an actual script that uses the GPIO pins to connect and disconnect a node. I have searched the archives and found where a generic script was referenced that could be modified. Unfortunately, I don’t have the skill sets to be able to do that yet, Someone has to have done that who is willing to share. Anything would be appreciated…

Thanks,
Rich, WA2ZPX.
Node 511720

Can you share the generic script reference you found in the archives? Perhaps one of us can put something together.

I always thought this needed to be handled via Python or something higher level in the background, for the GPIO state monitoring and action sequences, but I’ve never tried to put it together.

Byron

Hi Byron,

Thanks for the response… It was not much. It just pointed to the sample scripts in the /usr/local/sbin/example_scripts directory.

Regards,

Rich

The best way to run something from the gpio of the raspberry pi would be to do something like this.

create a Python script that monitor the gpio pin you want to use. A good exemple how to play with the gpio is here:

https://www.raspberrypi.org/documentation/usage/gpio/python/README.md

When you master the python part of reading the i/o state, you call the bash script that you want.

a good exemple on how to call a bash script from within python is here.

I know I am not giving you the fish, but I think you have the fishing rod and the bait. You need to learn how to use both togheter to catch as many fish you want.

What do you mean by using the GPIO pins to connect or disconnect the node?
There are lot of ways to go about controlling connections…maybe it’s me, but I’m missing something here. Could you be a bit more descriptive (ie describe your use case?) and maybe there’s another way that is easier using no hardware just from a programmatic standpoint.

That can be handled very easily via ilink commands from a bash shell you call from allstar; using a side script and the event subsystem could give you the equivalent.

More info surrounding what you’re trying to accomplish (and why) might help us flesh it out for you.

Bryan wb0yle/w2fuv
Morrisville PA
Fall River MA

Bryan,

I’m building radioless node. I want to be able to push a button on the front panel and get the node to connect to a node, and another button to disconnect… Put a number of buttons on the front panel to connect to a number of nodes.

1 Like

Thanks Pierre, I’ll take a look…

From the last answer you gave to Bryan I understood that what you want to do is kind of having memories of nodes to connect to. Surely to talk on different repeaters or repeaters networks.
Nice idea.
you should look into moving that idea to a “VFO” setting. taking that analogy of a set of “fix” memory or channel, and having a rotary encoder to flow trough the whole band frequency with the turn of a button.

You already have the list of all the active nodes into the raspberry pi. You even have the information available from the stats server of each individual nodes, its name, location…

Now if you use a rotary encoder and a single switch or two, you could display on a small screen part of the data from the stats server or from the node list and with the turn of the encoder select it with a push of the rotary switch. then you call the script to “change” the channel to the node you are pointing on the screen.

making this project a lot more versatile.
there are small 2.8 inch oled screen you can use that are really cheap.
or you can go even more grandiose with the use of a color touch screen like on this project.
https://maker.pro/raspberry-pi/tutorial/how-to-add-an-lcd-touchscreen-to-raspberry-pi

Have fun, keep us posted.

Pierre
VE2PF

···

Le mar. 26 mai 2020 à 21:55, Rich Ball via AllStarLink Discussion Groups <noreply@community.allstarlink.org> a écrit :

| richball
May 27 |

  • | - |

Thanks Pierre, I’ll take a look…


Visit Topic or reply to this email to respond.


In Reply To

| Pierre_Martel
May 26 |

  • | - |

The best way to run something from the gpio of the raspberry pi would be to do something like this. create a Python script that monitor the gpio pin you want to use. A good exemple how to play with the gpio is here: https://www.raspberrypi.org/documentation/usage/gpio/python/README.md When you ma…


Visit Topic or reply to this email to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, click here.

Pierre,

Novel idea…! But I think for right now, I need to walk before I run… Plus… anymore and my head will explode…

Stay safe,

Rich, WA2ZPX

Ahhh…I see what you’re looking to do. You just want one or a sequence of buttons. Nice. But, I’m going to make the suggestion here that you use the DTMF decoding functionality in Allstar to accomplish the same thing a lot quicker AND a bit more flexibly.

Less hardware. Just what you have in place now (well, maybe you need a DTMF mic, but that’s a different story…)

So…in your /etc/asterisk/rpt.conf file, there is a stanza called [functions] that calls out the sequences that, once decoded, can Do Stuff. A lot of stuff.

If you look there, you’ll see that (logically, based on experience…we’ve sorted these things out over time), the prefaces have been allocated as:

; Prefix Functions
; *1 Disconnect Link
; *2 Monitor Link
; *3 Connect Link
; *4 Command Mode
; *5 Macros
; *6 User Functions
; *7 Connection Status/Functions
; *8 User Functions
; *9 User Functions
; *0 User Functions

; *A User Functions
; *B User Functions
; *C User Functions
; *D User Functions

which means that we can build command sequences based on the prefix and suffix (to minimal uniqueness, ie a command *80 will be executed in preference to *801 since the match will be the first two and the command processor will go off when a minimal match occurs…) to do what we want.

Second thing is that we can build commands by specifying a command string that calls a bash (or python, or perl, or ?) script that ‘does stuff’.

For instance, I have a function defined as:

981=cmd,/etc/asterisk/scripts/27200up.sh

where 981 is the dtmf sequence (preceeded by a *) followed by a comma
cmd tells asterisk that it’s going to execute something followed by a comma
and /etc/asterisk/scripts/27200up.sh is the shell script that it’s going to run.

That script is a simple, 2 line script in my /etc/asterisk/scripts directory (which I created to hold Stuff):

#!/bin/bash
/usr/sbin/asterisk -rx “rpt cmd xxxxx ilink 3 27200”

to connect me to my friend’s hub.

So, just for instance…let’s create a ‘stack’ of DTMF functions:

x01 =cmd,/etc/asterisk/scripts/node1up.sh
x02 =cmd,/etc/asterisk/scripts/node2up.sh
x03 =cmd,/etc/asterisk/scripts/node3up.sh
x04 =cmd,/etc/asterisk/scripts/node4up.sh

Where a generic nodeXup.sh (replace X with whatever) looks like this in your local scripts directory:

#!/bin/bash

first, disconnect all existing links; will just error out if nothing there

/usr/sbin/asterisk -rx “rpt rpt cmd (your local node) ilink 6”

wait for it to settle down…

sleep 5

now, link to wherever.

/usr/sbin/asterisk -rx “rpt cmd (your local node #) ilink 3 (nodeX allstar extension)”

So, when you restart asterisk…you now have 4 (or however many…) nodes loaded.

Key your mic, replace the x above with your prefix, to make, say 801. You key in *801# into your dtmf mic, and allstar will drop whatever connection you have (if any), sleep for 5 seconds, then connect to the node you programmed in as node 1.

This is, believe it or not, about an hour’s worth of keyboard time…the first half hour to debug, the second to build the stack of commands, copy the files, edit to suit, and a lot more flexible than building hardware to do what programatically is relatively simple.

PM me on my QRZ email if you want a deeper explanation. This is how I’d do it, there are as many other ways, all of them valid, as there are folks on the list…pick what you’re comfortable with, and run with it.

73 bryan wb0yle/w2fuv

Thanks Bryan,

I just thought it would have been sexy to have a 1 button connect mechanism. It looks like everything is centered around DTMF. It may just be easier to do it that way in the long run. I just though someone may have done this before. I did come across a youtube video where it looks like G7RPG did just that…

By the way… I saw your QRZ page… I used to work at WFUV circa 1973 when Bob Jewel was Chief Engineer. I helped convert the station to Stereo and wired the McCurdy console…

Regards,

Rich, WA2ZPX

I knew your name was familiar. And for that, you can count on any help I can give…anyone who worked with bob (and billy holder, gene maxwell, etc) is a friend in my book.

we’ll take this off line…

Rich,
If you can point me to the script, I can try to help and can also enlist the help of one or more friends.
I also want to ask you about the IRLP and Echolink on a couple of local repeaters.
My number is 201.314.6964 or you can email me at W2TTT@ATT.NET.
73,
Gordon Beattie, W2TTT

What about when the node is busy? Seems a physical button executing a script or something could still be useful. This is a problem w simplex nodes when all you have is a radio (no DVSwitch, console on allmon/supermon, etc).

Found a old post I see…
Well, when you want something special off the beaten path, you are going to have to learn to code some.

Depending on the gpio input,
there are several options out there.
Use of ‘on event programming’ for sound dongle … see wiki
Parallel port pins can trigger a command if you are using a PC with one… see wiki
Use of pi gpio, a shell script will do the trick as mentioned above.

What you command is up to you.
This is not something I would do if you do not retain full access to dtmf or command line control.
If you connect to something and something goes wrong, you also need the ability to disconnect… one more gpio pin ?

Mainly interested in disconnect command for some guys w simplex nodes. Thx for the info!

Looking for something of the same. IF the GPIO pin is “on” aka there is continuity between to GPIO pins all is kosher. Once the relay breaks that I would like allstarlink to run a script for announcement such as “repeater is on back up power, please use for emergency only” and then when power comes back on script runs again to turn it off.