on 06-23-2014 05:19 AM
This ISR sample application uses a tclsh script managed by an EEM applet to stream NMEA formatted location data in UDP packets (with configurable port number) to a defined target. TCLSH script is in the attached zip file and also requires the following CLI commands.
! CLI commands required:
event manager environment server "your server ip address"
event manager environment udp_port "your udp port"
event manager applet NMEA
event syslog pattern "LINEPROTO-5-UPDOWN: Line protocol on Interface Cellular[0-9\/]+, changed state to up" maxrun 31536000
action 010 cli command "enable"
action 020 syslog msg "NMEA streaming starting now"
action 030 cli command "tclsh flash:stream_NMEA2.tcl $server $udp_port"
aaa new-model
aaa authentication login nologin none
aaa authorization exec nologin none
controller Cellular <number>
lte gps mode standalone
"lte gps nmea ip" for 819. "lte gps nmea" for all other platforms
How can this be modified to only send the GPS every 2 minutes? Also, can the GPS be configured to send only the GPRMC message?
Replace the stream_NMEA2.tcl with this code and it will send $GPRMC every 2 minutes.
package require udp
set server [lindex $argv 0]
set sudp_port [lindex $argv 1]
puts "server and port = $server $sudp_port"
set intf [ios_config "int loopback 7" "description DO NOT REMOVE" "ip add 1.2.3.4 255.255.255.255"]
set pt [exec show line | inc NM]
regexp {.?\s+(\d+)\s+TTY} $pt -> line
set cl [exec clear line $line]
set ttyline [ios_config "line $line" "login authentication nologin"]
set transprt [ios_config "line $line" "transport input all"]
set sock [udp_open]
fconfigure $sock -remote [list $server $sudp_port]
after 1000
set IP "1.2.3.4"
set port [expr 2000 + $line]
set fd [socket $IP $port]
set counter 120
while {[gets $fd line] } {
incr counter
if [ regexp {^\$GPRMC} $line ->line ] {
if {$counter >= 120} {
puts -nonewline $sock $line
flush $sock
send_syslog "NMEA packet sent to $server on port $sudp_port $line"
set counter 0
}
}
}
we've been trying to activate the new script for the past hour... doesn't seem that it is sending any data..
It may be best to get on a web ex to go over these changes. You can reach me at dafrey@cisco.com and we can set up a time to take a look at this policy.
I am in the middle of replacing 150 Sierra Truck cellular modems with Cisco IR829GW's and have noticed a significant increase in Cellular data consumption related to GPS data being send to out GPSGate vehicle location application. To the tune of 10x more data being send and at a streaming rate versus every 5 sec or 100M travelled.
Is there a way to not use streaming or change streaming to only report an a scheduled interval like 10 sec's or do I have to resort to a script like you have here?
Ideally I would like the router to report in every 5 seconds when moving, or 100M travelled, and every 2 min when stationary.
NMEA Streaming is every second with data packets 2-4 times larger than Sierra and its going to drive out Cellular consumption.
Any suggestions are welcome.
The script is the only way we have been able to get this to work. We did have to remove the line:
send_syslog "NMEA packet sent to $server on port $sudp_port $line"
This caused the script to not work properly. We could then change the 'counter' to get the desired report rate.
What router platform are you running on? (IR800?)
Are you finding the 2 min interval is working for you?
Is you application a vehicle tracking one?
I appreciate the information.
Running on an Cisco 819 Verizon router. The vehicle does not move very much, so it is only reporting every 5 minutes to the RASTRAC vehicle tracking service.
We did have to play with the counter a bit to get the proper report rate as the counter counts every message not just the RMC messages. This gave us an approx. 5 min report:
set counter 3073
Having issues getting this going. Am I right in assuming the router initiated the connection back to the server? I never see the router try to make the connection.
Here is my script:
package require udp
set server [lindex $argv 0]
set sudp_port [lindex $argv 1]
puts "server and port = $server $sudp_port"
set intf [ios_config "int loopback 1" "description DO NOT REMOVE" "ip add 192.168.252.129 255.255.255.255"]
set pt [exec show line | inc NM]
regexp {.?\s+(\d+)\s+TTY} $pt -> line
set cl [exec clear line $line]
set ttyline [ios_config "line $line" "login authentication nologin"]
set transprt [ios_config "line $line" "transport input all"]
set sock [udp_open]
fconfigure $sock -remote [list $server $sudp_port]
after 1000
set IP "192.168.252.129"
set port [expr 2000 + $line]
set fd [socket $IP $port]
set counter 120
while {[gets $fd line] } {
incr counter
if [ regexp {^\$GPRMC} $line ->line ] {
if {$counter >= 120} {
puts -nonewline $sock $line
flush $sock
# send_syslog "NMEA packet sent to $server on port $sudp_port $line"
set counter 0
}
}
My IOS commands are here:
event manager environment server "192.168.108.74"
event manager environment udp_port "30176"
event manager applet NMEA
event syslog pattern "LINEPROTO-5-UPDOWN: Line protocol on Interface Cellular[0-9\/]+, changed state to up" maxrun 31536000
action 010 cli command "enable"
action 020 syslog msg "NMEA streaming starting now"
action 030 cli command "tclsh flash:nmea_829_gps.tcl $server $udp_port"
Any ideas?
You will not see anything on the router that it is making a connection to the NMEA server. A few things to check.
Make sure the router successfully can reverse telnet to the TTY port for NMEA (8 in output below).
C1921#sh line
Tty Line Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
0 0 CTY - - - - - 0 0 0/0 -
1 1 AUX 9600/9600 - - - - - 0 0 0/0 -
2 2 TTY 9600/9600 - - - - - 0 0 0/0 -
A 0/0/0 3 TTY - - - - - 0 0 0/0 Ce0/0/0
* 0/0/5 8 TTY - inout - - - 0 0 0/0 NM0/0/5
I use this TCL script to act as my NMEA server.
#!/usr/bin/tclsh
# A simple UDP server
package require udp
proc udpEventHandler {sock} {
set pkt [read $sock]
set peer [fconfigure $sock -peer]
set dat [exec date +%H:%M:%S.%N]
puts "$dat $peer: [string length $pkt] $pkt"
return
}
proc udp_listen {port} {
set srv [udp_open $port]
# fconfigure $srv -buffering none -blocking 0 -translation binary
# fconfigure $srv -buffering none -encoding binary
fileevent $srv readable [list ::udpEventHandler $srv]
puts "Listening on udp port: [fconfigure $srv -myport]"
return $srv
}
set sock [udp_listen 12345]
vwait forever
##########End
Start server and wait for NMEA traffic.
[root@HammerHead nmea]# ./tcl_udp_server.tcl
Listening on udp port: 12345
14:21:54.496828145 192.168.0.1 55488: 68 $GPRMC,180245.0,A,3854.406476,N,07810.006597,W,1.7,3.2,270417,,,A*78
14:22:46.490448749 192.168.0.1 55488: 69 $GPRMC,180337.0,A,3854.388506,N,07809.996212,W,1.3,82.4,270417,,,A*42
14:23:39.497720327 192.168.0.1 55488: 70 $GPRMC,180430.0,A,3854.373288,N,07810.005838,W,0.7,175.7,270417,,,A*71
14:24:33.523844220 192.168.0.1 55488: 69 $GPRMC,180524.0,A,3854.386612,N,07810.006207,W,0.0,86.7,270417,,,A*47
14:25:26.513996143 192.168.0.1 55488: 69 $GPRMC,180617.0,A,3854.386246,N,07810.004374,W,0.0,86.7,270417,,,A*46
Reverse Telnet looks like its happening: Line 7
STJ-TEST-KEN#sh users
Line User Host(s) Idle Location
0 con 0 idle 00:18:01
3 tty 3 Async interface 00:00:00
7 tty 7 incoming 00:00:00 192.168.252.129
705 vty 0 idle 00:24:19 EEM:NMEA
706 vty 1 admin idle 00:25:40 192.168.101.130
*707 vty 2 admin idle 00:00:00 192.168.101.130
Interface User Mode Idle Peer Address
I get nothing back on my server.
Manually reverse telnet to the NMEA line and verify that NMEA data is present.
C1921#telnet 192.168.0.1 2008
Trying 192.168.0.1, 2008 ... Open
$GNGSA,A,2,67,75,76,85,86,87,,,,,,,1.1,0.7,0.8*2C
$PSTIS,*61
$GPGSV,3,1,12,07,46,313,48,08,67,168,41,09,49,253,38,11,14,172,33*79
$GPGSV,3,2,12,16,31,056,40,23,38,202,31,26,08,068,36,27,59,063,40*7E
$GPGSV,3,3,12,51,,,40,21,03,036,,28,00,254,,30,10,303,*44
$GLGSV,3,1,09,86,59,108,33,76,59,019,37,75,28,085,30,87,21,175,29*66
$GLGSV,3,2,09,85,28,035,32,68,02,343,34,66,16,240,,77,23,307,*66
$GLGSV,3,3,09,67,21,295,*50
Its there:
STJ-TEST-KEN#telnet 192.168.252.129 2007
Trying 192.168.252.129, 2007 ... Open
$GNGSA,A,3,07,09,21,,,,,,,,,,500.0,500.0,500.0*24
$GNGSA,A,3,,,,,,,,,,,,,500.0,500.0,500.0*29
$GPGSV,2,1,07,07,37,305,22,09,24,262,18,21,23,049,20,30,02,314,24*74
$GPGSV,2,2,07,04,,,,08,52,223,,11,05,198,*73
$GLGSV,3,1,12,,,,24,77,16,314,17,76,73,343,13,87,11,202,20*5B
$GLGSV,3,2,12,67,07,302,16,68,08,351,19,74,,,,66,,,*6D
$GLGSV,3,3,12,86,66,180,,75,45,119,,84,,,,85,48,040,*52
$GPGGA,183730.0,4733.508324,N,05245.174442,W,1,03,500.0,62.9,M,12.0,M,,*75
$PQXFI,183730.0,4733.508324,N,05245.174442,W,62.9,558.07,955.22,19.60*7B
$GNGNS,183730.0,4733.508324,N,05245.174442,W,AN,03,500.0,62.9,12.0,,*4E
$GPVTG,,T,,M,,N,,K,N*2C
$GPRMC,183730.0,A,4733.508324,N,05245.174442,W,,,270417,0.0,E,A*13
$GPGSA,A,3,07,09,21,,,,,,,,,,500.0,500.0,500.0*3A
$GNGSA,A,3,07,09,21,,,,,,,,,,500.0,500.0,500.0*24
$GNGSA,A,3,,,,,,,,,,,,,500.0,500.0,500.0*29
The script tries to get the NMEA port automatically by running CLI command "show line | inc NM". The platform that I have used the NMEA TTY port was always on that port. I suspect maybe your platform may not have that so the regex does not match.
For testing remove these two lines in the TCL script.
set pt [exec show line | inc NM]
regexp {.?\s+(\d+)\s+TTY} $pt -> line
Add this single where the two removed lines used to be so the TTY port is hardcoded to 7
set line 7
Also can you paste the output of "show line"
STJ-TEST-KEN#sh line
Tty Line Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int
* 0 0 CTY - - - - - 0 0 0/0 -
1 1 TTY 9600/9600 - - - - - 0 0 0/0 -
2 2 TTY 9600/9600 - - - - - 0 0 0/0 -
A 3 3 TTY - inout - - - 0 0 0/0 Ce0
4 4 TTY 9600/9600 - - - - - 0 0 0/0 -
* 7 7 TTY - inout - - - 8 1307 0/0 NM7
8 8 TTY - - - - - 0 0 0/0 Ce1
1/3 69 TTY 9600/9600 - - - - - 0 0 0/0 -
1/4 70 TTY 9600/9600 - - - - - 0 0 0/0 -
1/5 71 TTY 9600/9600 - - - - - 0 0 0/0 -
1/6 72 TTY 9600/9600 - - - - - 0 0 0/0 -
* 705 705 VTY - - - - 23 3 0 0/0 -
706 706 VTY - - - - 23 1 0 0/0 -
* 707 707 VTY - - - - 23 2 0 0/0 -
708 708 VTY - - - - 23 0 0 0/0 -
709 709 VTY - - - - 23 0 0 0/0 -
Line(s) not in async mode -or- with no hardware support:
5-6, 9-68, 73-704
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: