External scripts and variables.

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

External scripts and variables.

Manos Darkadakis
Hello there all. I am running svxlink for Radio Amateur assn of Greece and I would like to add some local weather information. Some time ago I have written a script that takes the APRS string by downloading it from an ftp site where it is uploaded by the weather station (WM-918). The script parses the received string and extracts various weather conditions in relevant variables. These variables and current forecast are send through our SV1P D-star repeater every hour. How should I use the same variables from inside svxlink?
I tried to run the script as an external command and works correctly as the "99" example but the svxlink does not see the variables (I send the output on screen and see all info printed correctly through the script).  Any suggestion / ideas anyone so svxlink can see these weather variables ?

Thanks in advance
Manos SV1IW
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: External scripts and variables.

Martin Burkhardt
Hi Manos,

I have doen somethning similar here on DB0SVX.

I modified Logic.tcl unsing the locales solution.

proc dtmf_cmd_received {cmd} {
  if {$cmd == 4711} {
    package require http;
    global mycall;
    set sHumidity -1;

    # some websites, not the usps necessarily, care what kind of browser is used.
    ::http::config -useragent "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)";

    set url http://aprs.fi/?c=raw&limit=4&call=$mycall&view=decoded;

    # the http man page is a good place to read up on these commands
    set sContent  [::http::geturl $url];
    set sUrlContent [::http::data $sContent];
#    puts "$sUrlContent"

    # we use a regular expression pattern to extract the text
    # we are looking for
    if {[regexp {m/.*wx:.*/} $sUrlContent]} {
      regexp -- {m/.*temp: (\-?\d{1,}\.\d).*/} $sUrlContent -> sTemp sDummy;
#      puts "sTemp $sTemp";
      regexp -- {m/.*humidity: (\d{1,}).*/} $sUrlContent -> sHumidity sDummy;
#      puts "$sHumidity";
      regexp -- {m/.*rain_1h: (\d{1,}\.\d).*/} $sUrlContent -> sRainHour sDummy;
#      puts "$sRainHour";#: 1.0 mm
      regexp -- {m/.*wind_speed: (\d{1,}\.\d).*/} $sUrlContent -> sWindSpeed sDummy;
#      puts "$sWindSpeed";#: 0.0 m/s
      regexp -- {m/.*pressure: (\d{1,}\.\d).*/} $sUrlContent -> sQNH sDummy;
#      puts "$sQNH";#: 942.7 mbar
      regexp -- {m/.*rain_24h: (\d{1,}\.\d).*/} $sUrlContent -> sRainDay sDummy;
#      puts "$sRainDay";#      rain_24h: 1.0 mm
      regexp -- {m/.*wind_direction: (\d{1,}).*/} $sUrlContent -> sWindDir sDummy;
#      puts "$sWindDir";  #wind_direction: 247

      playMsg "MetarInfo" "EDJA";
      spellWord $mycall;

      playMsg "MetarInfo" "wind";
      if {$sWindSpeed != "0.0"} {
        playNumber $sWindDir;
        playMsg "MetarInfo" "unit_degree";
        playNumber $sWindSpeed;
        playMsg "MetarInfo" "unit_mps";
      } else {
        playMsg "MetarInfo" "calm";
        playSilence 250;
      }
      playMsg "MetarInfo" "ra";
      playMsg "MetarInfo" "last";
      playMsg "MetarInfo" "hour";
      playNumber $sRainHour;
      playMsg "MetarInfo" "unit_mm";
      playMsg "MetarInfo" "ra";
      playMsg "MetarInfo" "last";
      playNumber 24;
      playMsg "MetarInfo" "hours";
      playNumber $sRainDay;
      playMsg "MetarInfo" "unit_mm";
      playMsg "MetarInfo" "temperature";
      if { $sTemp < 0 } {
        playMsg "MetarInfo" "minus";
      }
      playNumber $sTemp;
      playMsg "MetarInfo" "unit_degrees";
      if { $sHumidity > 0 } {
      playMsg "MetarInfo" "dewpoint";
      playNumber $sHumidity;
      playMsg "MetarInfo" "percent";
      }
      playMsg "MetarInfo" "qnh";
      playNumber $sQNH;
      playMsg "MetarInfo" "unit_hPa";
    } else {
      playMsg "Core" "failed";
    }
    return 1;
  } else {
    return 0;
  }
}

The first part is just settings and the download of the required informations. The second part that starts with playMsg "MetarInfo" "EDJA" is the audio output that has been needs to be build.

In clear text the output is for example "Memmingen DB0SVX Wind 145 degree 6 meter per second rain last hour 5 mm rain last 24 hours 35 mm  temperature 5 degree dewpoint 75 percent local airpressure 943 hecto pascal". I know that a dewpoint in percent in not totally correct, but I have not jet calclated the dewpoint in dregree.

I hope that helps. I not there is another solution that calls an external perl script, that has been created by Adi (DL1HRC).

73 de Martin, DF1AMB




-----Original-Nachricht-----
Betreff: [Svxlink-devel] External scripts and variables.
Datum: 2017-01-12T22:11:44+0100
Von: "Manos Darkadakis" <[hidden email]>
An: "[hidden email]" <[hidden email]>

Hello there all. I am running svxlink for Radio Amateur assn of Greece and I
would like to add some local weather information. Some time ago I have
written a script that takes the APRS string by downloading it from an ftp
site where it is uploaded by the weather station (WM-918). The script parses
the received string and extracts various weather conditions in relevant
variables. These variables and current forecast are send through our SV1P
D-star repeater every hour. How should I use the same variables from inside
svxlink?
I tried to run the script as an external command and works correctly as the
"99" example but the svxlink does not see the variables (I send the output
on screen and see all info printed correctly through the script).  Any
suggestion / ideas anyone so svxlink can see these weather variables ?

Thanks in advance
Manos SV1IW



--
View this message in context: http://svxlink.996268.n3.nabble.com/External-scripts-and-variables-tp4814.html
Sent from the svxlink-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: External scripts and variables.

Manos Darkadakis

Hi Martin and thanks for the information. This is an interesting approach but I must use less information or the repeater’s users won’t be so happy, perhaps basic information like temp, wind speed plus direction and humidity and rain would be enough for a start. I guess you are close to Memmingen airport.

Thanks again and I may send you an e-mail if further info is need through qrz.com I hope you don’t mind…

 

Regards

 

 Manos G. Darkadakis

SV1IW 

 

Former President (2004-2015) - IARU Liaison

Radio Amateur Association of Greece

National Society - Member of International

Amateur Radio Union  (IARU) since 1959.

 

Don't spot a dx you can't hear. Nobody cares about it

and you mess up propagation charts!

 

 

' Tel:210-9235210

7Fax:210-5226505

Mob:6974-914725

/e-mail:[hidden email]

Visit www.raag.org

 

From: Martin Burkhardt [via SvxLink] [mailto:[hidden email]]
Sent: Sunday, January 15, 2017 4:01 PM
To: Manos Darkadakis
Subject: Re: External scripts and variables.

 

Hi Manos,

I have doen somethning similar here on DB0SVX.

I modified Logic.tcl unsing the locales solution.

proc dtmf_cmd_received {cmd} {
  if {$cmd == 4711} {
    package require http;
    global mycall;
    set sHumidity -1;

    # some websites, not the usps necessarily, care what kind of browser is used.
    ::http::config -useragent "Mozilla/4.75 (X11; U; Linux 2.2.17; i586; Nav)";

    set url http://aprs.fi/?c=raw&limit=4&call=$mycall&view=decoded;

    # the http man page is a good place to read up on these commands
    set sContent  [::http::geturl $url];
    set sUrlContent [::http::data $sContent];
#    puts "$sUrlContent"

    # we use a regular expression pattern to extract the text
    # we are looking for
    if {[regexp {m/.*wx:.*/} $sUrlContent]} {
      regexp -- {m/.*temp: (\-?\d{1,}\.\d).*/} $sUrlContent -> sTemp sDummy;
#      puts "sTemp $sTemp";
      regexp -- {m/.*humidity: (\d{1,}).*/} $sUrlContent -> sHumidity sDummy;
#      puts "$sHumidity";
      regexp -- {m/.*rain_1h: (\d{1,}\.\d).*/} $sUrlContent -> sRainHour sDummy;
#      puts "$sRainHour";#: 1.0 mm
      regexp -- {m/.*wind_speed: (\d{1,}\.\d).*/} $sUrlContent -> sWindSpeed sDummy;
#      puts "$sWindSpeed";#: 0.0 m/s
      regexp -- {m/.*pressure: (\d{1,}\.\d).*/} $sUrlContent -> sQNH sDummy;
#      puts "$sQNH";#: 942.7 mbar
      regexp -- {m/.*rain_24h: (\d{1,}\.\d).*/} $sUrlContent -> sRainDay sDummy;
#      puts "$sRainDay";#      rain_24h: 1.0 mm
      regexp -- {m/.*wind_direction: (\d{1,}).*/} $sUrlContent -> sWindDir sDummy;
#      puts "$sWindDir";  #wind_direction: 247

      playMsg "MetarInfo" "EDJA";
      spellWord $mycall;

      playMsg "MetarInfo" "wind";
      if {$sWindSpeed != "0.0"} {
        playNumber $sWindDir;
        playMsg "MetarInfo" "unit_degree";
        playNumber $sWindSpeed;
        playMsg "MetarInfo" "unit_mps";
      } else {
        playMsg "MetarInfo" "calm";
        playSilence 250;
      }
      playMsg "MetarInfo" "ra";
      playMsg "MetarInfo" "last";
      playMsg "MetarInfo" "hour";
      playNumber $sRainHour;
      playMsg "MetarInfo" "unit_mm";
      playMsg "MetarInfo" "ra";
      playMsg "MetarInfo" "last";
      playNumber 24;
      playMsg "MetarInfo" "hours";
      playNumber $sRainDay;
      playMsg "MetarInfo" "unit_mm";
      playMsg "MetarInfo" "temperature";
      if { $sTemp < 0 } {
        playMsg "MetarInfo" "minus";
      }
      playNumber $sTemp;
      playMsg "MetarInfo" "unit_degrees";
      if { $sHumidity > 0 } {
      playMsg "MetarInfo" "dewpoint";
      playNumber $sHumidity;
      playMsg "MetarInfo" "percent";
      }
      playMsg "MetarInfo" "qnh";
      playNumber $sQNH;
      playMsg "MetarInfo" "unit_hPa";
    } else {
      playMsg "Core" "failed";
    }
    return 1;
  } else {
    return 0;
  }
}

The first part is just settings and the download of the required informations. The second part that starts with playMsg "MetarInfo" "EDJA" is the audio output that has been needs to be build.

In clear text the output is for example "Memmingen DB0SVX Wind 145 degree 6 meter per second rain last hour 5 mm rain last 24 hours 35 mm  temperature 5 degree dewpoint 75 percent local airpressure 943 hecto pascal". I know that a dewpoint in percent in not totally correct, but I have not jet calclated the dewpoint in dregree.

I hope that helps. I not there is another solution that calls an external perl script, that has been created by Adi (DL1HRC).

73 de Martin, DF1AMB




-----Original-Nachricht-----
Betreff: [Svxlink-devel] External scripts and variables.
Datum: 2017-01-12T22:11:44+0100
Von: "Manos Darkadakis" <[hidden email]>
An: "[hidden email]" <[hidden email]>

Hello there all. I am running svxlink for Radio Amateur assn of Greece and I
would like to add some local weather information. Some time ago I have
written a script that takes the APRS string by downloading it from an ftp
site where it is uploaded by the weather station (WM-918). The script parses
the received string and extracts various weather conditions in relevant
variables. These variables and current forecast are send through our SV1P
D-star repeater every hour. How should I use the same variables from inside
svxlink?
I tried to run the script as an external command and works correctly as the
"99" example but the svxlink does not see the variables (I send the output
on screen and see all info printed correctly through the script).  Any
suggestion / ideas anyone so svxlink can see these weather variables ?

Thanks in advance
Manos SV1IW



--
View this message in context: http://svxlink.996268.n3.nabble.com/External-scripts-and-variables-tp4814.html
Sent from the svxlink-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel


------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel


If you reply to this email, your message will be added to the discussion below:

http://svxlink.996268.n3.nabble.com/External-scripts-and-variables-tp4814p4817.html

To unsubscribe from External scripts and variables., click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: External scripts and variables.

Rob Janssen
When you do things like this you may face the people that like to invoke it again and again
and cause irritation amongst the users.
For that I have written a "rate limiting" function:

#
# An array to hold the timestampts of attempts used in checkattempts
#
variable times;

# check for number of attempts in specified time
# used for limiting the number of DTMF commands

proc checkattempts {attempts interval} {
  global times;

  set now [clock seconds];

  foreach element [array names times] {
    if {$element < $now} {
      unset times($element);
    }
  }

  if {[array size times] >= $attempts} {
     return 0;
  }

  set now [expr $now + $interval];
  set times($now) 1;
  return 1;
}

You can invoke this in the dtmf decoder like:

  # Limit the number of commands per time interval (seconds)
  if {[checkattempts 3 900] == 0} {
     puts "Ignoring DTMF command: $cmd"
     return 1;
  }

This will allow 3 usages in 15 minutes (900 seconds).
It does this by keeping the timestamps of recent usage in a list, and when there are more
than the number of attempts in the list more recent than the interval, it returns 0.  So when
the oldest attempt is >900 seconds ago, one further usage is allowed.

Rob

Manos Darkadakis wrote:

Hi Martin and thanks for the information. This is an interesting approach but I must use less information or the repeater’s users won’t be so happy, perhaps basic information like temp, wind speed plus direction and humidity and rain would be enough for a start. I guess you are close to Memmingen airport.

Thanks again and I may send you an e-mail if further info is need through qrz.com I hope you don’t mind…

 

Regards

 

 Manos G. Darkadakis

SV1IW 




------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: External scripts and variables.

Manos Darkadakis

Hi Rob and thanks for the info. This is certainly a very good idea. For the moment I plan to just “announce” the temperature on the long identification every hour. Then I will include some more information on demand…

I have made some progress and now I can read the APRS text produced by my WM-918 weather station and paaaing them over to tcl logic for further use…

 

Regards

 

 Manos G. Darkadakis

SV1IW 

 

Former President (2004-2015) - IARU Liaison

Radio Amateur Association of Greece

National Society - Member of International

Amateur Radio Union  (IARU) since 1959.

 

Don't spot a dx you can't hear. Nobody cares about it

and you mess up propagation charts!

 

 

' Tel:210-9235210

7Fax:210-5226505

Mob:6974-914725

/e-mail:[hidden email]

Visit www.raag.org

 

From: Rob Janssen [via SvxLink] [mailto:[hidden email]]
Sent: Monday, January 16, 2017 11:39 PM
To: Manos Darkadakis
Subject: Re: External scripts and variables.

 

When you do things like this you may face the people that like to invoke it again and again
and cause irritation amongst the users.
For that I have written a "rate limiting" function:

#
# An array to hold the timestampts of attempts used in checkattempts
#
variable times;

# check for number of attempts in specified time
# used for limiting the number of DTMF commands

proc checkattempts {attempts interval} {
  global times;

  set now [clock seconds];

  foreach element [array names times] {
    if {$element < $now} {
      unset times($element);
    }
  }

  if {[array size times] >= $attempts} {
     return 0;
  }

  set now [expr $now + $interval];
  set times($now) 1;
  return 1;
}

You can invoke this in the dtmf decoder like:

  # Limit the number of commands per time interval (seconds)
  if {[checkattempts 3 900] == 0} {
     puts "Ignoring DTMF command: $cmd"
     return 1;
  }

This will allow 3 usages in 15 minutes (900 seconds).
It does this by keeping the timestamps of recent usage in a list, and when there are more
than the number of attempts in the list more recent than the interval, it returns 0.  So when
the oldest attempt is >900 seconds ago, one further usage is allowed.

Rob

Manos Darkadakis wrote:

Hi Martin and thanks for the information. This is an interesting approach but I must use less information or the repeater’s users won’t be so happy, perhaps basic information like temp, wind speed plus direction and humidity and rain would be enough for a start. I guess you are close to Memmingen airport.

Thanks again and I may send you an e-mail if further info is need through qrz.com I hope you don’t mind…

 

Regards

 

 Manos G. Darkadakis

SV1IW 

 



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel


If you reply to this email, your message will be added to the discussion below:

http://svxlink.996268.n3.nabble.com/External-scripts-and-variables-tp4814p4820.html

To unsubscribe from External scripts and variables., click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [SPAM] RE: External scripts and variables.

Rob Janssen
Manos Darkadakis wrote:

Hi Rob and thanks for the info. This is certainly a very good idea. For the moment I plan to just “announce” the temperature on the long identification every hour. Then I will include some more information on demand…

I have made some progress and now I can read the APRS text produced by my WM-918 weather station and paaaing them over to tcl logic for further use…



Yes it is possible to do some nice things that way.
For example, we have DX announcements using the PE1NWL dx-robot "gooddx.net".  A separate process fetches
the DX status and puts a pre-recorded audio file at a fixed location when it changes, the svxlink code picks it
up in the snd_rgr_sound routine so the announcement is played just before the roger beep so it is clearly
heard (and not muted because it occurs during a transmission).

Rob

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RE: [SPAM] RE: External scripts and variables.

Manos Darkadakis

Great Rob

We do this in our D-Star network since 2014. As a matter of fact Allard changed the file structure of dxrobot after our discussion so we could issue voice alerts on 6, 4 and 2 m bands. Nice to know that others are using this too…

 

 Manos G. Darkadakis

SV1IW 

 

Former President (2004-2015) - IARU Liaison

Radio Amateur Association of Greece

National Society - Member of International

Amateur Radio Union  (IARU) since 1959.

 

Don't spot a dx you can't hear. Nobody cares about it

and you mess up propagation charts!

 

 

' Tel:210-9235210

7Fax:210-5226505

Mob:6974-914725

/e-mail:[hidden email]

Visit www.raag.org

 

From: Rob Janssen [via SvxLink] [mailto:[hidden email]]
Sent: Wednesday, January 18, 2017 6:57 PM
To: Manos Darkadakis
Subject: Re: [SPAM] RE: External scripts and variables.

 

Manos Darkadakis wrote:

Hi Rob and thanks for the info. This is certainly a very good idea. For the moment I plan to just “announce” the temperature on the long identification every hour. Then I will include some more information on demand…

I have made some progress and now I can read the APRS text produced by my WM-918 weather station and paaaing them over to tcl logic for further use…

 


Yes it is possible to do some nice things that way.
For example, we have DX announcements using the PE1NWL dx-robot "gooddx.net".  A separate process fetches
the DX status and puts a pre-recorded audio file at a fixed location when it changes, the svxlink code picks it
up in the snd_rgr_sound routine so the announcement is played just before the roger beep so it is clearly
heard (and not muted because it occurs during a transmission).

Rob

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel


If you reply to this email, your message will be added to the discussion below:

http://svxlink.996268.n3.nabble.com/External-scripts-and-variables-tp4814p4825.html

To unsubscribe from External scripts and variables., click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [SPAM] RE: [SPAM] RE: External scripts and variables.

Rob Janssen
Manos Darkadakis wrote:

Great Rob

We do this in our D-Star network since 2014. As a matter of fact Allard changed the file structure of dxrobot after our discussion so we could issue voice alerts on 6, 4 and 2 m bands. Nice to know that others are using this too…

 

 Manos G. Darkadakis

SV1IW


We too have separate messages for 6, 4 and 2 meter ES and also for Aurora.

We do this on our "extreme 70cm repeater" PI2NOS/PJ2NOS (likely the largest svxlink installation) which has 3 co-channel transmitters,
one more transmitter on another continent (operating under different callsign), 21 remote receivers into the voter, 2 more "audio uplinks"
for bulletin stations, EchoLink, live stream on internet ( http://icecast.pe1rjv.nl:8000/pi2nos ) and live display of the Voter and transmitter
events ( http://pi2nos.ampr.org/svxsqlinfo/ ).  And there is also a web application that displays that info on a map and allows playback
of recent audio on the repeater ( https://pc7x.net/repeaters/#/map/google/pi2nos ).

Rob

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Svxlink-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/svxlink-devel
Loading...