Skip to content

Commit 321f792

Browse files
committed
Add option for printing archive header
Add option (-a, --archive-header) to print the archive header instead of always printing
1 parent e721078 commit 321f792

File tree

2 files changed

+24
-11
lines changed

2 files changed

+24
-11
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ Options:
1919
- all the records since arc date
2020
(in yyyy-mm-dd[THH:MM format]
2121
- the last arc records
22+
-A, --archive-header Print the archive data header with the
23+
archive records
2224
-i, --get-interval Get the current archive interval
2325
-t, --get-time Get weather station time.
2426
-s, --set-time Set weather station time to system time.
@@ -232,7 +234,7 @@ grRainByMonth = 328.12,328.56,327.68,328.22,331.94,330.86,327.70,328.26,348.76,3
232234
grRainByYear = 655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,655.35,370.78,354.48
233235
```
234236

235-
## Archive Data Example Output
237+
## Archive Data Example Output (with Archive Header)
236238
```
237239
date,time,outside temp (°F),outside temp high (°F), outside temp low (°F),insideTemp (°F),extra temp1 (°F), extra temp2 (°F), extra temp3 (°F),inside humidity (%),outside humidity (%),extra humidity 1 (%),extra humidity 2 (%),rainfall (clicks),highest rain rate (clicks/hr),barometer (inches Hg),forecast at end of period,number of wind samples,average wind speed (mph),prevailing wind direction (°),prevailing wind rose,highest wind speed (mph),highest wind direction (°),higest wind rose,average solar radiation (W/m^2),maximum solar radiation (W/m^2),average uv index,max uv,accumulated et (in),leaf temp 1 (°F),leaf temp 2 (°F),leaf wetness 1,leaf wetness 2,soil temp 1 (°F),soil temp 2 (°F),soil temp 3 (°F),soil temp 4 (°F),soil moisture 1 (cb),soil moisture 2 (cb), soil moisture 3 (cb), soil moisture 4 (cb)
238240
2017-09-04,19:00,72.9,73.7,72.9,78.2,,,,75,65,,,,,30.155,Increasing clouds with little temperature change. Precipitation possible within 24 to 48 hrs.,1181,11,10,NNW,24,11,NNW,0,,0,,0.003,,,,,,,,,,,,

main.c

+21-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
#include "dhandler.h"
4242
#include "byte.h"
4343

44-
#define VERSION "1.3.1"
44+
#define VERSION "1.3.2"
4545

4646
/* local Data */
4747
static char szttyDevice[255]; /* Serial device string */
@@ -55,6 +55,7 @@ static bool bGetRTD; /* Get Real Time Data */
5555
static bool bGetHLD; /* Get High Low Data */
5656
static bool bGetGD; /* Get graph data */
5757
static bool bArchive; /* Get archive data */
58+
static bool bPrintArchiveHeader; /* Print archive header with data */
5859
static bool bGetInterval; /* Get arcive interval */
5960
static bool bGetTime; /* Get time flag */
6061
static bool bSetTime; /* Set time flag */
@@ -105,6 +106,8 @@ int main(int argc, char *argv[])
105106
printf(" - all the records since arc date\n");
106107
printf(" (in yyyy-mm-dd[THH:MM format]\n");
107108
printf(" - the last arc records\n");
109+
printf(" -A, --archive-header Print the archive data header with the\n");
110+
printf(" archive records\n");
108111
printf(" -i, --get-interval Get the current archive interval\n");
109112
printf(" -t, --get-time Get weather station time.\n");
110113
printf(" -s, --set-time Set weather station time to system time.\n");
@@ -388,7 +391,9 @@ int main(int argc, char *argv[])
388391
}
389392

390393
if (numPages) {
391-
PrintArchHeader();
394+
if (bPrintArchiveHeader) {
395+
PrintArchHeader();
396+
}
392397

393398
if (archiveRecords && (archiveRecords / 5) < numPages) {
394399
numPages = archiveRecords / 5;
@@ -479,6 +484,7 @@ int GetParms(int argc, char *argv[])
479484
{ "get-hilo", no_argument, 0, 'l' },
480485
{ "get-graph", no_argument, 0, 'g' },
481486
{ "get-archive", optional_argument, 0, 'a' },
487+
{ "archive-header", no_argument, 0, 'A' },
482488
{ "get-interval", no_argument, 0, 'i' },
483489
{ "get-time", no_argument, 0, 't' },
484490
{ "set-time", no_argument, 0, 's' },
@@ -499,6 +505,8 @@ int GetParms(int argc, char *argv[])
499505
bGetRTD = false;
500506
bGetHLD = false;
501507
bGetGD = false;
508+
bArchive = false;
509+
bPrintArchiveHeader = false;
502510
bHTML = false;
503511
bVerbose = false;
504512
bDebug = false;
@@ -510,7 +518,7 @@ int GetParms(int argc, char *argv[])
510518
if(argc == 1)
511519
return 0; /* no parms at all */
512520

513-
while ((c = getopt_long(argc, argv, "ofrmxlga::ivetsb:d:", longopts, NULL )) != EOF) {
521+
while ((c = getopt_long(argc, argv, "ofrmxlga::Aivetsb:d:", longopts, NULL )) != EOF) {
514522
switch (c) {
515523
case 'o': bBKLOn = true; break;
516524
case 'f': bBKLOff = true; break;
@@ -527,6 +535,7 @@ int GetParms(int argc, char *argv[])
527535
bVerbose = true;
528536
bDebug = true;
529537
break;
538+
case 'A': bPrintArchiveHeader = true; break;
530539

531540
case 'a':
532541
bArchive = true;
@@ -778,16 +787,18 @@ int runCommand(char* command, int commandLength, int expectedLength, char* dataL
778787
}
779788

780789
// Check for 0x0a0d at end
781-
if (nCnt == totalLength + 2) {
782-
if (szSerBuffer[totalLength] == 0x0a
783-
&& szSerBuffer[totalLength + 1] == 0x0d) {
790+
if (nCnt == totalLength + 2 && szSerBuffer[totalLength] == 0x0a
791+
&& szSerBuffer[totalLength + 1] == 0x0d) {
792+
if (bVerbose) {
784793
printf("Good\n");
785794
}
786795
} else {
787-
if(nCnt != totalLength)
788-
printf("Bad\n");
789-
else
790-
printf("Good\n");
796+
if (bVerbose) {
797+
if(nCnt != totalLength)
798+
printf("Bad\n");
799+
else
800+
printf("Good\n");
801+
}
791802

792803
if(nCnt != totalLength) {
793804
fprintf(stderr, "vproweather: Didn't get all data. Try changing delay parameter.\n");

0 commit comments

Comments
 (0)