From 7b05d4d56524cf769d4c6e85974a6dbeeaa7871f Mon Sep 17 00:00:00 2001 From: Andreas Messer Date: Thu, 22 Dec 2011 12:27:08 +0100 Subject: [PATCH] Added 'Over' Detection (Invalid Measurement) --- .gitignore | 5 +++++ src/libvc-gdm70x.c | 4 ++++ src/vc-gdm70x.c | 13 +++++++++++-- src/vc-gdm70x.h | 3 ++- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4f56c9b --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +config.* +*.o +*.la +*.lo +.* diff --git a/src/libvc-gdm70x.c b/src/libvc-gdm70x.c index 73cc341..9e236a0 100644 --- a/src/libvc-gdm70x.c +++ b/src/libvc-gdm70x.c @@ -395,6 +395,10 @@ vc_gdm70x_parsevalue(const char* str, struct vc_gdm70x_data* data_p) case 'u': data_p->mult = MICRO; break; default: data_p->mult = NONE; break; } + + /* check for overvoltage/autorange */ + if (str[3] == '4') + data_p->mult = OVER; data_p->unit=UNKNOWN; diff --git a/src/vc-gdm70x.c b/src/vc-gdm70x.c index a2562df..094a01d 100644 --- a/src/vc-gdm70x.c +++ b/src/vc-gdm70x.c @@ -24,6 +24,7 @@ along with this program. If not, see . #include #include #include +#include const struct option longopts [] = { { "device", required_argument, 0, 'd' }, @@ -119,8 +120,16 @@ int print_values(struct vc_gdm70x* gdm_p, void* ptr) switch(c) { - case 'D': fprintf(stdout,"%.3f",data_p->value); break; - case 'M': fputc(data_p->mult,stdout); break; + case 'D': + if (data_p->mult != OVER) + fprintf(stdout,"%.3f",data_p->value); + else + fputs("OVER",stdout); + break; + case 'M': + if (data_p->mult != OVER) + fputc(data_p->mult,stdout); + break; case 'U': switch(data_p->unit) { diff --git a/src/vc-gdm70x.h b/src/vc-gdm70x.h index 37ca63a..7abdcd7 100644 --- a/src/vc-gdm70x.h +++ b/src/vc-gdm70x.h @@ -48,7 +48,8 @@ enum vc_mult { NONE=' ', MILLI='m', MICRO='u', - NANO='n' + NANO='n', + OVER='#', }; /* struct containing the received data from one channel */