Ubuntu: gpsd and gpsd clients
In the blog Ubuntu: Using a GPS Dongle, you have see how to use a GPS receiver in Ubuntu.
In the previous blog, we have used the GPS receiver by directly reading the information from the /dev entry. Though this approach works fine, remember that only one client can read information from the /dev entry.
gpsd is a service daemon which monitors the GPS receiver connected to your laptop and makes the GPS information to one or more clients. For more details on gpsd, you can refer to http://www.catb.org/gpsd/ link.
Building gpsd from Source:
In this blog, we will check how to download gpsd source, compile gpsd and test gpsd (including the clients).
- Download gpsd from the project page host at http://download.savannah.gnu.org/releases/gpsd/
- Extract the source code using the following command:
tar -xvzf gpsd-3.10.tar.gz
- In order to build gpsd from source, you need have a few other utilities installed on your laptop. In my case, I had to install the following utilities:
sudo apt-get install scons
sudo apt-get install python-dev
sudo apt-get install chrpath
- Now enter the gpsd source directory and enter ‘scons‘ to build gpsd as show below.
- Note that we are not intending to install gpsd on the laptop. We will continue to test gpsd from the source build directory.
- Ensure that your GPS receiver is connected. If required, you can use minicom and check the output from the GPS receiver.
- Enter the following command to start gpsd in debug mode. This very useful to debug any problems that might occur during the communication with the GPS receiver.
sudo env “LD_LIBRARY_PATH=/home/training/friendly_arm_latest/gpsd-3.10” ./gpsd -n -N -D2 /dev/ttyUSB0 -S 2947
- Notice a few things in the above command.
- Since we have not installed gpsd, we have updated the LD_LIBRARY_PATH
- We have opened the /dev/ttyUSB0 device with root permissions using the ‘sudo’ command
- 2947 is the port number on the localhost where the gpsd daemon outputs the GPS information.
- If the above command is successful, gpsd will continue to run and provide the GPS information. You can launch the gpsd clients from another terminal.
gpsd source code contains three clients. The clients are also built when gpsd is built from the source code. You can refer to http://wiki.openstreetmap.org/wiki/Gpsd for a description about the GPS clients.
xgps is a simple test client for gpsd with an X interface. It displays current GPS position/time/velocity information and (for GPSes that support the feature) the locations of accessible satellites.
Here is a snapshot of the xgps application showing the data captured from the GPS receiver on my laptop.
xgpsspeed is a speedometer that uses position information from the GPS.
Here is a snapshot of the xgpspeed application showing the data captured from the GPS receiver on my laptop.
cgps is a client resembling xgps, but without the pictorial satellite display and able to run on a serial terminal or terminal emulator.
Here is a snapshot of the cgps application showing the data captured from the GPS receiver on my laptop.
Note: As mentioned above, we are not intending to install ‘gpsd‘ on the laptop. The purpose of this blog is to compile and install ‘gpsd‘ on the FriendlyARM board.