DD2-monitor/serial/funcs.c

37 lines
661 B
C
Raw Normal View History

#include <stdio.h>
#include "serial.h"
extern int verbosity;
/* ---------------------------------------------------------------- */
int parseXvalue(char *line, char cflag)
{
int value, foo;
int vrd[4];
value=0;
2019-01-01 03:19:52 +11:00
if ( cflag != *line ) {
2018-12-30 03:45:31 +11:00
if (verbosity) {
fprintf(stderr, "%s line[0] 0x%x bad\n",
__func__, *line);
}
return -777;
}
foo = sscanf(line+1, "%d %d %d %d", vrd, vrd+1, vrd+2, vrd+3);
2019-01-01 03:19:52 +11:00
#if DEBUG_LEVEL
fprintf(stderr, "%s : sscanf -> %d\n", __func__, foo);
#endif
if (4 != foo) {
return -666;
}
for (foo=0; foo<4; foo++) {
value += vrd[foo];
}
return value;
}
/* ---------------------------------------------------------------- */