[arm-allstar] Received variable - and automation delay
David Panscik
dpanscik at yahoo.com
Sat May 9 23:30:04 EDT 2020
Thanks Doug. That was the missing puzzle piece. Ive now got a working solution to delay automation if a conversation is in progress. In the next few days Ill clean up the code and publish back on this thread so others can use the script.
On Saturday, May 9, 2020, 07:33:27 PM PDT, Doug Crompton <wa3dsp at gmail.com> wrote:
David,
Just do it in a script. Here is an example.
Script name delay_test
Call as - delay_test <filename>
!/bin/bash
File_time=$(stat -c %Y $1)
Now=$(date +%s)
echo $File_time
echo $Now
Res=$(echo $( bc <<< "$Now - $File_time" ))
echo "Age since create - $Res"
73 Doug
WA3DSP
http://www.crompton.com/hamradio
On Sat, May 9, 2020 at 8:43 PM David Panscik <dpanscik at yahoo.com> wrote:
Hi Doug,
This afternoon I started playing with this. A solution is starting to take shape.
I would love to take this command and run it after the file is XX seconds old.
rm -f /tmp/RPT_TXKEYED = s|f|RPT_TXKEYED
Is there a easy way to do this? I played with some Python os.stat commands, but it seems the Raspberry Pi isnt loaded with a full set of Python commands.
What do you think?
David
On Wednesday, May 6, 2020, 06:37:50 AM PDT, David Panscik via ARM-allstar <arm-allstar at hamvoip.org> wrote:
Doug,
This is also a fantastic idea for solving for this. Ill tinker with both options and see which one I can get to work best.
Thank you,
David
On Tuesday, May 5, 2020, 10:35:24 PM PDT, Doug Crompton <wa3dsp at gmail.com> wrote:
David,
Another example on possibly how to do this is below. Run delay_msg.sh with delay and node parameter, in the background then create a voice message that plays in .ul format. Then copy that file to /tmp/message.ul - It should play right away if there is no TX or no TX for the delay period. If there is TX it will play up to the delay period after. Also might be better at first to not run delay _msg.sh in the background but rather open two sessions - one will show what is oging on and the other to copy the file to /tmp Make sure you copy the file as it does delete it after it plays it. node must match node the event is active in.
# delay_msg.sh <delay> <node>
#
# Add the following two lines to rpt.conf
# in the [events] section uncomment them
# remove the # Do NOT uncomment
# here in this script.
# touch /tmp/RPT_TXXKEYED = s|t|RPT_TXKEYED
# rm -f /tmp/RPT_TXKEYED = s|f|RPT_TXKEYED
# message location
msg="/tmp/message.ul"
# TX Key file check
TXKEYED="/tmp/TXKEYED"
# delay at unkey
# This is in seconds or with 'm' for minutes
delay="$1"
function Delay {
while [ -e $TXKEYED ]
do
sleep 1
done
echo "Delaying $1"
sleep $delay
}
while :
do
if [ -e $TXKEYED ]
then
echo "TX"
Delay
else
echo "NO TX"
if [ -e $msg ]
then
echo "Playing $msg to $2 with $1 delay"
asterisk -rx "rpt localplay $2 ${msg%.*}"
sleep 10 # Must be longer than message length
rm -f $msg
fi
fi
sleep 1
done
73 Doug
WA3DSP
http://www.crompton.com/hamradio
On Tue, May 5, 2020 at 3:00 PM David Panscik <dpanscik at yahoo.com> wrote:
Doug,
This is right up the alley of what I was looking for.
Ill use your code sample and see if I can get something accomplished here.
Thank you,
David
On Tuesday, May 5, 2020, 11:56:24 AM PDT, Doug Crompton via ARM-allstar <arm-allstar at hamvoip.org> wrote:
David,
This really would not have anything directly to do with cron but rather
would be applied to a script the cron called. The fact that the TX has
been keyed is known by the RPT_TXKEYED variable. This variable can be used
in an event in Asterisk to call a script. This is what might be used to
control a fan and in fact the same principle would be used for a delay time.
Here is an example that would get you started. You add the events to
rpt.conf and then run this script in the background adding the event to
call after the delay. You could have multiple of these scripts running.
They could be started manually or in rc.local. Also keep in mind that the
telemetry system in Allstar while better than most controllers is limited
in some ways that might make this system not work the way intended. This is
on our list of things to improve.
# Add the following two lines to rpt.conf
# in the [events] section uncomment them
# remove the # Do NOT uncomment
# here in this script.
# touch /tmp/RPT_TXXKEYED = s|t|RPT_TXKEYED
# rm -f /tmp/RPT_TXKEYED = s|f|RPT_TXKEYED
# TX Key file check
TXKEYED="/tmp/TXKEYED"
# delay at unkey
# This is in seconds or with 'm' for minutes
delay="1m"
function Delay {
while [ -e $TXKEYED ]
do
sleep 1
done
sleep $delay
}
while :
do
if [ -e $TXKEYED ]
then
echo "TX"
Delay
run_once=0
else
echo "NO TX"
if [ run_once == 0 ]
then
# call operations to execute after delay here
run_once=1
fi
fi
sleep 1
done
*73 Doug*
*WA3DSP*
*http://www.crompton.com/hamradio <http://www.crompton.com/hamradio>*
On Tue, May 5, 2020 at 10:46 AM "David Panscik via ARM-allstar" <
arm-allstar at hamvoip.org> wrote:
> I am not a good programmer. More of a copy and paste coder with a little
> extra syntax thrown in to muddle solutions together.
> My end goal is to write a crontab schedule parser that can delay crontab
> events if there has been a keyup with in xx number of minutes.
> On the air I have heard reference that several people can use this feature.
> I see in supermon there is a "recieved" field that pulls data from
> console.log
> This field would be perfect to determine if a crontab event needs to be
> delayed or allowed to continue.
> Has anyone written some code to parse this into a system variable?
> console.log tabledata[localNode].remote_nodes[row].last_keyed)
> Thanks,
> David
>
> _______________________________________________
>
> 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/4 web page - http://hamvoip.org
_______________________________________________
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/4 web page - http://hamvoip.org
_______________________________________________
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/4 web page - http://hamvoip.org
More information about the ARM-allstar
mailing list