working on serial protocol

This commit is contained in:
Tonton Th 2019-01-28 14:42:33 +01:00
parent 054d0f574c
commit 15c6cbd8ae
5 changed files with 25 additions and 7 deletions

View File

@ -28,6 +28,8 @@ ne bloque pas, c'est un peu ironique.
Après un peu plus d'investigation, j'en arrive à conclure qu'il y a
plein de subtilités entre les diverses variantes d'Arduino. Mais pas que.
Je pense que les quatre ports série supplémentaires de l'Arduino Mega
seront moins capricieux.

View File

@ -5,18 +5,18 @@ DATAFILE="foo.dat"
TMPFILE="/tmp/dd2data"
IMAGE="graphe.png"
NB_READ=25000
NB_READ=25
./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
gnuplot << __EOC__
set term png size 3200,512
set output "${IMAGE}"
set grid
set title "Dans le Double Dragon 2"
set title "Temperature dans le Double Dragon 2"
set xdata time
set timefmt "%s"
set format x "%H:%M:%S"
set format x "%a, %H:%M:%S"
set yrange [ 5.0 : 30.0]
plot "${DATAFILE}" using 1:2 title " foo" with lines, \
"${DATAFILE}" using 1:3 title " bar" with lines, \

View File

@ -7,6 +7,10 @@
extern int verbosity;
/* ---------------------------------------------------------------- */
/*
* compute the integer mean value of a four values
* tagged lines.
*/
int parseXvalue(char *line, char cflag)
{
int value, foo;
@ -32,10 +36,17 @@ if (4 != foo) {
for (foo=0; foo<4; foo++) {
value += vrd[foo];
}
value /= 4;
return value;
}
/* ---------------------------------------------------------------- */
int values2temps(float array[4])
/*
* this fonction is specific to the LM35 thermo-sensor
* connected to a ADC pin of an Arduino Mega
*/
int values2temperature(float array[4])
{
int foo;
for (foo=0; foo<4; foo++) {

View File

@ -17,7 +17,7 @@ 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 values2temperature(float array[4]);
int parse4values(char *line, char cflag, float array[4]);

View File

@ -37,7 +37,7 @@ for (count=0; count<iters; count++) {
//
if (foo >= 0) {
temps = time(NULL);
values2temps(datas);
values2temperature(datas);
printf("%ld %f %f %f %f\n", temps,
datas[0], datas[1], datas[2], datas[3]);
fflush(stdout);
@ -75,6 +75,11 @@ while ((opt = getopt(argc, argv, "d:n:v")) != -1) {
}
if (verbosity) {
fprintf(stderr, "Testing Serial Software - compiled " \
__DATE__ " " __TIME__ "\n");
}
serial_in = prepare_UART(device, speed);
if (serial_in < 0) {
fprintf(stderr, "%s : open device : error %d on %s\n",