diff --git a/Auxiliary_utils/Weather_chk/Readme.md b/Auxiliary_utils/Weather_chk/Readme.md index 5ad8feb..2a4a3e1 100644 --- a/Auxiliary_utils/Weather_chk/Readme.md +++ b/Auxiliary_utils/Weather_chk/Readme.md @@ -7,12 +7,13 @@ Check meteostation parameters -d, --devname=arg serial device name -h, --help show this help + -r, --raw show raw information from meteostation -s, --speed=arg baudrate (default: 9600) Output: Rain=0/1 -Clouds=0/1 +Clouds=xxxx Return value: -0 if no rain, 1 if there's rainy +0 if no rain and Clouds>1800, 1 if there's rainy or Clouds>1800 diff --git a/Auxiliary_utils/Weather_chk/cmdlnopts.c b/Auxiliary_utils/Weather_chk/cmdlnopts.c index 94b0ed7..cf65fbd 100644 --- a/Auxiliary_utils/Weather_chk/cmdlnopts.c +++ b/Auxiliary_utils/Weather_chk/cmdlnopts.c @@ -1,5 +1,5 @@ /* - * This file is part of the ttyterm project. + * This file is part of the weatherchk project. * Copyright 2020 Edward V. Emelianov . * * This program is free software: you can redistribute it and/or modify @@ -33,7 +33,7 @@ static glob_pars G; // default global parameters glob_pars const Gdefault = { .speed = 9600, - .ttyname = "/dev/ttyUSB0", + .ttyname = "/dev/ttyS3", }; /* @@ -45,6 +45,7 @@ static myoption cmdlnopts[] = { {"help", NO_ARGS, NULL, 'h', arg_int, APTR(&help), _("show this help")}, {"speed", NEED_ARG, NULL, 's', arg_int, APTR(&G.speed), _("baudrate (default: 9600)")}, {"devname", NEED_ARG, NULL, 'd', arg_string, APTR(&G.ttyname), _("serial device name")}, + {"raw", NO_ARGS, NULL, 'r', arg_int, APTR(&G.showraw), _("show raw information from meteostation")}, end_option }; diff --git a/Auxiliary_utils/Weather_chk/cmdlnopts.h b/Auxiliary_utils/Weather_chk/cmdlnopts.h index 6b6e539..ad1a69b 100644 --- a/Auxiliary_utils/Weather_chk/cmdlnopts.h +++ b/Auxiliary_utils/Weather_chk/cmdlnopts.h @@ -1,5 +1,5 @@ /* - * This file is part of the ttyterm project. + * This file is part of the weatherchk project. * Copyright 2020 Edward V. Emelianov . * * This program is free software: you can redistribute it and/or modify @@ -26,6 +26,7 @@ typedef struct{ int speed; // baudrate char *ttyname; // device name + int showraw; // show raw information } glob_pars; diff --git a/Auxiliary_utils/Weather_chk/main.c b/Auxiliary_utils/Weather_chk/main.c index 995ebe2..867a22e 100644 --- a/Auxiliary_utils/Weather_chk/main.c +++ b/Auxiliary_utils/Weather_chk/main.c @@ -1,5 +1,5 @@ /* - * This file is part of the ttyterm project. + * This file is part of the weatherchk project. * Copyright 2020 Edward V. Emelianov . * * This program is free software: you can redistribute it and/or modify @@ -80,10 +80,11 @@ int main(int argc, char **argv){ char *eol = strchr(ptr, '\n'); if(eol) *eol = 0; DBG("Now: %s\n", ptr); + if(G->showraw) green("%s\n", ptr); double rain = 1., clouds = 1.; if(!getpar(ptr, &rain, "RT")) printf("Rain=%g\n", rain); - if(!getpar(ptr, &clouds, "WK")) printf("Clouds=%g\n", clouds); + if(!getpar(ptr, &clouds, "WU")) printf("Clouds=%g\n", clouds); close_tty(&dev); - if(rain > 0.1) return 1; + if(rain > 0.1 || clouds < 1800.) return 1; return 0; }