From 8989ff558badbdaf49a5a74a621872c96761f5bf Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 12 Jan 2019 17:13:30 +0100 Subject: [PATCH] + conversion sortie lm25 -> celsius --- serial/essai.sh | 2 +- serial/funcs.c | 9 +++++++++ serial/serial.h | 2 ++ serial/t.c | 5 +++-- simulator/rdtemp/rdtemp.ino | 2 +- 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/serial/essai.sh b/serial/essai.sh index 854ac44..0d9a601 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,7 +5,7 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=50 +NB_READ=160 ./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} diff --git a/serial/funcs.c b/serial/funcs.c index 6bbd45a..bc59658 100644 --- a/serial/funcs.c +++ b/serial/funcs.c @@ -35,6 +35,15 @@ for (foo=0; foo<4; foo++) { return value; } /* ---------------------------------------------------------------- */ +int values2temps(float array[4]) +{ +int foo; +for (foo=0; foo<4; foo++) { + array[foo] *= (5.0 / 1023.0 * 100.0); + } +return 0; +} +/* ---------------------------------------------------------------- */ int parse4values(char *line, char cflag, float array[4]) { float ftmp[4]; diff --git a/serial/serial.h b/serial/serial.h index 6b28d65..158a2d1 100644 --- a/serial/serial.h +++ b/serial/serial.h @@ -17,6 +17,8 @@ int getline_to(int fd, char *where, int szm, int to_ms); /* auxiliary and test functions */ int parseXvalue(char *asciidatas, char id); +int values2temps(float array[4]); + int parse4values(char *line, char cflag, float array[4]); diff --git a/serial/t.c b/serial/t.c index fe72b05..fef41c6 100644 --- a/serial/t.c +++ b/serial/t.c @@ -29,7 +29,7 @@ float datas[4]; for (count=0; count 1) { fprintf(stderr, "getline #%d -> %d\n", count, foo); fprintf(stderr, "%s\n", ligne); } @@ -37,6 +37,7 @@ for (count=0; count= 0) { temps = time(NULL); + values2temps(datas); printf("%ld %f %f %f %f\n", temps, datas[0], datas[1], datas[2], datas[3]); fflush(stdout); @@ -44,7 +45,7 @@ for (count=0; count %d\n", __func__, foo); } - if (verbosity) fprintf(stderr, "\n"); + if (verbosity > 1) fprintf(stderr, "\n"); } return 0; } diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index cf28832..0df852c 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -4,7 +4,7 @@ /* -------------------------------------------------- */ #define NBVAL 4 -#define DELAI 5000 +#define DELAI 10000 int values[NBVAL];