Sorry, you need to enable JavaScript to visit this website.

Automotive Message Broker

Automotive Message Broker is a framework for getting vehicle sensor data from the vehicle networks and making it available to applications. It allows applications to be developed independently of the differences in vehicle networks used in different automotive vehicle designs.

[Howto Series] - GPS NMEA plugin

BY Kevron Rees ON Dec 17, 2014

GPS Location data is an important peice of the overall vehicle experience.  Without knowing where you are, you cannot know where you are going.  This blog demonstrates how to get AMB up and running with your GPS device.  Assumptions: you have pre-knowledge of how to install Tizen IVI and get an ssh terminal into the Tizen IVI machine.
 

NMEA

 

NMEA stands for The National Marine Electronics Association is a US-based marine electronics trade organisation setting standards of communication between marine electronics.  The association has little to do with our topic of GPS except that they have produced a protocol standard for communicating with GPS devices.  The standard is officially known as NMEA 0183.  It defines a protocol that many modern GPS units use to communicate with software.

Because many devices have support for NMEA we decided that having a GPS NMEA plugin within AMB would be a valuable tool for providing GPS information to applications.

 

Why AMB?



Some vehicles have dedicated hardware on the CAN bus network that handles GPS data.  This data is broadcast to other nodes in the vehicle, including the headunit running the navigation software.  However, other vehicles do not have a GPS device on the CAN bus network.  Instead, this data is provided directly from the GPS inside the headunit.  To handle both cases, AMB must support the ability to get GPS data from devices outside of CAN networks.  Additionally, vehicle hobbiests designing their own system may not have access to the CAN network or have replaced the stock headunit with custom hardware will want a way to use readily-available GPS devices with their custom system.
 

 

Installing the GPS NMEA Plugin


On Tizen IVI, you can simply install the gpsnmea package for AMB:

 

ssh root@tizen_device_ip

zypper in automotive-message-broker-plugins-gpsnmea

After we have the plugin binaries installed, we need to enable and configure them.  Edit /etc/ambd/config.tizen:

nano /etc/ambd/config.tizen

Now add the following section in the "source" section:
 

{
    "name" : "gpsnmea",
    "path" : "/usr/lib/automotive-message-broker/gpsnmea.so",
    "device" : "/dev/ttyUSB0",
    "baudrate" : "9600"
}

You will want to change "device"to match your device location.  Many USB GPS dongles show up as a ttyUSB device.  I've also seen /dev/ttyACM0 and other nodes for different types of GPS hardware.  The best way to find out what your device node is is to run dmesg after plugging in the device.  On some IVI-grade hardware, the GPS device is built in and exposed via a more traditional serial device node.  On the VTC 1010, the GPS device is usually /dev/ttyS3.  Sometimes you just have to try to "cat" the device node to see if you get any NMEA sentences:

cat /dev/ttyS3

$GPAAM,A,A,0.10,N,WPTNME*32

If you see something like the above (NMEA messages typically start with "$G", then you've found your GPS device.

In addition to USB GPS dongles, AMB can use bluetooth to communicate with bluetooth GPS devices.  In this case,  just replace the "device" value with the address of your bluetooth device (typically something like 00:00:00:00:00:00).  This assumes you've already paired with the bluetooth GPS device.

Next restart ambd and we can start getting GPS data.

systemctl restart ambd

Now may be a good time to check journalctl to see if ambd started up without any problems with our configuration.  See the "Debugging" section for hints for getting everything working.
 

Getting Data

 

If ambd is now running with the GPS NMEA plugin enabled and our GPS device has a fix, you can start getting data.  AMB exposes data over DBus, so we can use standard DBus tools (ie dbus-send) to get the data, or the amb-get helper tools.  To get GPS Location simply type:

amb-get Location

{

  "Zone": 0, 
  "LongitudeSequence": -1, 
  "Altitude": dbus.Double(200.0, variant_level=1), 
  "AltitudeSequence": -1, 
  "Longitude": dbus.Double(-122.958967, variant_level=1), 
  "LatitudeSequence": -1, 
  "Time": dbus.Double(0.0, variant_level=1), 
  "Latitude": dbus.Double(45.541174, variant_level=1)
}
 
If you see something like the above, congrats, you have GPS data!  If not, see the "Debugging" section below.  In addition to amb-get, you can also monitor location data from the console with amb-listen:
 
amb-listen Location
 
{
  "Zone": 0, 
  "LongitudeSequence": -1, 
  "Altitude": dbus.Double(200.0, variant_level=1), 
  "AltitudeSequence": -1, 
  "Longitude": dbus.Double(-122.958967, variant_level=1), 
  "LatitudeSequence": -1, 
  "Time": dbus.Double(0.0, variant_level=1), 
  "Latitude": dbus.Double(45.541174, variant_level=1)
}
{
  "Zone": 0, 
  "LongitudeSequence": -1, 
  "Altitude": dbus.Double(200.0, variant_level=1), 
  "AltitudeSequence": -1, 
  "Longitude": dbus.Double(-122.96430, variant_level=1), 
  "LatitudeSequence": -1, 
  "Time": dbus.Double(100.0, variant_level=1), 
  "Latitude": dbus.Double(45.53809, variant_level=1)
}
 

 

Debugging



If you don't get anything from amb-get/amb-listen there might be a number of reasons.  First, you might want to check if your GPS device has a fix.  You can do this by turning on debug lvl 5 in AMB.

 

nano /lib/systemd/system/ambd.service

EXEC=/usr/bin/ambd -d5 -c /etc/ambd/config.tizen

systemctl restart ambd

Now you should see nmea sentences in journalctl.  If you see a lot of messages that look like this:
$GPRMC,,,,,,,2A*

This type of message with a lot of empty commas often indicates that you do not have a GPS fix.  Check your antenna position or wait a little longer to get a fix.

 

Conclusion



Gps data is an essential part of the modern vehicle experiece.  Whether you are a hobbiest or a system vendor, AMB's GPS NMEA plugin can help provide that data.  As always, if there are comments or questions, post them to the AMB mailing list.