From d6c60fd7c4e2d5f892be3730e31f244ab92ec2eb Mon Sep 17 00:00:00 2001 From: juanalfarom Date: Sat, 5 Oct 2024 17:12:40 +0200 Subject: [PATCH] apply suggested changes --- .../telemetry_decoder/adapters/CMakeLists.txt | 9 +- .../gnuradio_blocks/CMakeLists.txt | 9 +- .../gps_l1_ca_telemetry_decoder_gs.cc | 6 +- .../telemetry_decoder/libs/tlm_conf.cc | 1 - .../gps_l1_ca_dll_pll_tracking_gpu_cc.cc | 5 +- src/core/system_parameters/gnss_satellite.cc | 13 +- src/utils/matlab/SBAS_decoder.m | 506 ------------------ 7 files changed, 30 insertions(+), 519 deletions(-) delete mode 100644 src/utils/matlab/SBAS_decoder.m diff --git a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt index 9c0ae28ee..a804a1a86 100644 --- a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt @@ -59,11 +59,16 @@ target_link_libraries(telemetry_decoder_adapters telemetry_decoder_gr_blocks telemetry_decoder_libs PRIVATE - Gflags::gflags - Glog::glog Gnuradio::runtime ) +if(ENABLE_GLOG_AND_GFLAGS) + target_link_libraries(telemetry_decoder_adapters PRIVATE Gflags::gflags Glog::glog) + target_compile_definitions(telemetry_decoder_adapters PRIVATE -DUSE_GLOG_AND_GFLAGS=1) +else() + target_link_libraries(telemetry_decoder_adapters PRIVATE absl::flags absl::log) +endif() + target_include_directories(telemetry_decoder_adapters PUBLIC ${GNSSSDR_SOURCE_DIR}/src/core/interfaces diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index c71184aa8..7c9ff7b83 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -58,11 +58,16 @@ target_link_libraries(telemetry_decoder_gr_blocks Gnuradio::runtime Boost::headers PRIVATE - Gflags::gflags - Glog::glog Gnuradio::pmt ) +if(ENABLE_GLOG_AND_GFLAGS) + target_link_libraries(telemetry_decoder_gr_blocks PRIVATE Gflags::gflags Glog::glog) + target_compile_definitions(telemetry_decoder_gr_blocks PRIVATE -DUSE_GLOG_AND_GFLAGS=1) +else() + target_link_libraries(telemetry_decoder_gr_blocks PRIVATE absl::flags absl::log) +endif() + if(GNURADIO_USES_STD_POINTERS) target_compile_definitions(telemetry_decoder_gr_blocks PUBLIC -DGNURADIO_USES_STD_POINTERS=1 diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc index 05374e1eb..e57aaa354 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_gs.cc @@ -578,7 +578,7 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ } // add new symbol to the symbol queue d_symbol_history.push_back(current_symbol.Prompt_I); - + d_sample_counter++; // count for the processed symbols consume_each(1); d_flag_preamble = false; @@ -684,10 +684,12 @@ int gps_l1_ca_telemetry_decoder_gs::general_work(int noutput_items __attribute__ LOG(WARNING) << "Exception writing observables dump file " << e.what(); } } + // 3. Make the output (move the object contents to the GNU Radio reserved memory) *out[0] = std::move(current_symbol); return 1; } + return 0; -} +} \ No newline at end of file diff --git a/src/algorithms/telemetry_decoder/libs/tlm_conf.cc b/src/algorithms/telemetry_decoder/libs/tlm_conf.cc index ae7e34e47..c66f44ae5 100644 --- a/src/algorithms/telemetry_decoder/libs/tlm_conf.cc +++ b/src/algorithms/telemetry_decoder/libs/tlm_conf.cc @@ -16,7 +16,6 @@ */ #include "tlm_conf.h" -#include void Tlm_Conf::SetFromConfiguration(const ConfigurationInterface *configuration, const std::string &role) diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc index 35ade1c36..ddfcffd4b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc @@ -248,7 +248,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::start_tracking() d_pull_in = true; d_enable_tracking = true; d_acc_carrier_phase_initialized = false; - + LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz << " Code Phase correction [samples]=" << delay_correction_samples << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; @@ -526,7 +526,6 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut tmp_E = std::abs(d_correlator_outs[0]); tmp_P = std::abs(d_correlator_outs[1]); tmp_L = std::abs(d_correlator_outs[2]); - try { // Dump correlators output @@ -589,4 +588,4 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut { return 0; } -} +} \ No newline at end of file diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index 1230d9d3a..c84dbb6ce 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -15,9 +15,13 @@ */ #include "gnss_satellite.h" -#include #include -#include + +#if USE_GLOG_AND_GFLAGS +#include +#else +#include +#endif Gnss_Satellite::Gnss_Satellite(const std::string& system_, uint32_t PRN_) { @@ -561,7 +565,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_ switch (PRN_) { case 1: - block_ = std::string("FOC-FM10"); // Galileo Full Operational Capability (FOC) satellite FM10 / GSAT-0210, launched on May 24, 2016. + block_ = std::string("FOC-FM10"); // Galileo Full Operational Capability (FOC) satellite FM10 / GSAT-0210, launched on May 24, 2016. NOT USABLE. break; case 2: block_ = std::string("FOC-FM11"); // Galileo Full Operational Capability (FOC) satellite FM11 / GSAT-0211, launched on May 24, 2016. @@ -629,6 +633,9 @@ std::string Gnss_Satellite::what_block(const std::string& system_, uint32_t PRN_ case 27: block_ = std::string("FOC-FM17"); // Galileo Full Operational Capability (FOC) satellite FM17 / GSAT0217, launched on Dec. 12, 2017. UNDER COMMISSIONING. break; + case 29: + block_ = std::string("FOC-FM25"); // Galileo Full Operational Capability (FOC) satellite FM25 / GSAT0225, launched on Apr. 28, 2024. UNDER COMMISSIONING. + break; case 30: block_ = std::string("FOC-FM6"); // Galileo Full Operational Capability (FOC) satellite FM6 / GSAT0206, launched on Sept. 11, 2015. break; diff --git a/src/utils/matlab/SBAS_decoder.m b/src/utils/matlab/SBAS_decoder.m deleted file mode 100644 index dae96fd7c..000000000 --- a/src/utils/matlab/SBAS_decoder.m +++ /dev/null @@ -1,506 +0,0 @@ -clear; clc; -% This program decodes the navigation bits obtained from the telemetry -% block for SBAS. The only input required is the filename of the .mat with -% the telemetry output. -% -% The message types available for decoding are: 0, 17, 18, 26 and 27. -% -% Written by Juan Alfaro - -filename = ''; % Path to the telemetry .mat output file. -load(filename) - -% SBAS preamble types -preamble1 = '01010011'; -preamble2 = '10011010'; -preamble3 = '11000110'; - -% Prepare the incoming bit data for the program -bitLog = nav_symbol == 1; - -preLog1 = preamble1 == '1'; -preLog2 = preamble2 == '1'; -preLog3 = preamble3 == '1'; - -preLen = length(preamble1); -preStart = 0; -counter = 0; - -% Main Loop -for i=1:(length(nav_symbol) - preLen + 1) - if all(bitLog(i:i + preLen -1) == preLog1) || all(bitLog(i:i + preLen -1) == preLog2) || all(bitLog(i:i + preLen -1) == preLog3) - if (i+249 <= length(nav_symbol)) - preStart = i; - binMsg = strcat(strjoin(cellstr(char(nav_symbol(preStart:preStart+249) + '0')'),''),'000000'); - check = paritycheck(binMsg); - - if check == 1 - counter = counter +1; - hex = convert2hex(binMsg) - data{counter} = hex; - preamble = dec2hex(bin2dec(binMsg(1:8))); % Preamble bits 0-7 - msgType = bin2dec(binMsg(9:14)); % Message type bits 8-13 - - if msgType == 0 - disp('Message type 0: don`t use for safety applications (for WAAS testing)'); NavData = MT0(binMsg,preamble); - elseif msgType == 17 - disp('Message type 17: satellite almanacs'); NavData = MT17(binMsg,preamble); - elseif msgType == 18 - disp('Message type 18: Ionospheric grid point mask'); NavData = MT18(binMsg,preamble); - elseif msgType == 26 - disp('Message type 26: Ionospheric delay corrections'); NavData = MT26(binMsg,preamble); - elseif msgType == 27 - disp('Message type 27: WAAS Service Message'); NavData = MT27(binMsg,preamble); - else - fprintf('Message type %d not supported! \n', msgType); - end - end - end - end -end - -fprintf('There were found a total of %d messages in %d bits of data. \n', counter, length(nav_symbol)) - - -% Functions -function check = paritycheck(binMsg) - if strcmp(crc24q(binMsg),'000000000000000000000000') && strcmp(binMsg(251:256),'000000')% Check CRC-24 of message (parity) - disp('CRC-24 parity valid!'); - check = 1; - else - disp('CRC-24 parity not valid, error!'); - check = 0; - end -end - -function NavData = MT0(binMsg,preamble) - - NavData.dataID(1) = bin2dec(binMsg(15:16)); % Data ID bits 14-15 (satellite 1) - NavData.dataID(2) = bin2dec(binMsg(82:83)); % Data ID bits 81-82 (satellite 2) - NavData.dataID(3) = bin2dec(binMsg(149:150)); % Data ID bits 148-149 (satellite 3) - %NavData.parity = bin2dec(binMsg(1:250)); - - fprintf('Preamble: %s \n',preamble) - fprintf('Parity: %d \n',0) - fprintf('Data ID sat. 1: %d \n', NavData.dataID(1)); - fprintf('Data ID sat. 2: %d \n', NavData.dataID(2)); - fprintf('Data ID sat. 3: %d \n', NavData.dataID(3)); - - -end - -function NavData = MT17(binMsg,preamble) - - NavData.dataID(1) = bin2dec(binMsg(15:16)); % Data ID bits 14-15 (satellite 1) - NavData.dataID(2) = bin2dec(binMsg(82:83)); % Data ID bits 81-82 (satellite 2) - NavData.dataID(3) = bin2dec(binMsg(149:150)); % Data ID bits 148-149 (satellite 3) - - NavData.PRN(1) = bin2dec(binMsg(17:24)); % PRN bits 16-23 (satellite 1) - NavData.PRN(2) = bin2dec(binMsg(84:91)); % PRN bits 83-90 (satellite 2) - NavData.PRN(3) = bin2dec(binMsg(151:158)); % PRN bits 150-157 (satellite 3) - - NavData.ranging(1) = bin2dec(binMsg(32:32)); % Ranging bits 31-31 (satellite 1) - NavData.ranging(2) = bin2dec(binMsg(99:99)); % Ranging bits 98-98 (satellite 2) - NavData.ranging(3) = bin2dec(binMsg(166:166)); % Ranging bits 165-165 (satellite 3) - - NavData.corrections(1) = bin2dec(binMsg(31:31)); % Corrections bits 30-30 (satellite 1) - NavData.corrections(2) = bin2dec(binMsg(98:98)); % Corrections bits 97-97 (satellite 2) - NavData.corrections(3) = bin2dec(binMsg(165:165)); % Corrections bits 164-164 (satellite 3) - - NavData.broadInteg(1) = bin2dec(binMsg(30:30)); % Broadcast integrity bits 29-29 (satellite 1) - NavData.broadInteg(2) = bin2dec(binMsg(97:97)); % Broadcast integrity bits 96-96 (satellite 2) - NavData.broadInteg(3) = bin2dec(binMsg(164:164)); % Broadcast integrity bits 163-163 (satellite 3) - - NavData.ServProvID(1) = bin2dec(binMsg(25:28)); % Service provider ID bits 24-27 (satellite 1) - NavData.ServProvID(2) = bin2dec(binMsg(92:95)); % Service provider ID bits 91-94 (satellite 2) - NavData.ServProvID(3) = bin2dec(binMsg(159:162)); % Service provider ID bits 158-161 (satellite 3) - - if binMsg(33) == '0' - NavData.Xg(1) = bin2dec(binMsg(33:47))*2600; % Xg ECEF (m) bits 32-46 (satellite 1) - else - NavData.Xg(1) = (bin2dec(binMsg(33:47))-2^15)*2600; - end - - if binMsg(100) == '0' - NavData.Xg(2) = bin2dec(binMsg(100:114))*2600; % Xg ECEF (m) bits 99-113 (satellite 2) - else - NavData.Xg(2) = (bin2dec(binMsg(100:114))-2^15)*2600; - end - - if binMsg(167) == '0' - NavData.Xg(3) = bin2dec(binMsg(167:181))*2600; % Xg ECEF (m) bits 166-180 (satellite 3) - else - NavData.Xg(3) = (bin2dec(binMsg(167:181))-2^15)*2600; - end - - if binMsg(48) == '0' - NavData.Yg(1) = bin2dec(binMsg(48:62))*2600; % Yg ECEF (m) bits 47-61 (satellite 1) - else - NavData.Yg(1) = (bin2dec(binMsg(48:62))-2^15)*2600; - end - - if binMsg(115) == '0' - NavData.Yg(2) = bin2dec(binMsg(115:129))*2600; % Yg ECEF (m) bits 114-128 (satellite 2) - else - NavData.Yg(2) = (bin2dec(binMsg(115:129))-2^15)*2600; - end - - if binMsg(182) == '0' - NavData.Yg(3) = bin2dec(binMsg(182:196))*2600; % Yg ECEF (m) bits 181-197 (satellite 3) - else - NavData.Yg(3) = (bin2dec(binMsg(182:196))-2^15)*2600; - end - - if binMsg(63) == '0' - NavData.Zg(1) = bin2dec(binMsg(63:71))*26000; % Zg ECEF (m) bits 62-70 (satellite 1) - else - NavData.Zg(1) = (bin2dec(binMsg(63:71))-2^9)*26000; - end - - if binMsg(130) == '0' - NavData.Zg(2) = bin2dec(binMsg(130:138))*26000; % Zg ECEF (m) bits 129-137 (satellite 2) - else - NavData.Zg(2) = (bin2dec(binMsg(130:138))-2^9)*26000; - end - - if binMsg(197) == '0' - NavData.Zg(3) = bin2dec(binMsg(197:205))*26000; % Zg ECEF (m) bits 196-204 (satellite 3) - else - NavData.Zg(3) = (bin2dec(binMsg(197:205))-2^9)*26000; - end - - if binMsg(72) == '0' - NavData.Delta_Xg(1) = bin2dec(binMsg(72:74))*10; % Rate of change Xg (m/s) bits 71-73 (satellite 1) - else - NavData.Delta_Xg(1) = (bin2dec(binMsg(72:74))-2^3)*10; - end - - if binMsg(139) == '0' - NavData.Delta_Xg(2) = bin2dec(binMsg(139:141))*10; % Rate of change Xg (m/s) bits 138-140 (satellite 2) - else - NavData.Delta_Xg(2) = (bin2dec(binMsg(139:141))-2^3)*10; - end - - if binMsg(206) == '0' - NavData.Delta_Xg(3) = bin2dec(binMsg(206:208))*10; % Rate of change Xg (m/s) bits 205-207 (satellite 3) - else - NavData.Delta_Xg(3) = (bin2dec(binMsg(206:208))-2^3)*10; - end - - if binMsg(75) == '0' - NavData.Delta_Yg(1) = bin2dec(binMsg(75:77))*10; % Rate of change Yg (m/s) bits 74-76 (satellite 1) - else - NavData.Delta_Yg(1) = (bin2dec(binMsg(75:77))-2^3)*10; - end - - if binMsg(142) == '0' - NavData.Delta_Yg(2) = bin2dec(binMsg(142:144))*10; % Rate of change Yg (m/s) bits 141-143 (satellite 2) - else - NavData.Delta_Yg(2) = (bin2dec(binMsg(142:144))-2^3)*10; - end - - if binMsg(209) == '0' - NavData.Delta_Yg(3) = bin2dec(binMsg(209:211))*10; % Rate of change Yg (m/s) bits 208-210 (satellite 3) - else - NavData.Delta_Yg(3) = (bin2dec(binMsg(209:211))-2^3)*10; - end - - if binMsg(78) == '0' - NavData.Delta_Zg(1) = bin2dec(binMsg(78:81))*60; % Rate of change Zg (m/s) bits 77-80 (satellite 1) - else - NavData.Delta_Zg(1) = (bin2dec(binMsg(78:81))-2^4)*60; - end - - if binMsg(145) == '0' - NavData.Delta_Zg(2) = bin2dec(binMsg(145:148))*60; % Rate of change Zg (m/s) bits 144-147 (satellite 2) - else - NavData.Delta_Zg(2) = (bin2dec(binMsg(145:148))-2^4)*60; - end - - if binMsg(212) == '0' - NavData.Delta_Zg(3) = bin2dec(binMsg(212:215))*60; % Rate of change Zg (m/s) bits 211-214 (satellite 3) - else - NavData.Delta_Zg(3) = (bin2dec(binMsg(212:215))-2^4)*60; - end - - NavData.t0 = bin2dec(binMsg(216:226))*64; % Time of day (s) bits 215-225 - %NavData.parity = bin2dec(binMsg(1:250)); - - fprintf('Preamble: %s \n',preamble) - fprintf('Time of the day: %d s \n',NavData.t0); - fprintf('Parity: %d \n',0) - disp('-----------------------------------') - disp('Satellite [ 1 ]') - fprintf('PRN number: %d \n', NavData.PRN(1)); - fprintf('Data ID: %d \n', NavData.dataID(1)); - fprintf('Ranging: %d \n',NavData.ranging(1)) - fprintf('Corrections: %d \n', NavData.corrections(1)); - fprintf('Broadcast integrity: %d \n', NavData.broadInteg(1)); - fprintf('Service provider ID: %d \n', NavData.ServProvID(1)); - - fprintf('Xg (ECEF): %d m \n',NavData.Xg(1)); - fprintf('Yg (ECEF): %d m \n',NavData.Yg(1)); - fprintf('Zg (ECEF): %d m \n',NavData.Zg(1)); - - fprintf('Xg rate-of-change: %d m/s \n',NavData.Delta_Xg(1)); - fprintf('Yg rate-of-change: %d m/s \n',NavData.Delta_Yg(1)); - fprintf('Zg rate-of-change: %d m/s \n',NavData.Delta_Zg(1)); - - disp('-----------------------------------') - disp('Satellite [ 2 ]') - fprintf('PRN number: %d \n', NavData.PRN(2)); - fprintf('Data ID: %d \n', NavData.dataID(2)); - fprintf('Ranging: %d \n',NavData.ranging(2)) - fprintf('Corrections: %d \n', NavData.corrections(2)); - fprintf('Broadcast integrity: %d \n', NavData.broadInteg(2)); - fprintf('Service provider ID: %d \n', NavData.ServProvID(2)); - - fprintf('Xg (ECEF): %d m \n',NavData.Xg(2)); - fprintf('Yg (ECEF): %d m \n',NavData.Yg(2)); - fprintf('Zg (ECEF): %d m \n',NavData.Zg(2)); - - fprintf('Xg rate-of-change: %d m/s \n',NavData.Delta_Xg(2)); - fprintf('Yg rate-of-change: %d m/s \n',NavData.Delta_Yg(2)); - fprintf('Zg rate-of-change: %d m/s \n',NavData.Delta_Zg(2)); - - disp('-----------------------------------') - disp('Satellite [ 3 ]') - fprintf('PRN number: %d \n', NavData.PRN(3)); - fprintf('Data ID: %d \n', NavData.dataID(3)); - fprintf('Ranging: %d \n',NavData.ranging(3)) - fprintf('Corrections: %d \n', NavData.corrections(3)); - fprintf('Broadcast integrity: %d \n', NavData.broadInteg(3)); - fprintf('Service provider ID: %d \n', NavData.ServProvID(3)); - - fprintf('Xg (ECEF): %d m \n',NavData.Xg(3)); - fprintf('Yg (ECEF): %d m \n',NavData.Yg(3)); - fprintf('Zg (ECEF): %d m \n',NavData.Zg(3)); - - fprintf('Xg rate-of-change: %d m/s \n',NavData.Delta_Xg(3)); - fprintf('Yg rate-of-change: %d m/s \n',NavData.Delta_Yg(3)); - fprintf('Zg rate-of-change: %d m/s \n',NavData.Delta_Zg(3)); - -end - -function NavData = MT18(binMsg,preamble) - - NavData.Nbands = bin2dec(binMsg(15:18)); % Number of bands being broadcast bits 14-17 - NavData.BandNumber = bin2dec(binMsg(19:22)); % Band number bits 18-21 - NavData.IODI = bin2dec(binMsg(23:24)); % Issue of data - Ionosphere bits 22-23 - NavData.IgpMask = binMsg(25:255) == '1'; % Igp Mask bits 24-224 (logic) - %NavData.parity = bin2dec(binMsg(1:250)); - - fprintf('Preamble: %s \n',preamble) - fprintf('Parity: %d \n',0) - fprintf('Number of bands being broadcast: %d \n', NavData.Nbands); - fprintf('Band number: %d \n', NavData.BandNumber); - fprintf('Issue of data - Ionosphere: %d \n',NavData.IODI) - disp('Igp Mask: LOGIC ARRAY'); - - -end - -function NavData = MT26(binMsg,preamble) - - idxIGP = [23, 31, 36, 44, 49, 57, 62, 70, 75, 83, 88, 96, 101, 109, 114, 122, 127, 135, 140, 148, 153, 161, 166, 174, 179, 187, 192, 200, 205, 213]; - idxGIVEI = [32, 35, 45, 48, 58, 61, 71, 74, 84, 87, 97, 100, 110, 113, 123, 126, 136, 139, 149, 152, 162, 165, 175, 178, 188, 191, 201, 204, 214, 217]; - NavData.BandNumber = bin2dec(binMsg(15:18)); % Band number bits 14-17 - NavData.BlockID = bin2dec(binMsg(19:22)); % Block ID bits 18-21 - NavData.IODI = bin2dec(binMsg(218:219)); % Issue of data - Ionosphere bits 217-218 - %NavData.parity = bin2dec(binMsg(1:250)); - - counter = 1; - for i = 1:15 - NavData.GIVEI(i) = bin2dec(binMsg(idxGIVEI(counter):idxGIVEI(counter+1))); - NavData.IGP(i) = bin2dec(binMsg(idxIGP(counter):idxIGP(counter+1)))*0.125; - counter = counter +2; - end - - - fprintf('Preamble: %s \n',preamble) - fprintf('Parity: %d \n',0) - fprintf('Band number: %d \n', NavData.BandNumber); - fprintf('Block ID: %d \n',NavData.BlockID) - fprintf('Issue of data - Ionosphere: %d \n',NavData.IODI); - for i = 1:15 - fprintf('Satellite IGP [ %d ]: ',i+15*NavData.BlockID) - fprintf('Grid Ionospheric Vertical Error Index: %d \t',NavData.GIVEI(i)) - fprintf('IGP Vertical Delay Estimate: %fm \n',NavData.IGP(i)); - end - -end - -function NavData = MT27(binMsg,preamble) - - idxcoor1lat = [37 44 72 79 107 114 142 149 177 184]; - idxcoor1lon = [45 53 80 88 115 123 150 158 185 193]; - idxcoor2lat = [54 61 89 96 124 131 159 166 194 201]; - idxcoor2lon = [62 70 97 105 132 140 167 175 202 210]; - idxregshape = [71 106 141 176 211]; - - NavData.IODS = bin2dec(binMsg(15:17)); % IODS bits 14-16 - NavData.NumSerMsg = bin2dec(binMsg(18:20))+1; % Number of service messages bits 17-19 - NavData.SerMsgNum = bin2dec(binMsg(21:23))+1; % Service message number bits 20-22 - NavData.NumReg = bin2dec(binMsg(24:26)); % Number of regions bits 23-25 - NavData.PrioCode = bin2dec(binMsg(27:28)); % Priority Code bits 26-27 - NavData.dUDREin = bin2dec(binMsg(29:32)); % delta UDRE indicator inside bits 28-31 - NavData.dUDREout = bin2dec(binMsg(33:36)); % delta UDRE indicator outside bits 32-35 - %NavData.parity = bin2dec(binMsg(1:250)); - - if NavData.NumReg > 0 - counter = 1; - for i = 1:NavData.NumReg - NavData.coor1lat(i) = bin2dec(binMsg(idxcoor1lat(counter):idxcoor1lat(counter+1))); - NavData.coor1lon(i) = bin2dec(binMsg(idxcoor1lon(counter):idxcoor1lon(counter+1))); - NavData.coor2lat(i) = bin2dec(binMsg(idxcoor2lat(counter):idxcoor2lat(counter+1))); - NavData.coor2lon(i) = bin2dec(binMsg(idxcoor2lon(counter):idxcoor2lon(counter+1))); - NavData.regShape(i) = bin2dec(binMsg(idxregshape(i):idxregshape(i))); - counter = counter +2; - end - end - - - fprintf('Preamble: %s \n',preamble) - fprintf('Parity: %d \n',0) - fprintf('IODS: %d \n', NavData.IODS); - fprintf('Number of service messages: %d \n',NavData.NumSerMsg) - fprintf('Service message number: %d \n',NavData.SerMsgNum); - fprintf('Number of regions: %d \n',NavData.NumReg) - fprintf('Priority Code: %d \n', NavData.PrioCode); - fprintf('Delta UDRE indicator inside: %d \n',NavData.dUDREin) - fprintf('Delta UDRE indicator outside: %d \n',NavData.dUDREout); - % for i = 1:5 - % fprintf('Satellite IGP [ %d ]: ',i+15*NavData.BlockID) - % fprintf('Grid Ionospheric Vertical Error Index: %d \t',NavData.GIVEI(i)) - % fprintf('IGP Vertical Delay Estimate: %fm \n',NavData.IGP(i)); - % end - -end - -function [parity] = crc24q(msg) - - % SYNTAX: - % [parity] = crc24q(msg); - % - % INPUT: - % msg = binary message - % - % OUTPUT: - % parity = crc parity (24 bits) - % - % DESCRIPTION: - % Applies CRC-24Q QualComm algorithm. - - %---------------------------------------------------------------------------------------------- - % goGPS v0.4.3 - % - % Copyright (C) 2009-2014 Mirko Reguzzoni, Eugenio Realini - % - % ('rtcm3torinex.c', by Dirk Stoecker, BKG Ntrip Client (BNC) Version 1.6.1 - % was used as a reference) - %---------------------------------------------------------------------------------------------- - % - % This program 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. - % - % This program 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. - % - % You should have received a copy of the GNU General Public License - % along with this program. If not, see . - %---------------------------------------------------------------------------------------------- - - parity = uint32(0); - - %check the length of the input string, in case make it splittable byte-wise - remainder = rem(length(msg),8); - if (remainder ~= 0) - fill = char(ones(1,8-remainder)*48); %fill string of zeroes - msg = [fill msg]; - end - - Nbits = length(msg); - - %pre-allocate to increase speed - Nbytes = Nbits / 8; - bytes = cell(1,Nbytes); - k = 1; - for j = 1 : 8 : Nbits - bytes{k} = msg(j:j+7); - k = k + 1; - end - %call 'fbin2dec' and 'bitshift' only once (to optimize speed) - bytes = bitshift(fbin2dec(bytes), 16); - bytes = uint32(bytes); - for i = 1 : Nbytes - parity = bitxor(parity, bytes(i)); - for j = 1 : 8 - parity = bitshift(parity, 1); - if bitand(parity, 16777216) - parity = bitxor(parity, 25578747); - end - end - end - - parity = dec2bin(parity, 24); -end - -function x=fbin2dec(s) - %FBIN2DEC (fast bin2dec) Convert binary string to decimal integer. - % X = FBIN2DEC(B) interprets the binary string B and returns in X the - % equivalent decimal number. It is a stripped version of "bin2dec", with - % a minimal check on input. - % - % If B is a character array, or a cell array of strings, each row is - % interpreted as a binary string. - % - % Example - % fbin2dec('010111') returns 23 - - %---------------------------------------------------------------------------------------------- - % goGPS v0.4.3 - % - % Copyright (C) 2009-2014 Mirko Reguzzoni, Eugenio Realini - %---------------------------------------------------------------------------------------------- - % - % This program 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. - % - % This program 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. - % - % You should have received a copy of the GNU General Public License - % along with this program. If not, see . - %---------------------------------------------------------------------------------------------- - - % handle input - s = char(s); - - [m,n] = size(s); - - % Convert to numbers - v = s - '0'; - twos = pow2(n-1:-1:0); - x = sum(v .* twos(ones(m,1),:),2); -end - -function hexStr = convert2hex(binMsg) - % Convertir la cadena binaria a hexadecimal - hexStr = ''; - for i = 1:4:length(binMsg) - % Tomar grupos de 4 bits - binSegment = binMsg(i:i+3); - % Convertir el segmento binario a decimal - decValue = bin2dec(binSegment); - % Convertir el valor decimal a hexadecimal y concatenar - hexStr = [hexStr, dec2hex(decValue)]; - end -end \ No newline at end of file