From 7adcd86c990e37f8dcf3b92394928d0ccc296204 Mon Sep 17 00:00:00 2001 From: juanalfarom Date: Sun, 29 Sep 2024 20:58:06 +0200 Subject: [PATCH] SBAS-telemetry decoder matlab file+code organization --- .../dll_pll_veml_tracking.cc.o | Bin 306304 -> 306304 bytes .../gnuradio_blocks/libtracking_gr_blocks.a | Bin 2366978 -> 2366978 bytes cmake/src/main/gnss-sdr | Bin 13805888 -> 13805888 bytes cmake/src/tests/control_thread_test | Bin 14358168 -> 14358168 bytes cmake/src/tests/flowgraph_test | Bin 13181696 -> 13181696 bytes cmake/src/tests/gnss_block_test | Bin 13161680 -> 13161680 bytes cmake/src/tests/run_tests | Bin 17794344 -> 17794344 bytes cmake/src/tests/trk_test | Bin 12977776 -> 12977776 bytes cmake/src/utils/front-end-cal/front-end-cal | Bin 13238112 -> 13238112 bytes .../gnuradio_blocks/dll_pll_veml_tracking.cc | 7 +- src/utils/matlab/SBAS_decoder.m | 506 ++++++++++++++++++ 11 files changed, 507 insertions(+), 6 deletions(-) create mode 100644 src/utils/matlab/SBAS_decoder.m diff --git a/cmake/src/algorithms/tracking/gnuradio_blocks/CMakeFiles/tracking_gr_blocks.dir/dll_pll_veml_tracking.cc.o b/cmake/src/algorithms/tracking/gnuradio_blocks/CMakeFiles/tracking_gr_blocks.dir/dll_pll_veml_tracking.cc.o index 59b59046860eca14778f0b0ff9d6a9dc5a749b40..cf417085ca10f6fb3699447a73646a5311fd70d9 100644 GIT binary patch delta 28 icmZp;Db#RNXoLAdMwVuagY6av8G)E-yTw6fkJkXMYzyfC delta 28 icmZp;Db#RNXoLAdM#g4~gY6av8G)E-yTw6fkJkXMHVfte diff --git a/cmake/src/algorithms/tracking/gnuradio_blocks/libtracking_gr_blocks.a b/cmake/src/algorithms/tracking/gnuradio_blocks/libtracking_gr_blocks.a index 92945c36a644e8d95de76d324a85cd3530e78f9e..3beeb7ced5e82231d08bb7e257636be0ce681533 100644 GIT binary patch delta 155 zcmWm0$q9o%063cXx{&pbrDP6&q2pyIWMm?!fL=EKo5}p9Lldhl4kN!-MN# zXEwj6ATpoq>_BYZ-@5UcNx!3l$$yGd5({%8qJL$jhXNU)Ko}+X|8OFRB#M%hqBLbF zOEl#uPX#Jci5Oz3Ockn9jq22(Cbg(d9qLk#`ZS;+jc800n$nEsw4f!eXiXd1(vJ3Y zpd+1fLxH%Mgs||8;$R$|=|We!(VZUjq!+#ELp%xer5`~O>CXTLGKeGwGlZcGV>lxi z$tXrMhOvxeJQJ8mGLx9h6s9tb>C7O7nWQp{*~}r0xy)le3s}e^7PEw-V?7(#$R;+kg{^EOo$c&kCmHM_liloLFZ>6LQGqDbILL9xr&wD_)b&8{YDc d5bycGM?UeH0t)%USHAI`ANl}(83t!%PaB-xVBN=7+%{W+c=-rXxG zEeb6lCnpeDn3a%SlJO@qD!Mo|JS;CICi!n}S}>3v41`dQ|1VDkLa9h4!l+CY!l_C% zs#AlS)FOgNYEy^0)T2HPXhUm&M1@gP!!FH+|?!Kl(F(fea#!!3-gup$ua&aK$t-3whq=sSJ_}e#0*gpwF-urV63bZ53X(}-C97D?8rHIo^=x1xo7hY$ zTiD7rwzGqs>|!^2NMkSi*iSkKI7kMEILr}_a*X4g;3TIw%^A*ej`L)a#RV>MiOXE! zD%ZHq4YIk(EpBs%yWHbG4|vEU9+Sfpo|4Nm@_0@@FL=o-Uh{^xyyHCue4vnz1o^~g ZzVMZA6!D#6e(;lD{H7$oEWR`;@gD)Nv9$mI diff --git a/cmake/src/tests/control_thread_test b/cmake/src/tests/control_thread_test index 0ca57d4277071978822f31b85514686983c2e0aa..a4101ec91f999bd5b0c6a432bf1792ef3821e3b4 100755 GIT binary patch delta 917 zcmWm0WpfSy007{dccvMpJ2u@lV`{p)W2U<%r)MUod3CojjOl!JcbuQ#`~!C$AD+7> znE5**NLE%LD)G<6TN#ltGop(mr^NqF`xQ*6{~$FKNDl?V$i@GMlbZh zL}7{$Nl}VXoG40Al2VkW3}q=tc`8tmN>ru_RjEdGqKTmfHK|2y>QI+@)TaRrX+&e1 z(3EC0rv!nJ#pt8{O$aPkPatKJ=v@ z{TaYO1~Hf+3}qO@8Nov*~>ombAW>! z;xI=z$}x^}f|H!$G-o)=InHx|OfGVXEG~0}t7LPH>*R2Qo800yceu+v?(=|$JmN7S np74}sJm&>3dBtnq@RoPH=K~-4#Am+nm2Z6KM^0?g&&2G1Cd+Y^ delta 917 zcmWm0)lL-v007Y8wL7r8uoWAz#qMql><(-(5wQ~$yIT|i#m;LWHnz{cxw-iT9v{wj zl2d-?O(r!p5SsKhET>3ZboSr$xU^s42~j_TS%2b#fy7`Sgk1c8Zt{?qeB`G91t~;f zicpkd6sH6wDMcuyDMMMxQJxA^q!N{>LRG3!of_1n7PSeZ4t1$VeHze^Ml_}g;WVWg z&1pePTG5&a+GGX;k+I`KLJ}ilB56xI+S7rKbfPm|h@vaq=uQuM(u>~op)dXD&j1E8 zh`|hDD8m@e2u3oB(Trg%(Trm}6PQR0lbFmDrZSD`%wQ(7n9UsKGLQKzU?H(AVlhit z$}*O-f|bOviq))PE$diMJR3-0BZ+KcGh5ioHny{ao$O*ad)P}7``FI`k~zpB4s(Q~ z9OF1AILRqabB42=<2)C*$R#dwg%qxGja06aMmibX;3k>e;x>1<%RTP%fQLNdF;93( okY_yS1ux0s71_Mz4R3kJdp_`y96s@xFMQ=2-!mg(eoV;t2UUf1e*gdg diff --git a/cmake/src/tests/flowgraph_test b/cmake/src/tests/flowgraph_test index 3115c858b08802e40aa195677c24c098f04e1a99..a1875c4f3b7b111e86874c369c7d6457d955240d 100755 GIT binary patch delta 845 zcmWm0WqS+&007`;Zl?QmH=B;>7*5x8Oy_hvQ^&X)Gu<6yOpW1m-i9CGqaUz;;q~Et zo;Olnm=d9+BoHi)7Ucx3>qQ3o?Iam6hct0v8W5x*jc800n$nEsw4f!eXiXd1(vJ3Ypd+2=Oc%P6N*dkhP7iw0i{A91 zFa78rPXy9SGm?^H;ZQmQ7|0+7GlZcGV>lxiNd}`B%@{(AWgO#~z(gi7nJG+V8q>*S z1~Zw(Z00bRdCX@43&~;;i&?@_ma&`_tYj6dS;JbgS;u-du#rt{W(!-{#&&kFlU?j4 z%pP*s%RcsVfP+Lh#9?wd!cn5c$m1Bt$>#(Goa7XzIm21bah?lYUG7oHeI8K6LmpAgW1jGoXFR8b7rdmDSG?v8ao+Nd_k7?ZpZLrdzVeOl{2)OY N<@}6?L%;I={sSe0V@Ci0 delta 845 zcmWm0MOza9007W$4pHpD4(#s0R#1nD-GSXL#%u%?4D7}hvE2l9c24x@(Tn~MZaxq1 z`(93Yabgb9XfXM2Bqb|5DYv5HS7A{?W=6^HNVGIB9?Xvi161Pw6R1ogRj5i5)u>Jl zYEp~Z)S)i*s82EtXh7rN4o?)0E1z35FJ z`qGd7v3M}GEIkm&4~J42z(58um>~>h7{eJs8tIH=6r%}|!5GFej`2)jBAHBLGEWU+|FEMY0jSk4MovWnHLVJ+)e&jvQKiOptvecrS%)H-ep})Vf@=FRr@jy5pNT3q`pGakrs6th$kxX@J zP?K8JrVe$fM}1OgKtmeQm{iheLQ~RdMsr%wl2){)4Q**hdpgjOPIRUVUCE#u-RVJ3 zGU-KDc|4FEElx-b2P4_^rVoATM}Gz|kUF`or2WD$#5!cvy8oD~FF$tqT}hPA9?Jsa3aKAYIg7PeBr zHny{ao$O*ah3sK3``Ay20~AqAn1dW5!eNeZlw*`|oD-bn6sI}ES3Dd!chdBa=Y@tzNSl007`~U1qw*bWZo!#Kf4K8ZM@rtC{ZE*yZZ(oSK}xn0CeEet=qo3vOwm|k2I2t>lsbo$Vje)K1U0SsgigUMtFL&;(o!x_OyMlqUf#xRy~jAsHl zOk@(12{DDKOe2@+%wQ(7n9UsKGLQKzU?GcG%o3IoW*N&_!Ae%Knl-Ft9eJ#00~^`I zX11`EZER-;JK4o<^4UWHh3sV?MMT)o0iqn_5QjO!QI2t(6P)A}r#Zt}&T*a#T;vj$ zxx!Vhah)3!bCX-#<_>o$;U4#Sz(XGKm{OkblxIBW1uu#5ir2iMjJLewJsBnjGX8@;@&KaD^S)9#425}DOavp;j!cflV0xskt zGRWj&F5yy!F`Ub|oGTc?NJcT5D;dL8T+LXr7{@h?=UT2~0@pKGm}}&W)ArjFqcA#n8za&Q$i_^ z)-{F88Vf^_`31#gJjUac^8`=w6i@RE&r-pB7O;>?7V#X<^8$-m!cwYOMm5W+VFfR; zl3HHkWnSS`USkz?tY!^sd7U>{M?DR!X9I82NE2`IHt+B*@9{p(e87i%#K(NXr+h{W zpYsJ9`I1evvY9P>#n*hpw|vL6e>gw~|MFi^L2;;rAQ3^rK_Y`h1&Iz46C^fBT#)!62|*HrB!wCZijzZ??f(NH CH68E( delta 1139 zcmWm0d3e?X0KoC*-Mh0LsD+wqlpHzILAgRYB$1?)N`+FH}{)ewMxjb5R1k- zRO{GiZ=1?lp~DzChFpt^4&E}YK=bfp^?auFAE3768H%eb5?=)slr zq!+#E!&UUjO$=oiH#3|OjN}$ZF`6;l%5B`vSjKS& zdqKXL*k2DPb`$@FFj6ud$3W zUgr(USDH!bmh!M3A^3;UMur5`rWKNeYr2Bqd0*AgMvpf~1G4BGHUcNz?x; CWFFN3 diff --git a/cmake/src/tests/trk_test b/cmake/src/tests/trk_test index e034d0d13e9b482c56c79a700d329388bfd1162d..a15e2d553feacb73a3ca4538d78f83a88e0ec5ed 100755 GIT binary patch delta 833 zcmWm0S62-H007{Vo3e%MjLhtvO$e9FjI7As6xrLwHL_PW*|TfjxMr^77kKvQwO4OG z58pXoRY_@56_H3Fwc>AKW?FH2e)6B+Wxt9FDu0&e<%Z&ca6FJeHU2-5>Lig&4Qf)0 z+SH*g^{7t@4QNOsQfW*Rn$nEsw4fzvw4ya_XiGZnXio<^(uvMw(1osaqdPt5NiTZS zhraZqKLf~QAcGjp5QZ|0;f!EpG#$y z!A)*)n>&(@NS7aQ?-a^@Xi);>OWRtRYwlfcBJHNv>pZf)PeR!Ye ztt=@^sw5f>rj{1xmuI9D=KcMX_+3%(D=n)^dQmtLj3j~qs`CHUs7?|!s7WnqQ-`|L zqdv(rpdpP&A(h6Y(S)Wnqd6^TNh?~@hPI^Bj`n2GfsS+{lg@OZE8XZ$7Cq=mFM895 zzVxF%0~p941~Y`A3}ZMWVu@gOI2H&*Lh)=yGKw5VGlsE@BgA+nkjq5!n8akJFqLUc zX9hEw#cbvom?bP_8OvG0N>;I&HLPVF>)F6YHnEv4Y-JloY-b0> z>|__a*~4D;v7ZARB+MZWbA$*-ImU5LP{K)0ahfxnAL>c8=<_cH2#&vFR zlUv;84tKf7eJXgsLmu&%Cp_gD&x!Jam%QRNZ+J_Lcf98VaX#{i&wSx4-}ufC60uPH HXJ+m{yXb(B diff --git a/cmake/src/utils/front-end-cal/front-end-cal b/cmake/src/utils/front-end-cal/front-end-cal index 91d4bfd46ae67dc858d51e9a16bc3d197157f577..235036a39a2684cda968e909bc0a2363bed80d45 100755 GIT binary patch delta 686 zcmWm0<#q@F7=Yn3W4foOyJNcBtGjc$yPJ7UcQf5NF;kOM$4%@GTmT23AI~{Y{-0Y( z`5`MSG5KQ7%U>sdq@-jvy_3-FXKwvYN7GW%^Aa=i5)(p!@c#uvp^y{`ha#b9C>Dx` z5}{-$6-tLPp=>A@%7^4oAyf>NLgi2;R1MWaN~j)cgqopNs2%Erx}jdE9~y*)p;2g@ zlb6^e{dYn^X)4X6xwMd$(n?xO8%dS6(oWh-2k9uCq_cF9uF_4qOAqNOy`;DFk-pMT z`pW=82Ff5AEJI|d43pt9LPp9c87*UEtc;WKGC?NFB$+HzWU5S)=`usoWTwoL*)m7w z$~>7b3uK`zlEtz_mdY|&E-PfEtdiBTM%KzYSuY!8qimARvPHJaHrXyaWT&LdE>U(% zhU}5OvQPHQ0XZm#o1c zOK!^@xhwbNzC4hJ@<_7eu{@Ed@=UVjx#Y+Tc`2{twY-sBc`NVay?l_5@=5aKvwV@S L@-3V1mH++&jrAG4 delta 686 zcmWm0Rd)yg7=U3j-7(#5rn@^{-KM*{nYMXNcbkrB6EmGt|6&(@hJ(+=bIw!nC%afd z$jM1eT3T(@)~sLeP9_&hOX-}Rk-Bnih4mTviJAF{388TK|01DiC>Dx`5}{-$6-tLP zp=>A@%7+S}VyF}U3y4Q=_S3TkMxy((q9J1Kp7;1 zWr!d{Wta??5i(Ln$!HlPV`ZF-mkBaaCP}JHmMJn-rpa`fAv0x`%$7MaSLVrlSs)8# zkt~)avQ(DIa#%3jHo zeX?H;$U!+IhvkSIm1A;TPRL0)C8y<#oRxEOUM|Q*$&yQQS+2-cxhB`;hTN1}a$B<@=TX`q%<%4{bPx4v5NWOfPZ}MG! J(GPS_CA_PREAMBLE_LENGTH_SYMBOLS); d_secondary_code_string = GPS_CA_PREAMBLE_SYMBOLS_STR; - d_symbols_per_bit = 1;//GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; + d_symbols_per_bit = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; } else if (d_signal_type == "2S") { @@ -1932,11 +1932,6 @@ int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused) d_state = 4; } } - // SBAS addons - current_synchro_data = *d_acquisition_gnss_synchro; - current_synchro_data.Prompt_I = d_Prompt->real(); - current_synchro_data.Prompt_Q = d_Prompt->imag(); - current_synchro_data.Flag_valid_symbol_output = true; } break; } diff --git a/src/utils/matlab/SBAS_decoder.m b/src/utils/matlab/SBAS_decoder.m new file mode 100644 index 000000000..dae96fd7c --- /dev/null +++ b/src/utils/matlab/SBAS_decoder.m @@ -0,0 +1,506 @@ +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