Past operations & data
Communications / Navigation / Tracking
Ship contact info
GPS- AND ECHO SOUNDER LOGGING
On this page... (hide)
Capture of data from echo sounder is achieved by a combined GPS- and echo sounder logging program, running in terminal window under Windows. We searched without success for commercial software that could accomplish this task, so we wrote a small Python script instead. Please notify us if you are aware of similar commercial software.
The program features:
Screenshot of logging program during normal operation is shown below:
Screenshot of combined GPS and Echo sounder logging software.
Ideally, software should be written as a proper Windows program with a Graphical User Interface (GUI). Due to time and personnel constraints this Python program was, however, what we were able to achieve. It might be sufficient for the task at hand.
Software is written in Python language. This language is interpreted - not compiled. Changes can be made in any text editor.
It's possible to make stand-alone executable Python program, alleviating the need to install Python and library modules. Perhaps we have time to look into this later. The drawback is, of course, that you loose the possibility of making changes (fixing bugs) using a simple editor.
In addition to the Python interpreter, two library modules are needed.
If you want to edit the program source code, there is a nice Windows editor called Programmer's Notepad.
If you use a GPS with USB interface, it will appear as a COM-port in the operating system. You might experience problems during this COM-port assignment.
It is most convenient to execute the program within terminal window that has already been opened. Otherwise the terminal window is closed immediately when you hit the <ENTER> key, and log file summary cannot be seen.
It's also convenient to add the directory containing the Python interpreter to the PATH environment variable. Follow these steps:
Control Panel -> System -> Advanced system settings
Select Path, then click Edit, and enter path to Python interpreter as shown. As of May 2010 it has version 2.6, reflected in path name - so this will change with later versions.
Start program by writing, in terminal window
The program will first make an inventory of available COM ports. Next it will try to locate GPS data among these port. It will attempt to read data at three different speeds (4800, 9600 and 19200 bits/s). If valid GPS data is found it makes a similar seach for Echo Sounder serial data.
Screenshot below shows successful detection of both GPS and Echo Sounder COM ports:
Starting the program - identifying GPS and Echo Sounder serial ports.
In the next stage the user has to enter GPS data logging interval. Echo Sounder data is stored continuously (max rate 1 Hz), so there is no need to specify log interval here. User input is vetted and hopefully accepted; the program then needs to capture one valid GPS telegram in order to perform automatic file naming (file name contains year, month, day and time). After that, it enters an eternal logging loop.
Every minute, on the minute, LATITUDE, LONGITUDE and UTC TIME is printed to screen. This provides crew with a convenient method of reading current vessel position and time.
Exit program by hitting <ENTER> key. At program closure a file summary is displayed, as shown below:
Logging halted by hitting the <ENTER> key.
Receiving and merging data from two serial sources that transmits asynchronously is a challenge. There is a plethoria of error scenarios that can be encountered. Errors should of cource be handled according to the degree of severity they represent. They should never cause the program to crash. However, it can be difficult to foresee every possible error condition. Despite being subjected to extensive testing, the software might have vulnerabilities lurking in the shadows. Please send bug reports to ole.meyer at geo.uib.no.
As mentioned in section Normal operation above, the program depends on initially receiving at least one valid GPS telegram in order to determine file name, which will indicate year, month, day and time. If the GPS do not have fix at this stage, the program simply loops until fix is achieved, or you press <ENTER>. That situation is shown in screenshot below.
No initial GPS fix - cannot determine file name - cannot proceed ....
This is actually not an error condition. The Echo Sounder will normally be used on rare occasions. So there will be a COM port available, but it will be quit. If this is the initial situation, program simply monitors port for activity and automatically starts logging of Echo Sounder data, when they appear. If more then one COM port is available for the Echo Sounder, user is asked to specify which one to monitor.
No Echo Sounder data (but free COM port, assumed to belong to Echo Sounder, is present).
If GPS fix is lost when logging has started, logging will continue. Both error messages on screen and audio alarm will seek to draw the crews attention.
Screenshot below shows error messages during loss of GPS fix.
GPS fix lost during logging.
Here's an excerpt from log file:
$SDDPT, 12.34, 0.00*63 @ $GPRMC,120159.000,A,6023.0521,N,00519.8125,E,0.58,115.23,160510,,*05 $SDDPT, 12.46, 0.00*66 @ $GPRMC,120200.000,A,6023.0519,N,00519.8130,E,0.46,82.79,160510,,*3A $SDDPT, 18.43, 0.00*69 @ $GPRMC,120202.000,A,6023.0520,N,00519.8130,E,0.15,76.80,160510,,*39 $GPRMC,120202.000,A,6023.0520,N,00519.8130,E,0.15,76.80,160510,,*39 $SDDPT, 16.75, 0.00*62 @ $GPRMC,120203.000,A,6023.0520,N,00519.8126,E,0.16,146.10,160510,,*07 $SDDPT, 15.07, 0.00*64 @ $GPRMC,120204.000,A,6023.0523,N,00519.8121,E,0.25,89.69,160510,,*38
Echo sounder data contains depth reading with time- and position stamping added. E.g.:
$SDDPT, 12.34, 0.00*63 @ $GPRMC,120159.000,A,6023.0521,N,00519.8125,E,0.58,115.23,160510,,*05
indicates a depth reading of 12.34 meter, with time and position yielded by the $GPRMC GPS telegram:
The $GPRMS telegram is decoded according to description provided here.
GPS track log data and Echo Sounder data can be separated by either AWK (on Linux/Unix platform) or a simple Python script.
It's possible to merge two serial input data streams (this is what we are trying to achieve) using software like [[ | GpsGate}} from Franson. Setup for this scenario is given further down on this page.
The essential idea behind our program is to read GPS data telegrams in an eternal main loop. Reading of Echo Sounder telegrams is performed in a separate thread. Time- and position stamping of Echo Sounder telegrams is achieved by sending them through a "Last-In-First-Out" (LIFO) queue to the main loop. Main loop executes once every second, and Echo Sounder has a repetition rate of 2 seconds, so in theory there should not be any bottlenecks in consuming Echo Sounder data packets. Even so, the programs features mechanisms for handling such a case.
This merging of two asynchronous data streams, and time- and position stamping one of them with data from the other, is a challenging task. The program is designed to handle different error scenarios. It has been subject to long-term testing. If you spot any bugs in the program please notify us.
Click to see software listing:
Click to download Python script logger.py.
For reference: Python program that merges three serial data flows, used for logging of EM data:
From Python thread programming discussion with C.H.:
...If you still want to look into threading there is a need for syncronization: Upon reception of EM data you want to fetch Sonic and GPS data immediately, but you have to ensure that any update of Sonic and GPS data is complete before they are used. In addition, the age of data must be checked, as mentioned.
To achieve syncronization, you can investigate:
In general, searching for "python thread syncronization" get a lot of interesting hits.
Two USB-Serial devices connected: RS422 adapter (to Echo Sounder). and USB-GPS.
Notes on Laptop:
It's assumed that you have already connected GPS to the PC, and that you have verified its proper operation by reading data in terminal program, like TeraTerm
We will use an excellent piece of software for this purpose: GpsGate made by Franson.
First download and install GpsGate. The first time it's started, it enters Wizard mode:
Franson GpsGate, entering Wizard Mode.
GPS Serial port identified.
Summary of GPS output to virtual COM ports.
Running Nav data + Echo Sounder logging program with GPS on several virtual COM ports.
Normal view of GpsGate - Input, Output and Advanced tabs:
Enter licence key by first identifying the GpsGate icon in the task bar. Right-click the icon. A new menu appears; select "Licence key":