X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=ao-tools%2Fao-test-baro%2Fao-test-baro.c;h=d617a83aa876d4c95c7cbfcca513cd21bf6fd04d;hp=e883de4a47d3fc6ae346c7e7f8fcfc7556d9f5ec;hb=6f729ff46b2f4531db68f0af85e7e9fe0f6d1969;hpb=fc3364de2b6cdfff53f5c38b3ae52ae5601ff3b7 diff --git a/ao-tools/ao-test-baro/ao-test-baro.c b/ao-tools/ao-test-baro/ao-test-baro.c index e883de4a..d617a83a 100644 --- a/ao-tools/ao-test-baro/ao-test-baro.c +++ b/ao-tools/ao-test-baro/ao-test-baro.c @@ -3,7 +3,8 @@ * * 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; version 2 of the License. + * the Free Software Foundation; either version 2 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 @@ -46,7 +47,7 @@ static void usage(char *program) exit(1); } -void +static void done(struct cc_usb *cc, int code) { /* cc_usb_printf(cc, "a\n"); */ @@ -54,28 +55,6 @@ done(struct cc_usb *cc, int code) exit (code); } -static int -ends_with(char *whole, char *suffix) -{ - int whole_len = strlen(whole); - int suffix_len = strlen(suffix); - - if (suffix_len > whole_len) - return 0; - return strcmp(whole + whole_len - suffix_len, suffix) == 0; -} - -static int -starts_with(char *whole, char *prefix) -{ - int whole_len = strlen(whole); - int prefix_len = strlen(prefix); - - if (prefix_len > whole_len) - return 0; - return strncmp(whole, prefix, prefix_len) == 0; -} - static char ** tok(char *line) { char **strs = malloc (sizeof (char *)), *str; @@ -139,16 +118,15 @@ free_baro(struct baro *b) { } } -char ** +static char ** find_baro(struct baro *b, char *word0) { - int i; for (;b; b = b->next) if (b->strs[0] && !strcmp(b->strs[0], word0)) return b->strs; return NULL; } -int +static int do_baro(struct cc_usb *usb) { struct baro *b = baro(usb); char **temp = find_baro(b, "Temperature:"); @@ -163,13 +141,13 @@ do_baro(struct cc_usb *usb) { double temperature = strtod(temp[2], NULL) / 100.0; double altitude = strtod(alt[1], NULL); - if (altitude < -50 || 3000 < altitude) { + if (altitude < -100 || 3000 < altitude) { printf ("weird altitude %f\n", altitude); free_baro(b); return 0; } - if (temperature < 20 || 35 < temperature) { + if (temperature < 20 || 40 < temperature) { printf ("weird temperature %f\n", temperature); free_baro(b); return 0; @@ -184,15 +162,9 @@ int main (int argc, char **argv) { char *device = NULL; - char *filename; - Elf *e; - unsigned int s; - int i; int c; - int tries; struct cc_usb *cc = NULL; char *tty = NULL; - int success; int verbose = 0; int ret = 0;