From 8c48b80e8b7f741a40f7395939013a59222c0398 Mon Sep 17 00:00:00 2001
From: Carles Fernandez <carles.fernandez@gmail.com>
Date: Sat, 24 Nov 2018 23:43:48 +0100
Subject: [PATCH] Fix value

---
 .../galileo_navigation_message.cc             |  2 +-
 .../gps_cnav_navigation_message.cc            |  2 +-
 .../gps_navigation_message.cc                 |  2 +-
 src/utils/rinex2assist/README.md              | 34 +++++++++++++++++++
 4 files changed, 37 insertions(+), 3 deletions(-)
 create mode 100644 src/utils/rinex2assist/README.md

diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc
index 25a8fc241..e94179e1b 100644
--- a/src/core/system_parameters/galileo_navigation_message.cc
+++ b/src/core/system_parameters/galileo_navigation_message.cc
@@ -306,7 +306,7 @@ int64_t Galileo_Navigation_Message::read_navigation_signed(std::bitset<GALILEO_D
     // read the MSB and perform the sign extension
     if (bits[GALILEO_DATA_JK_BITS - parameter[0].first] == 1)
         {
-            value ^= 0x0FFFFFFFFFFFFFFFLL;  // 64 bits variable
+            value ^= 0x3FFFFFFFFFFFFFFFLL;  // 64 bits variable
         }
     else
         {
diff --git a/src/core/system_parameters/gps_cnav_navigation_message.cc b/src/core/system_parameters/gps_cnav_navigation_message.cc
index 02e622fdc..4e1e4ca79 100644
--- a/src/core/system_parameters/gps_cnav_navigation_message.cc
+++ b/src/core/system_parameters/gps_cnav_navigation_message.cc
@@ -115,7 +115,7 @@ int64_t Gps_CNAV_Navigation_Message::read_navigation_signed(std::bitset<GPS_CNAV
     // read the MSB and perform the sign extension
     if (bits[GPS_CNAV_DATA_PAGE_BITS - parameter[0].first] == 1)
         {
-            value ^= 0x0FFFFFFFFFFFFFFFLL;  // 64 bits variable
+            value ^= 0x3FFFFFFFFFFFFFFFLL;  // 64 bits variable
         }
     else
         {
diff --git a/src/core/system_parameters/gps_navigation_message.cc b/src/core/system_parameters/gps_navigation_message.cc
index 9292aa7d3..6fe1e05e1 100644
--- a/src/core/system_parameters/gps_navigation_message.cc
+++ b/src/core/system_parameters/gps_navigation_message.cc
@@ -203,7 +203,7 @@ int64_t Gps_Navigation_Message::read_navigation_signed(std::bitset<GPS_SUBFRAME_
     // read the MSB and perform the sign extension
     if (bits[GPS_SUBFRAME_BITS - parameter[0].first] == 1)
         {
-            value ^= 0x0FFFFFFFFFFFFFFFLL;  // 64 bits variable
+            value ^= 0x3FFFFFFFFFFFFFFFLL;  // 64 bits variable
         }
     else
         {
diff --git a/src/utils/rinex2assist/README.md b/src/utils/rinex2assist/README.md
new file mode 100644
index 000000000..bc3246374
--- /dev/null
+++ b/src/utils/rinex2assist/README.md
@@ -0,0 +1,34 @@
+Rinex2assist
+------------
+
+This program generates ephemeris XML files from RINEX navigation data files. The usage is as follows:
+
+```
+$ rinex2assist /path/to/RINEX_nav_file 
+```
+
+The argument is mandatory (the name of the RINEX navigation file). The name `gps_ephemeris.xml` is given to the output if GPS NAV data is fould. If the RINEX file contains Galileo data, the corresponding `gal_ephemeris.xml` file will be generated. The program is also able to extract parameters of the UTC and the Ionospheric models from the RINEX header, if available. They will be called `gps_utc_model.xml`, `gps_iono.xml`, `gal_utc_model.xml` and `gal_iono.xml`.
+
+
+The program accepts either versions 2.xx or 3.xx for the RINEX navigation data file.
+
+There are some servers available for downloading RINEX navigation files. For instance:
+  * NASA: [ftp://cddis.gsfc.nasa.gov/pub/gnss/data/hourly/](ftp://gssc.esa.int/gnss/data/hourly/)
+  * ESA: [ftp://gssc.esa.int/gnss/data/hourly/](ftp://gssc.esa.int/gnss/data/hourly/)
+
+Just make sure to pick up a [station near you](http://gpspp.sakura.ne.jp/gmap/igsnet.htm).
+
+An example of GNSS-SDR configuration using ephemeris and UTC and ionospheric model parameters for GPS L1 and Galileo signals is shown below:
+
+```
+GNSS-SDR.AGNSS_XML_enabled=true
+GNSS-SDR.AGNSS_ref_location=41.39,2.31
+GNSS-SDR.AGNSS_gps_ephemeris_xml=gps_ephemeris.xml
+GNSS-SDR.AGNSS_gps_iono_xml=gps_iono.xml
+GNSS-SDR.AGNSS_gps_utc_model_xml=gps_utc_model.xml
+GNSS-SDR.AGNSS_gal_ephemeris_xml=gal_ephemeris.xml
+GNSS-SDR.AGNSS_gal_iono_xml=gal_iono.xml    
+GNSS-SDR.AGNSS_gal_utc_model_xml=gal_utc_model.xml
+```
+
+More info about the usage of AGNSS data [here](https://gnss-sdr.org/docs/sp-blocks/global-parameters/#assisted-gnss-with-xml-files).