GPS

CAn anyone tell me if they have successfully implemented a GPS reciever thru a MiKrotiK box. What I want to do is get the reciver to work, and somehow get the info from it every 30 seconds. THis info can either be fetched or if possible sent to a ftp server.

Any suggestions?

Cheers
Andre

that is right Mr. aporozny,
I also wants to be one of GPS users here in Egypt

[admin@home] > /system gps monitor
date-and-time: may/26/2008 02:16:19
longitude: “W 117 X’ 51’'”
latitude: “N 33 X’ 48’'”
altitude: “201.699997m”
speed: “0.166680 km/h”
valid: yes

date-and-time: may/26/2008 02:16:21
longitude: “W 117 X’ 51’'”
latitude: “N 33 X’ 48’'”
altitude: “201.699997m”
speed: “0.092600 km/h”
valid: yes

Thanks for that guru, however, how do i get that information to either a mapping server or an ftp server automaticatlly?

Thanks in advance
Andre

if your router travelling a lot :slight_smile: ?

you could use the API, or some SSH/PERL script to get that info.

yup, I am putting the mikrotik box with the 3g router in a bus. People travelling will be able to purchase time or data and get online in the bus.

THe customer wants to see where the bus is at the same time. Keep track of where it has been.

I do not know how to get a script to read the serial port to get the info from the gps.

I also need to load the GPS software on the microtik box so any help ther would be good as well.


Cheers
Andre

BUMP

Info guys… has anyone got this working???

Today I got an enquiry for the same type of thing.

T

gps works fine… do you need to write a /tool fetch script to post the location periodically? whats your goal ?

Sam

We’ve had a request from a client that does geographical mapping in a desert…

We’ve installed several BSS for them… and they want to get GPS data from the BSS and triangulate from their equipment to get exact positions…

I said I’d ask…

T

Is it possible to gather the location information (LAT/LON) from SNMP OID values? This would do what I need done, and I could then grab them whenever I wished with an SNMP GET.

What you will need:
A webserver
A database
A serverside programming language

you can use the fetch command in ROS and use the GET function in your script on your webserver from the http header.
the script logs every thing to the database…

i use something similar to monitor wifi clients status (will be posted in the wiki when it is done).

What GPS are you using? I am looking for a GPS I can connect to the serial port of the MT.

Thank you,

Cory

bump

I´m working with a GARMIN GPS18X PC with serial connection. Others model of Garmin cann´t comunicate with Mikrotik because they have his own protocol.

If you want to use a GPS with Mikrotik you need to check that the GPS use NMEA 0183 protocol.

Regards

I have a GPS “Module” that connects via USB…
RouterOS “Sees” it and works…

It costs about $50.00 US ans has a magnetic mount…
It has a 6’ USB cable.

It is made by “Ambicom”
Model: GPS-USB

Just Drug it out of the laptop case and it is up and working..

Let me think on the collection idea..

Assuming the ‘once’ parameter works and that ‘/system/gps/monitor’ works in the API much like changip’s CLI example, then using the Ruby API command-line example script tikjson.rb and changip’s example GPS output, one could retrieve the GPS info thus:

user@unixhost:/path% ./tikjson.rb 10.20.30.40 userid password /system/gps/monitor =once=
[{'date-and-time': 'may/26/2008 02:16:19','longitude': 'W 117 X\' 51\"','latitude': 'N 33 X\' 48'\'','altitude': '201.699997m','speed': '0.166680 km/h','valid': 'yes','.tag': 2,'!re': NULL},{'!done': NULL,'.tag': 2}]
user@unixhost:/path%

Or using the Ruby GEM:

#!/usr/local/bin/ruby

require 'rubygems'
require 'mtik'

TIKHOST='10.20.30.40'
TIKUSER='admin'
TIKPASS='password'

def get_location(ip, user, pass)
  location = MTik::command(
    :host => TIKHOST,
    :user => TIKUSER,
    :pass => TIKPASS,
    :command => [
      '/system/gps/monitor',
      '=once='
    ]
  )[0]
  unless location.key?('!re')
    raise RuntimeError.new("No valid reply from MikroTik device to /system/gps/monitor command.")
  end
  unless location['valid'] == 'yes'
    raise RuntimeError.new("GPS location was read, but invalid.")
  end
  return location
end

l = get_location(TIKHOST, TIKUSER, TIKPASS)
puts "GPS Latitude #{l['latitude']} Longitude #{l['longitude']}"
puts "Altitude #{l['altitude']} Date/Time #{l['date-and-time']} Speed #{l['speed']}"

Which might output (barring errors/exceptions):

GPS Latitude N 33 X' 48' Longitude W 117 X' 51''
Altitude 201.699997m Date/Time  may/26/2008 02:16:19 Speed 0.166680 km/h

If you want to save the location in a database, require ‘mysql’ or another DB (or even ‘activerecord’) and insert the data. You could even run an eternal script that connected to the device, then continuously monitored the GPS location (by not using the ‘=once=’ parameter) and processing each reply sentence as received:

#!/usr/local/bin/ruby

require 'rubygems'
require 'mtik'

TIKHOST='10.20.30.40'
TIKUSER='admin'
TIKPASS='password'

tikcon = MTik::Connection.new(
  :host => TIKHOST,
  :user => TIKUSER,
  :pass => TIKPASS
)

tikcon.get_reply_each('/system/gps/monitor') do |req, sentence|
  if sentence.key?('!re') && sentence['valid'] == 'yes'
    puts "Time: #{sentence['date-and-time'] Lat: #{sentence['latitude']} " +
      "Lon: #{sentence['longitude']} Alt: #{sentence['altitude']} " +
      "Speed: #{sentence['speed']}\n"
  end
end
## This runs the event loop which should keep reading replies for as long as the device sends 'em
tikcon.wait_all

## This should never happen:
tikcon.close

Which might output a sequence like:

Time: may/26/2008 02:16:19 Lat: N 33 X' 48' Lon: W 117 X' 51'' Alt: 201.699997m Speed: 0.166680 km/h
Time: may/26/2008 02:16:20 Lat: N 33 X' 48' Lon: W 117 X' 50'' Alt: 202.262352m Speed: 2.235236 km/h
Time: may/26/2008 02:16:21 Lat: N 33 X' 48' Lon: W 117 X' 50'' Alt: 201.693527m Speed: 1.012523 km/h
Time: may/26/2008 02:16:22 Lat: N 33 X' 49' Lon: W 117 X' 50'' Alt: 200.838820m Speed: 5.936262 km/h
...

The API in any of the API languages is very useful.

Aaron out.

Disclaimer: No code above was tested for syntatic correctness, and I don’t have a GPS attached to a 'Tik so I dunno exact API commands nor output sentence structure. But the basics should be there…