From 369666e909d7a13efe9894c2c09553235efb0bd0 Mon Sep 17 00:00:00 2001 From: Caz Yokoyama Date: Wed, 9 Dec 2020 19:11:28 -0800 Subject: [PATCH] Fix the bug where no data is read on json format. Signed-off-by: Caz Yokoyama --- TX23/readTX23.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/TX23/readTX23.c b/TX23/readTX23.c index 82f5f21..87c7544 100644 --- a/TX23/readTX23.c +++ b/TX23/readTX23.c @@ -42,6 +42,9 @@ printWindSpeedAndDirection(void) // Set up the TX23 Pins RPi_TX23_InitPins(); + //Read from the TX23 + if (RPi_TX23_GetReading(&WindDirection, &WindSpeed) != TRUE) + return false; if (json_format) { RPi_TX23_GetDateTimeUTC(thetime); p = strchr(thetime, 'T'); @@ -56,14 +59,10 @@ printWindSpeedAndDirection(void) mph, (double)WindDirection*22.5); } else { - //Read from the TX23 - if (RPi_TX23_GetReading(&WindDirection, &WindSpeed) == TRUE) { - RPi_TX23_GetDateTimeLocal(thetime); - printf("(%d , %d )", WindDirection, WindSpeed); -// printf("%s,Wind Direction,%0.1f\n",thetime,((double)WindDirection)*22.5); -// printf("%s,Wind Speed,%d\n",thetime,WindSpeed); - } else - return false; + RPi_TX23_GetDateTimeLocal(thetime); + printf("(%d , %d )", WindDirection, WindSpeed); +// printf("%s,Wind Direction,%0.1f\n",thetime,((double)WindDirection)*22.5); +// printf("%s,Wind Speed,%d\n",thetime,WindSpeed); } fflush(stdout);