RXtoRINEX  V2.1
RXtoRINEX provides tools to collect data from GPS / GNSS receivers in mobile devices, convert them to RINEX or RTK formats, and process RINEX files.
Functions
SynchroRX.cpp File Reference
#include "ArgParser.h"
#include "Logger.h"
#include "Utilities.h"
#include "SerialTxRx.h"
#include <thread>
#include <chrono>
#include <stdio.h>

Functions

int main (int argc, char **argv)
 

Detailed Description

Contains the command line program to synchronize receiver and computer to allow reception of GNSS receiver data. The current implementation of is program synchronizes the computer serial port and its connected SiRF IV receiver.

Usage:

SynchroRX.exe {options}

Options are:

Copyright 2015 Francisco Cancillo

This file is part of the RXtoRINEX tool.

RXtoRINEX is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. RXtoRINEX is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. A copy of the GNU General Public License can be found at http://www.gnu.org/licenses/.

Ver. |Date |Reason for change ---—+----—+---------------— V1.0 |2/2015 |First release V1.1 |2/2016 |Minor improvements for logging messages V1.2 |2/2018 |Adapted to new SerialTxRx I/F to set and get port parameters |Reviewed to run on Linux

Function Documentation

int main ( int  argc,
char **  argv 
)

main sets the communication between computer and receiver at the speed and mode requested.

The receiver state is defined by the following:

  • The serial port bit rate, stop bits, and parity it is using
  • The protocol mode it is using to send data: NMEA or OSP
  • If data is flowing from the receiver or not

The computer data acquisition process state is defined by:

  • The serial port (port name) it is using for the communication with the GPS receiver
  • The serial port bit rate, stop bits, parity and mode (raw or not) being used
  • The type of data expected: NMEA or OSP

To allow communication between GPS receiver and computer, states of both elements shall be synchronized according to the needs stated. To synchronize computer and receiver their current states shall be known, and changed if different.

To know the receiver state is necessary to communicate with it, setting first the computer port at the same speed, stop bits and parity that the receiver. This will allow receiving and analyzing the data being generated by the receiver to know the protocol it is using.

As receiver state may be not known initially, it would be necessary to scan at different speeds data being received to identify the protocol.

To allow synchronization it is assumed the following for the receiver:

  • It is providing data continuously, ASCII NMEA or binary OSP messages, depending on the mode.
  • It is receiving/sending data at 1200, 2400, 4800, 9600, 38400, 57600 or 115200 bps, with one stop bit and parity none.

After synchronization, bit rates will be set to 9600 bps when exchanging NMEA data or to 57600 bps when exchanging OSP messages..

Parameters
argcthe number of arguments passed from the command line
argvarray with argument values passed
Returns
the exit status according to the following values and meaning:
  • (0) Receiver protocol mode changed to requested value (OSP or NMEA). Baud rate set accordingly.
  • (1) Error in the command line arguments passed to the program
  • (2) An error occurred when setting computer port parameters, or when sending or reciving data. See log file for details.
  • (3) Unable to change to the protocol mode requested. See log file for details.

The main process sequence follows:

1- Defines and sets the error logger object

2- Setups the valid options in the command line. They will be used by the argument/option parser

3- Parses arguments in the command line extracting options and operators

4- Sets logging level stated in option

5- Gets from option the protocol mode to be used

6 - Checks current computer baud rate

6 - Discover initial receiver mode and baud rate, first look for "most likely" ones:

  • if the computer computer baud rate is not the NMEA or OSP one, set the NMEA rate
  • if computer baud rate is the NMEA one, check if receiver is sending NMEA messages
  • if computer baud rate is the OSP one, check if receiver is sending OSP messages

9- When failed to discover receiver mode at usual baud rates, iterate over all baud rates setting computer port speed and sending NMEA and OSP commands to set its mode to OSP at 57600 bps. Then checks if the current receiver mode has changed to OSP.

10- If the current receiver mode is OSP, but it is wanted to be NMEA, sends a OSP command to change it, and sets computer com speed at NMEAbRate. Then checks if new mode has changed to NMEA.

11- If the current receiver mode is NMEA, but it is wanted to be OSP, sends a NMEA command to change it, and sets computer com speed at OSPbRate Then checks if new mode has changed to OSP.

12- Verify if the resulting current mode is the wanted one, and returns value accordingly