rs1729 / RS

radiosonde decoding
GNU General Public License v3.0
170 stars 56 forks source link

PTU not printed in JSON in silent mode #35

Closed danijelt closed 3 years ago

danijelt commented 3 years ago

I noticed that decoder demod/mod/rs41mod.c doesn't print PTU in JSON in silent mode, because both getting the PTU data and printing it in non-JSON mode is handled in the same if block.

It can be easily fixed with this patch:

diff --git a/demod/mod/rs41mod.c b/demod/mod/rs41mod.c
index 01c3d8a..f70bacb 100644
--- a/demod/mod/rs41mod.c
+++ b/demod/mod/rs41mod.c
@@ -1789,9 +1789,9 @@ static int print_position(gpx_t *gpx, int ec) {

             if ( pos > frm_end )  // end of (sub)frame
             {
-                if (gpx->option.ptu && out && !sat && !encrypted && pck_ptu > 0) {
+                if (gpx->option.ptu && !sat && !encrypted && pck_ptu > 0) {
                     err0 = get_PTU(gpx, ofs_ptu, pck_ptu, !err3);
-                    if (!err0) prn_ptu(gpx);
+                    if (!err0 && out) prn_ptu(gpx);
                 }
                 pck_ptu = 0;

I can't test other decoders at the moment to see if they are affected too, and due to different code in each decoder I can't simply grep for the relevant section. Otherwise, I'd submit a pull request.

rs1729 commented 3 years ago

Fixed, thank you.