Skip to content

Commit

Permalink
Added 'Over' Detection (Invalid Measurement)
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Messer committed Dec 22, 2011
1 parent e6f3b25 commit 7b05d4d
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
config.*
*.o
*.la
*.lo
.*
4 changes: 4 additions & 0 deletions src/libvc-gdm70x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
13 changes: 11 additions & 2 deletions src/vc-gdm70x.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <getopt.h>
#include <assert.h>
#include <time.h>
#include <stdlib.h>

const struct option longopts [] = {
{ "device", required_argument, 0, 'd' },
Expand Down Expand Up @@ -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)
{
Expand Down
3 changes: 2 additions & 1 deletion src/vc-gdm70x.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 7b05d4d

Please sign in to comment.