[arm-allstar] Feature request

Doug Crompton wa3dsp at gmail.com
Wed Nov 28 23:52:44 EST 2018


Justin,

 The example in /usr/local/sbin/example_scripts/test_alert.sh works. I
tested it here. It does have a slight error though if you are specifying
the node on the command line  -

if [ -z $1 ]
 then
   node=$NODE1
else
   node=$1   -   is $2 in the example script - should be $1 as shown here.
fi

The easiest way to check this is to open two ssh windows. Run the script in
one and in the other write and clear the file. You should see the condition
come up in the running script.

Clear file -

> /tmp/AUTOSKY/warnings.txt

write something to the file

echo "test" > /tmp/AUTOSKY/warnings.txt

Here is what you should see -

./test_alert.sh
Alert Active - sending 1 to FOB GPIO5        -when you write something to
the file
No Active Alert - sending 0 to FOB GPIO5  - when you clear the file
Alert Active - sending 1 to FOB GPIO5

The GPIO bi is set in the script. It is shown here as 5.


*73 Doug*

*WA3DSP*

*http://www.crompton.com/hamradio <http://www.crompton.com/hamradio>*




On Wed, Nov 28, 2018 at 11:12 PM "Justin Reed via ARM-allstar" <
arm-allstar at hamvoip.org> wrote:

> I've almost got this running. It sets the fob output low when there is
> an alert, (when the file size is greater than 0 bytes), but when the
> alert clears (file size is zero) the script hangs, or doesn't do
> anything, doesn't clear the fob bit.  I flipped the logic the opposite
> way from the original, so a ground on the fob pin indicates an active
> alert.  I've checked for typos or syntax and it looks OK to me.  Here is
> the script:
>
> #!/bin/bash
>
> FOB_BIT=1
>
> # Set node to operate on
>
> if [ -z $1 ]
>   then
>     node="46259"
> else
>     node=$2
> fi
>
> # Clear bit to start
> Current_state=1
>
> while :
> do
>    if [ -s /tmp/AUTOSKY/warnings.txt ]
>      then
>        if [ $Current_state = 1 ]
>          then
>               /bin/asterisk -rx "rpt cmd $node cop 62 GPIO$FOB_BIT=0"
>               echo "Alert Active - sending 0 to FOB GPIO$FOB_BIT"
>               Current_state=0
>        fi
>      else
>        Alert_set=0
>        if [ $Current_state = 0 ]
>           then
>               echo "No Active Alert - sending 1 to FOB GPIO$FOB_BIT"
>               /bin/asterisk -rx "rpt cmd $node cop 62 GPIO$FOB_BIT=1"
>               Current_state=1
>        fi
>    fi
> sleep 5
> done
>
>
>
>
>
> On 11/16/2018 1:42 AM, "Doug Crompton via ARM-allstar" wrote:
> > I actually modified the script again after thinking it. I am attaching a
> > better updated script. This should work fine. Assuming you are using a
> > DMK-URI or other FOB where you can pick up bit 5 hang an LED with a 330
> ohm
> > or so resistor in series to ground. It should light when there is an
> alert.
> > You can simulate this by doing the following -
> >
> > echo "test" > /tmp/AUTOSKY/warnings.txt  # to turn it on - alert
> > echo > /tmp/AUTOSKY/warnings.txt   # To turn it off - no alert
> >
> > See the script for info on changing bits if required. The script assume
> the
> > first node. If you are using a second node you would need to specify it
> in
> > the first parameter to the script -   test_alert.sh <node>
> >
> > Run it in the background after testing  -  test_alert.sh <node> &
> > Best to copy to /etc/asterisk/local  and run from there if you are
> changing
> > anything.
> > could be called at boot in /etc/rc.local - add line at end.
>
> _______________________________________________
>
> ARM-allstar mailing list
> ARM-allstar at hamvoip.org
> http://lists.hamvoip.org/cgi-bin/mailman/listinfo/arm-allstar
>
> Visit the BBB and RPi2/3 web page - http://hamvoip.org


More information about the ARM-allstar mailing list