From 841cdbc593958f06108ec2179214b2e3556b9e4f Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 14 Dec 2018 18:14:04 +0100 Subject: [PATCH 001/110] more doc... --- README.md | 20 +++++++++++++++++++- gnocchi/README.md | 4 ++-- influxdb/README.md | 2 -- rrdb/README.md | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 54cde11..315e02f 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,20 @@ -# DD2 monitoring tools +## DD2 monitoring tools + +Expérimentations et recherches dans le but de construire un système +de _monitoring_ pour le futur Phytotron du Tetalab. + +Le but premier de ce système est de faciliter la mise au point d'un +automate de contrôle de l'enceinte thermostatée. Nous devrons +surveiller température et humidité du dd2, et température du +confinement biologique. + +Pour en savoir plus sur ce passionnant projet, il y a le canal IRC +`#tetalab` sur le réseau Freenode et/ou les rencontres du mercredi +soir au DD2, à Mixart-Myrys. + + + + + + diff --git a/gnocchi/README.md b/gnocchi/README.md index ea63666..643e7ed 100644 --- a/gnocchi/README.md +++ b/gnocchi/README.md @@ -2,9 +2,9 @@ # blabla commercial -https://gnocchi.xyz/ -_The problem that Gnocchi solves is the storage and indexing of + +_The problem that [Gnocchi](https://gnocchi.xyz/) solves is the storage and indexing of time series data and resources at a large scale. This is useful in modern cloud platforms which are not only huge but also are dynamic and potentially multi-tenant. diff --git a/influxdb/README.md b/influxdb/README.md index 6d2fdfc..8a603ab 100644 --- a/influxdb/README.md +++ b/influxdb/README.md @@ -1,5 +1,3 @@ - - ## InfluxDB # Blabla commercial diff --git a/rrdb/README.md b/rrdb/README.md index 6632e81..2c69ae5 100644 --- a/rrdb/README.md +++ b/rrdb/README.md @@ -1,3 +1,3 @@ - +## Round Robin Database Un grand classique du genre. From aba734c095a84883383f4d22fccba0dcd315e08c Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 14 Dec 2018 18:21:16 +0100 Subject: [PATCH 002/110] patching fsck markdown --- gnocchi/README.md | 4 ++-- rrdb/README.md | 6 ++++-- serial/README.md | 3 ++- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gnocchi/README.md b/gnocchi/README.md index 643e7ed..e447827 100644 --- a/gnocchi/README.md +++ b/gnocchi/README.md @@ -1,6 +1,6 @@ -## Gnocchi +# Gnocchi -# blabla commercial +## blabla commercial diff --git a/rrdb/README.md b/rrdb/README.md index 2c69ae5..4cf4455 100644 --- a/rrdb/README.md +++ b/rrdb/README.md @@ -1,3 +1,5 @@ -## Round Robin Database +# Round Robin Database + +Un grand classique du genre. Délicat à comprendre au début. + -Un grand classique du genre. diff --git a/serial/README.md b/serial/README.md index 98293fc..defd657 100644 --- a/serial/README.md +++ b/serial/README.md @@ -4,7 +4,8 @@ But premier de ce module : recevoir les données fournies par l'automate de contrôle du phytotron. -Ayant déja pratiqué ce genre de chose pour un déja ancien +Ayant déja pratiqué ce genre de chose (recevoir des données par rs232) +pour un déja ancien [projet](http://art.dinorama.fr/bdf/) avec _MadPhoenix_, je me propose de reprendre quelques parties de ce code, de le remettre au gout du jour et de le tester dès que possible. From c391b6b079c72d294513bb54ca73ed9b979bf42c Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 14 Dec 2018 18:52:06 +0100 Subject: [PATCH 003/110] le bar est ouvert --- serial/README.md | 14 +++++++++++++- serial/serial.c | 37 +++++++++++++++++++++++++++++++++++++ serial/serial.h | 2 ++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/serial/README.md b/serial/README.md index defd657..f7486ff 100644 --- a/serial/README.md +++ b/serial/README.md @@ -6,10 +6,22 @@ de contrôle du phytotron. Ayant déja pratiqué ce genre de chose (recevoir des données par rs232) pour un déja ancien -[projet](http://art.dinorama.fr/bdf/) +[projet artsitique](http://art.dinorama.fr/bdf/) conçu par et avec _MadPhoenix_, je me propose de reprendre quelques parties de ce code, de le remettre au gout du jour et de le tester dès que possible. +## principe général + +Pour écouter plusieurs lignes simultanément, chaque port sera traité +par un _thread_ séparé, et les diverses données reçues seront pré-traitées +par celui-ci. Les flux de données seront alors agrégées par +le célèbre *synthétiseur d'évènement* mis au point il y a très longtemps +par le professeur Cispeo. + + + + + diff --git a/serial/serial.c b/serial/serial.c index f086c13..1c04a8a 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -170,3 +170,40 @@ switch (retval) { return byte; } /* -------------------------------------------------------------------- */ +/* timeout is in milliseconds */ + +int getline_to(int fd, char *where, int szm, int to_ms) +{ +int curpos, byte, retval; + +curpos = 0; +retval = -7; /* magic number powa */ +where[0] = '\0'; /* erase all the bs */ + +for(;;) { + byte = getbyte_to (fd, to_ms); + + if (byte < 0) { + fprintf(stderr, "%s : somthing is wrong %d\n", + __func__, byte); + retval = byte; + break; + } + + if ('\n' == byte) { /* got an EOL ? */ + where[curpos] = '\0'; + retval = curpos; + } + + + + + } + +fprintf(stderr, "%s -> '%s'\n", __func__, where); + + +return -666; +} +/* -------------------------------------------------------------------- */ + diff --git a/serial/serial.h b/serial/serial.h index 2bd7cb5..9da35b3 100644 --- a/serial/serial.h +++ b/serial/serial.h @@ -12,4 +12,6 @@ int getbyte(int fd); /* timeout is exprimed in milliseconds. */ int getbyte_to (int fd, int to_ms); +int getline_to(int fd, char *where, int szm, int to_ms); + From 8a34fed6af9f78868bcfb9df5eed7e217ee907ba Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 14 Dec 2018 22:12:03 +0100 Subject: [PATCH 004/110] Sabrina <3 --- .gitignore | 8 +++++--- serial/README.md | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 8ed37e6..90c1ad8 100644 --- a/.gitignore +++ b/.gitignore @@ -3,8 +3,10 @@ a.out fake-values essai serial/t -doc/*.toc doc/*.log doc/*.aux doc/*.pdf - - +doc/*.toc +doc/*.log +doc/*.aux +doc/*.pdf +doc/*.idx diff --git a/serial/README.md b/serial/README.md index f7486ff..2a541de 100644 --- a/serial/README.md +++ b/serial/README.md @@ -18,6 +18,11 @@ par celui-ci. Les flux de données seront alors agrégées par le célèbre *synthétiseur d'évènement* mis au point il y a très longtemps par le professeur Cispeo. +## À venir... + +Un petit exemple ? + + From bb10042aaebaa69ab4764265310d9ee1c4549538 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 20 Dec 2018 11:57:23 +0100 Subject: [PATCH 005/110] blocking read is not blocking --- README.md | 5 +++ serial/README.md | 6 +++ serial/serial.c | 45 ++++++++++++++-------- serial/serial.h | 2 +- serial/t.c | 28 +++++++++----- simulator/send-random/send-random.ino | 55 +++++++++++++++++++++++++++ 6 files changed, 115 insertions(+), 26 deletions(-) create mode 100644 simulator/send-random/send-random.ino diff --git a/README.md b/README.md index 315e02f..9404e2c 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,11 @@ Pour en savoir plus sur ce passionnant projet, il y a le canal IRC `#tetalab` sur le réseau Freenode et/ou les rencontres du mercredi soir au DD2, à Mixart-Myrys. +# WTF status + +Le `read` bloquant ne bloque pas. Ça craint grave. + + diff --git a/serial/README.md b/serial/README.md index 2a541de..cfe5c6a 100644 --- a/serial/README.md +++ b/serial/README.md @@ -22,6 +22,12 @@ par le professeur Cispeo. Un petit exemple ? +Oui, voilà. À ce jour (20 déc. 2018), on va dire que ça ne marche pas. +Il faut dire que les `serial devices` ont toujours étés un peu le +domaine de la magie noire. Mais quand même, coincer sur un `read` qui +ne bloque pas, c'est un peu ironique. + + diff --git a/serial/serial.c b/serial/serial.c index 1c04a8a..bec0bf8 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -1,7 +1,9 @@ #include #include +#include #include +#include #include //Used for UART #include //Used for UART #include //Used for UART @@ -60,12 +62,14 @@ fprintf(stderr, "%s ( %s %d )\n", __func__, port, baudrate); // shall not cause the terminal device to become the controlling terminal // for the process. -uart0 = open(port, O_RDWR | O_NOCTTY); -if (uart0== -1) +uart0 = open(port, O_RDONLY | O_NOCTTY); +if (uart0 < 0) { perror("unable to open uart "); return -1; } + +return uart0; /* WTF ??? */ // CONFIGURE THE UART // The flags defined in /usr/include/termios.h - @@ -87,6 +91,9 @@ baudbits = baudrate2const(baudrate); #if DEBUG_LEVEL fprintf(stderr, "%d -> 0x%04x\n", baudrate, baudbits); #endif + +memset(&options, 0, sizeof(options)); + tcgetattr(uart0, &options); options.c_cflag = baudbits | CS8 | CLOCAL | CREAD; // %d\n", __func__, retval); #endif -retval = retval < 0 ? -1 : retval; - switch (retval) { case -1: fprintf(stderr, "omg ?\n"); - byte = -1; + retval = -1; break; case 0: fprintf(stderr, "timeout\n"); - byte = -99; + retval = -99; break; default: + fprintf(stderr, "%s default -> %d\n", __func__, retval); if (retval==fd) { read(fd, &byte, 1); fprintf(stderr, "got 0x%02x\n", byte); + retval = byte; } else { fprintf(stderr, "%d bad fd ?\n", retval); - byte = -3; + retval = -3; } break; } -return byte; +return retval; } /* -------------------------------------------------------------------- */ /* timeout is in milliseconds */ @@ -195,15 +204,21 @@ for(;;) { retval = curpos; } - - + if (curpos < szm) { /* ya de la place */ + where[curpos] = byte; + curpos++; + } + else { /* oups overflow */ + retval = -6; + break; + } } fprintf(stderr, "%s -> '%s'\n", __func__, where); -return -666; +return retval; } /* -------------------------------------------------------------------- */ diff --git a/serial/serial.h b/serial/serial.h index 9da35b3..a13d292 100644 --- a/serial/serial.h +++ b/serial/serial.h @@ -6,7 +6,7 @@ int prepare_UART(char *port, int bauds); -int getbyte(int fd); +int getbyte(int fd); /* really brotched func */ /* timeout is exprimed in milliseconds. */ diff --git a/serial/t.c b/serial/t.c index 8a75043..4fed028 100644 --- a/serial/t.c +++ b/serial/t.c @@ -1,28 +1,36 @@ #include +#include #include #include "serial.h" +int verbosity; + int main (int argc, char *argv[]) { -int serial_in; -int byte, foo, to; +int serial_in; +int byte; -serial_in = prepare_UART("/dev/ttyS0", 9600); +serial_in = prepare_UART("/dev/ttyACM0", 9600); fprintf(stderr, "prepare uart -> %d\n", serial_in); -for (foo=0; foo<20; foo++) { - to = (foo+1) * 666; - byte = getbyte_to(serial_in, to); +if (serial_in < 0) { + exit(1); + } + +for (;;) { + + byte = getbyte(serial_in); + if (byte < 0) { fprintf(stderr, "get byte : err is %d\n", byte); } - // XXX else { - printf("%9ld %6d %6d %02x\n", - time(NULL), foo, to, byte); - // XXX } + else { + printf("%9ld %02x/%d\n", + time(NULL), byte, byte); + } } return 0; diff --git a/simulator/send-random/send-random.ino b/simulator/send-random/send-random.ino new file mode 100644 index 0000000..16cd63f --- /dev/null +++ b/simulator/send-random/send-random.ino @@ -0,0 +1,55 @@ +/* + * simulateur de telemesure automate + */ + +/* -------------------------------------------------- */ + +#define NBVAL 4 + +int values[NBVAL]; + +/* -------------------------------------------------- */ +void setup() { + int foo; + Serial.begin(9600); + pinMode(LED_BUILTIN, OUTPUT); + for (foo=0; foo 1023) { + values[foo] = rand()%15; + } + } +} +/* -------------------------------------------------- */ + +void sendvalues(void) +{ + int foo; + + Serial.print("X "); + for (foo=0; foo Date: Thu, 20 Dec 2018 17:53:18 +0100 Subject: [PATCH 006/110] EOW --- .gitignore | 3 +++ doc/dd2-monitoring.tex | 17 +++++++++++++++-- doc/mkdoc.sh | 8 ++++++++ serial/serial.c | 6 ++---- 4 files changed, 28 insertions(+), 6 deletions(-) create mode 100755 doc/mkdoc.sh diff --git a/.gitignore b/.gitignore index 90c1ad8..5a276e4 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ doc/*.log doc/*.aux doc/*.pdf doc/*.idx +doc/*.ilg +doc/*.ind + diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index be5ec16..a1cf56e 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -1,5 +1,5 @@ -\documentclass[a4paper,12pt]{article} +\documentclass[a4paper,11pt]{article} % \listfiles % pour le debug @@ -8,6 +8,7 @@ \usepackage[T1]{fontenc} % XXX \usepackage{lipsum} \usepackage{makeidx} +\usepackage{listings} % \usepackage{color} % \usepackage{url} \usepackage{xspace} @@ -93,7 +94,7 @@ ne demande qu'à grandir. \subsection{Exemples} -Promis, on va en mettre ! +Promis, on va en mettre ! Dès que ça marche\dots \subsection{Analyses} @@ -120,7 +121,19 @@ La première, que nous allons juste entrevoir, passera par le port USB de la carte Arduino. La seconde passera par un port série auxiliaire\footnote{Il y en a 4 sur le 2560} de celle-ci. +\begin{lstlisting} +tcgetattr(uart0, &options); +options.c_cflag = baudbits | CS8 | CLOCAL | CREAD; +options.c_iflag = IGNPAR; +options.c_oflag = 0; +options.c_lflag = 0; +tcflush(uart0, TCIFLUSH); +tcsetattr(uart0, TCSANOW, &options); +\end{lstlisting} +Et en fait, le \texttt{read} sur le \textsl{fd} du serial device +n'est pas bloquant, \texttt{perror} annonce \emph{success}, mais +rien ne marche. L'année 2019 va commencer sur du vaudou programming. % ------------------------------------------------------------------- diff --git a/doc/mkdoc.sh b/doc/mkdoc.sh new file mode 100755 index 0000000..031711f --- /dev/null +++ b/doc/mkdoc.sh @@ -0,0 +1,8 @@ +#!/bin/bash + + +pdflatex dd2-monitoring.tex + +makeindex dd2-monitoring + +pdflatex dd2-monitoring.tex \ No newline at end of file diff --git a/serial/serial.c b/serial/serial.c index bec0bf8..241f050 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -68,8 +68,6 @@ if (uart0 < 0) perror("unable to open uart "); return -1; } - -return uart0; /* WTF ??? */ // CONFIGURE THE UART // The flags defined in /usr/include/termios.h - @@ -92,10 +90,10 @@ baudbits = baudrate2const(baudrate); fprintf(stderr, "%d -> 0x%04x\n", baudrate, baudbits); #endif -memset(&options, 0, sizeof(options)); +memset(&options, 0, sizeof(options)); tcgetattr(uart0, &options); -options.c_cflag = baudbits | CS8 | CLOCAL | CREAD; // Date: Fri, 21 Dec 2018 17:53:17 +0100 Subject: [PATCH 007/110] serial over USB is evil, really evil --- serial/t.c | 43 ++++++++++++++++++++------- simulator/send-random/send-random.ino | 2 +- 2 files changed, 34 insertions(+), 11 deletions(-) diff --git a/serial/t.c b/serial/t.c index 4fed028..cd95b9e 100644 --- a/serial/t.c +++ b/serial/t.c @@ -3,17 +3,41 @@ #include #include #include +#include //Used for UART +#include //Used for UART +#include #include "serial.h" int verbosity; +/* ----------------------------------------------------- */ +int openserial(char *dev) +{ +int uart; + +fprintf(stderr, "%s ( %s )\n", __func__, dev); +uart = open(dev, O_RDONLY | O_NOCTTY); +if (uart < 0) + { + perror("unable to open uart"); + return -1; + } +return uart; +} +/* ----------------------------------------------------- */ + int main (int argc, char *argv[]) { -int serial_in; -int byte; +int serial_in, foo; +unsigned char byte; -serial_in = prepare_UART("/dev/ttyACM0", 9600); +if (2 != argc) { + fprintf(stderr, "device name ?\n"); + return 2; + } + +serial_in = openserial(argv[1]); fprintf(stderr, "prepare uart -> %d\n", serial_in); if (serial_in < 0) { @@ -21,17 +45,16 @@ if (serial_in < 0) { } for (;;) { - - byte = getbyte(serial_in); - - if (byte < 0) { - fprintf(stderr, "get byte : err is %d\n", byte); + foo = read(serial_in, &byte, 1); + if (1 != foo) { + fprintf(stderr, "get byte : err is %d\n", errno); } else { - printf("%9ld %02x/%d\n", - time(NULL), byte, byte); + printf("%9ld %02x/%d\n", time(NULL), byte, byte); } } return 0; } + +/* ----------------------------------------------------- */ diff --git a/simulator/send-random/send-random.ino b/simulator/send-random/send-random.ino index 16cd63f..70f8bb0 100644 --- a/simulator/send-random/send-random.ino +++ b/simulator/send-random/send-random.ino @@ -48,7 +48,7 @@ void sendvalues(void) void loop() { updatevalues(); sendvalues(); - delay(5000); + delay(1000); } /* -------------------------------------------------- */ From c7053d9c30e55964d383eb1c745e7153c70de6ee Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 29 Dec 2018 02:43:12 +0100 Subject: [PATCH 008/110] /dev/ttyACM0 mon amour --- rrdb/README.md | 15 +++++++++++++++ serial/README.md | 4 ++++ serial/t.c | 16 +++++++--------- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/rrdb/README.md b/rrdb/README.md index 4cf4455..74d6528 100644 --- a/rrdb/README.md +++ b/rrdb/README.md @@ -1,5 +1,20 @@ # Round Robin Database Un grand classique du genre. Délicat à comprendre au début. +Les principes sous-jacents sont assez pointus, et leur mise en oeuvre +loin d'être évidente pour les newbies. + +La lecture de la manpage `rrdtutorial` est indispensable. + +## premier exemple + + +## et après ? + + + + + + diff --git a/serial/README.md b/serial/README.md index cfe5c6a..f531775 100644 --- a/serial/README.md +++ b/serial/README.md @@ -26,6 +26,10 @@ Oui, voilà. À ce jour (20 déc. 2018), on va dire que ça ne marche pas. Il faut dire que les `serial devices` ont toujours étés un peu le domaine de la magie noire. Mais quand même, coincer sur un `read` qui 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. + diff --git a/serial/t.c b/serial/t.c index cd95b9e..68ef369 100644 --- a/serial/t.c +++ b/serial/t.c @@ -21,7 +21,7 @@ uart = open(dev, O_RDONLY | O_NOCTTY); if (uart < 0) { perror("unable to open uart"); - return -1; + exit(1); } return uart; } @@ -33,24 +33,22 @@ int serial_in, foo; unsigned char byte; if (2 != argc) { - fprintf(stderr, "device name ?\n"); + fprintf(stderr, "give me a device name, please.\n"); return 2; } serial_in = openserial(argv[1]); -fprintf(stderr, "prepare uart -> %d\n", serial_in); - -if (serial_in < 0) { - exit(1); - } +fprintf(stderr, "openserial -> %d\n", serial_in); for (;;) { foo = read(serial_in, &byte, 1); if (1 != foo) { - fprintf(stderr, "get byte : err is %d\n", errno); + fprintf(stderr, "get byte : got %d, err is %d\n", foo, errno); } else { - printf("%9ld %02x/%d\n", time(NULL), byte, byte); + printf("%9ld $%02x ", time(NULL), byte); + if (isprint(byte)) putchar(byte); + puts(""); } } From 654453f0db109a7bff902a6c0e7ebbbc6ddb3219 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 29 Dec 2018 09:45:22 +0100 Subject: [PATCH 009/110] tios.c_cc[VMIN] = 1; --- serial/serial.c | 4 ++-- serial/t.c | 24 +++++++++++++++++++++--- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/serial/serial.c b/serial/serial.c index 241f050..527d304 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -213,9 +213,9 @@ for(;;) { } +#if DEBUG_LEVEL fprintf(stderr, "%s -> '%s'\n", __func__, where); - - +#endif return retval; } /* -------------------------------------------------------------------- */ diff --git a/serial/t.c b/serial/t.c index 68ef369..2a72e37 100644 --- a/serial/t.c +++ b/serial/t.c @@ -2,10 +2,13 @@ #include #include +#include +#include #include #include //Used for UART #include //Used for UART #include +#include //Used for UART #include "serial.h" @@ -26,7 +29,17 @@ if (uart < 0) return uart; } /* ----------------------------------------------------- */ - +int configserial(int fd) +{ +struct termios tios; +bzero(&tios, sizeof(tios)); +tios.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD; +tios.c_lflag = ICANON; +tios.c_cc[VMIN] = 1; /* read bloquant ??? */ +tcsetattr(fd,TCSANOW,&tios); +return 0; +} +/* ----------------------------------------------------- */ int main (int argc, char *argv[]) { int serial_in, foo; @@ -40,15 +53,20 @@ if (2 != argc) { serial_in = openserial(argv[1]); fprintf(stderr, "openserial -> %d\n", serial_in); +(void)configserial(serial_in); + + for (;;) { foo = read(serial_in, &byte, 1); if (1 != foo) { - fprintf(stderr, "get byte : got %d, err is %d\n", foo, errno); + fprintf(stderr, "get byte : got %d, err is %d\n", + foo, errno); } else { printf("%9ld $%02x ", time(NULL), byte); - if (isprint(byte)) putchar(byte); + if (isprint(byte)) putchar(byte); puts(""); + if ('\n'==byte) puts(""); } } From 4eed817ecbebcbb2d36c37422fd5ae5e6d111a22 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 29 Dec 2018 09:49:07 +0100 Subject: [PATCH 010/110] slowdown arduino testing sender --- simulator/send-random/send-random.ino | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/simulator/send-random/send-random.ino b/simulator/send-random/send-random.ino index 70f8bb0..f387759 100644 --- a/simulator/send-random/send-random.ino +++ b/simulator/send-random/send-random.ino @@ -36,7 +36,7 @@ void sendvalues(void) { int foo; - Serial.print("X "); + Serial.print("X"); for (foo=0; foo Date: Sat, 29 Dec 2018 12:09:34 +0100 Subject: [PATCH 011/110] select in 'get_byte_to' don't work --- serial/serial.c | 14 +++++++++----- serial/t.c | 51 +++++++++++++------------------------------------ 2 files changed, 22 insertions(+), 43 deletions(-) diff --git a/serial/serial.c b/serial/serial.c index 527d304..ac2abc3 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -86,7 +86,7 @@ if (uart0 < 0) baudbits = baudrate2const(baudrate); -#if DEBUG_LEVEL +#if DEBUG_LEVEL > 1 fprintf(stderr, "%d -> 0x%04x\n", baudrate, baudbits); #endif @@ -97,6 +97,9 @@ options.c_cflag = baudbits | CS8 | CLOCAL | CREAD; options.c_iflag = IGNPAR; options.c_oflag = 0; options.c_lflag = 0; + +options.c_cc[VMIN] = 1; /* ask for blocking read */ + tcflush(uart0, TCIFLUSH); tcsetattr(uart0, TCSANOW, &options); @@ -133,9 +136,9 @@ struct timeval timeout; fd_set rfds; int retval; -timeout.tv_sec = to_ms / 1000; +timeout.tv_sec = to_ms / 1000; timeout.tv_usec = (to_ms % 1000) * 1000; -#if DEBUG_LEVEL +#if DEBUG_LEVEL > 1 fprintf(stderr, "timeout %6d is %4ld.%6ld\n", to_ms, timeout.tv_sec, timeout.tv_usec); #endif @@ -145,7 +148,7 @@ FD_SET (fd, &rfds); retval = select(1, &rfds, NULL, NULL, &timeout); #if DEBUG_LEVEL -fprintf(stderr, "%s : select -> %d\n", __func__, retval); +fprintf(stderr, "%s : select on %d -> %d\n", __func__, fd, retval); #endif switch (retval) { @@ -156,7 +159,8 @@ switch (retval) { break; case 0: - fprintf(stderr, "timeout\n"); + fprintf(stderr, "timeout %ld.%ld\n", + timeout.tv_sec, timeout.tv_usec); retval = -99; break; diff --git a/serial/t.c b/serial/t.c index 2a72e37..25e0cf7 100644 --- a/serial/t.c +++ b/serial/t.c @@ -1,4 +1,7 @@ - +/* + * Experiments with the serial input + * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + */ #include #include @@ -14,63 +17,35 @@ int verbosity; -/* ----------------------------------------------------- */ -int openserial(char *dev) -{ -int uart; - -fprintf(stderr, "%s ( %s )\n", __func__, dev); -uart = open(dev, O_RDONLY | O_NOCTTY); -if (uart < 0) - { - perror("unable to open uart"); - exit(1); - } -return uart; -} -/* ----------------------------------------------------- */ -int configserial(int fd) -{ -struct termios tios; -bzero(&tios, sizeof(tios)); -tios.c_cflag = B9600 | CRTSCTS | CS8 | CLOCAL | CREAD; -tios.c_lflag = ICANON; -tios.c_cc[VMIN] = 1; /* read bloquant ??? */ -tcsetattr(fd,TCSANOW,&tios); -return 0; -} -/* ----------------------------------------------------- */ +/* ---------------------------------------------------------------- */ int main (int argc, char *argv[]) { int serial_in, foo; -unsigned char byte; if (2 != argc) { fprintf(stderr, "give me a device name, please.\n"); return 2; } -serial_in = openserial(argv[1]); -fprintf(stderr, "openserial -> %d\n", serial_in); - -(void)configserial(serial_in); +serial_in = prepare_UART(argv[1], 9600); +fprintf(stderr, "going to listen on %d\n", serial_in); for (;;) { - foo = read(serial_in, &byte, 1); - if (1 != foo) { + foo = getbyte_to(serial_in, 50000); + if (foo < 0) { fprintf(stderr, "get byte : got %d, err is %d\n", foo, errno); } else { - printf("%9ld $%02x ", time(NULL), byte); - if (isprint(byte)) putchar(byte); + printf("%9ld $%02x ", time(NULL), foo); + if (isprint(foo)) putchar(foo); puts(""); - if ('\n'==byte) puts(""); + if ('\n'==foo) puts(""); } } return 0; } -/* ----------------------------------------------------- */ +/* ---------------------------------------------------------------- */ From 6aa2a26becad2ea89011f3062f37ee61e062f6aa Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 29 Dec 2018 17:07:23 +0100 Subject: [PATCH 012/110] workaround the infamous select() bug : first milestone, demo code is coming --- .gitignore | 3 +++ serial/Makefile | 7 +++++-- serial/funcs.c | 26 ++++++++++++++++++++++++++ serial/serial.c | 15 +++++++++++++-- serial/serial.h | 4 ++++ serial/t.c | 24 ++++++++++++------------ simulator/send-random/send-random.ino | 4 ++-- 7 files changed, 65 insertions(+), 18 deletions(-) create mode 100644 serial/funcs.c diff --git a/.gitignore b/.gitignore index 5a276e4..b0aef2a 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,7 @@ doc/*.idx doc/*.ilg doc/*.ind +*/foo.dat + + diff --git a/serial/Makefile b/serial/Makefile index 984dabe..492d6af 100644 --- a/serial/Makefile +++ b/serial/Makefile @@ -4,6 +4,9 @@ OPT = -Wall -DDEBUG_LEVEL=1 serial.o: serial.c serial.h Makefile gcc ${OPT} -c $< -t: t.c serial.o Makefile - gcc ${OPT} $< serial.o -o $@ +funcs.o: funcs.c serial.h Makefile + gcc ${OPT} -c $< + +t: t.c serial.o funcs.o Makefile + gcc ${OPT} $< serial.o funcs.o -o $@ diff --git a/serial/funcs.c b/serial/funcs.c new file mode 100644 index 0000000..52eb1b3 --- /dev/null +++ b/serial/funcs.c @@ -0,0 +1,26 @@ + +#include + +#include "serial.h" + +extern int verbosity; + +/* ---------------------------------------------------------------- */ +int parseXvalue(char *line, char cflag) +{ +int value, foo; +int vrd[4]; + +value=0; + +foo = sscanf(data+1, "%d %d %d %d", vrd, vrd+1, vrd+2, vrd+3); +fprintf(stderr, "sscanf -> %d\n", foo); +if (4 != foo) { + return -666; + } +for (foo=0; foo<4; foo++) { + value += vrd[foo]; + } +return value; +} +/* ---------------------------------------------------------------- */ diff --git a/serial/serial.c b/serial/serial.c index ac2abc3..4854e65 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -148,7 +148,7 @@ FD_SET (fd, &rfds); retval = select(1, &rfds, NULL, NULL, &timeout); #if DEBUG_LEVEL -fprintf(stderr, "%s : select on %d -> %d\n", __func__, fd, retval); +fprintf(stderr, "%s : select on fd %d -> %d\n", __func__, fd, retval); #endif switch (retval) { @@ -187,12 +187,22 @@ int getline_to(int fd, char *where, int szm, int to_ms) { int curpos, byte, retval; +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %d %p %d %d )\n", __func__, + fd, where, szm, to_ms); +#endif + curpos = 0; retval = -7; /* magic number powa */ where[0] = '\0'; /* erase all the bs */ for(;;) { - byte = getbyte_to (fd, to_ms); + if (to_ms) { + byte = getbyte_to (fd, to_ms); + } + else { + byte = getbyte(fd); + } if (byte < 0) { fprintf(stderr, "%s : somthing is wrong %d\n", @@ -204,6 +214,7 @@ for(;;) { if ('\n' == byte) { /* got an EOL ? */ where[curpos] = '\0'; retval = curpos; + break; } if (curpos < szm) { /* ya de la place */ diff --git a/serial/serial.h b/serial/serial.h index a13d292..294d3c4 100644 --- a/serial/serial.h +++ b/serial/serial.h @@ -14,4 +14,8 @@ int getbyte_to (int fd, int to_ms); int getline_to(int fd, char *where, int szm, int to_ms); +/* auxiliary and test functions */ + +int parseXvalue(char *asciidatas, char id); + diff --git a/serial/t.c b/serial/t.c index 25e0cf7..84d5d05 100644 --- a/serial/t.c +++ b/serial/t.c @@ -17,10 +17,12 @@ int verbosity; +/* ---------------------------------------------------------------- */ /* ---------------------------------------------------------------- */ int main (int argc, char *argv[]) { -int serial_in, foo; +int serial_in, foo, count; +char ligne[200]; if (2 != argc) { fprintf(stderr, "give me a device name, please.\n"); @@ -31,17 +33,15 @@ serial_in = prepare_UART(argv[1], 9600); fprintf(stderr, "going to listen on %d\n", serial_in); -for (;;) { - foo = getbyte_to(serial_in, 50000); - if (foo < 0) { - fprintf(stderr, "get byte : got %d, err is %d\n", - foo, errno); - } - else { - printf("%9ld $%02x ", time(NULL), foo); - if (isprint(foo)) putchar(foo); - puts(""); - if ('\n'==foo) puts(""); +for (count=0; count<10000; count++) { + foo = getline_to(serial_in, ligne, 100, 0); + fprintf(stderr, "getline #%d -> %d\n", count, foo); + fprintf(stderr, "%s\n", ligne); + foo = parseXvalue(ligne); + fprintf(stderr, "parse -> %d\n", foo); + if (foo>= 0) { + printf("%d %d\n", count, foo); + fflush(stdout); } } diff --git a/simulator/send-random/send-random.ino b/simulator/send-random/send-random.ino index f387759..8496b28 100644 --- a/simulator/send-random/send-random.ino +++ b/simulator/send-random/send-random.ino @@ -26,7 +26,7 @@ void updatevalues(void) values[foo] += (foo + 1); } if (values[foo] > 1023) { - values[foo] = rand()%15; + values[foo] = rand()%25; } } } @@ -48,7 +48,7 @@ void sendvalues(void) void loop() { updatevalues(); sendvalues(); - delay(2500); + delay(800); } /* -------------------------------------------------- */ From 011a1ecd6a4f0d90dc69edd11f64fe3c9b7e7083 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 29 Dec 2018 17:45:31 +0100 Subject: [PATCH 013/110] big hup to romse the cooker --- README.md | 4 +++- doc/dd2-monitoring.tex | 12 +++++++++++- serial/funcs.c | 10 +++++++++- serial/t.c | 2 +- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 9404e2c..6bf5abb 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,9 @@ soir au DD2, à Mixart-Myrys. # WTF status -Le `read` bloquant ne bloque pas. Ça craint grave. +Le `read` bloquant ne bloque pas. Ça craint grave. La recherche +du workaround avance. + diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index a1cf56e..13b0a3d 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -91,6 +91,10 @@ phytotron pose un problème : d'où viennent les premières mesures ? C'est pour ça qu'il y a déja un générateur de \textit{fake-values} qui ne demande qu'à grandir. +Nous avons également un générateur de nombres divers et incohérents +qui envoie des quadruplets d'entiers 10 bits précédés d'un caractere +de bonne efficacité. + \subsection{Exemples} @@ -119,7 +123,7 @@ Au programme : écriture d'un injecteur en Perl\index{Perl}. Il va y avoir deux liaisons série entre l'automate et le monitoring. La première, que nous allons juste entrevoir, passera par le port USB de la carte Arduino. La seconde passera par un port série -auxiliaire\footnote{Il y en a 4 sur le 2560} de celle-ci. +auxiliaire\footnote{Il y en a 4 sur le mega 2560} de celle-ci. \begin{lstlisting} tcgetattr(uart0, &options); @@ -135,6 +139,12 @@ Et en fait, le \texttt{read} sur le \textsl{fd} du serial device n'est pas bloquant, \texttt{perror} annonce \emph{success}, mais rien ne marche. L'année 2019 va commencer sur du vaudou programming. +\textit{29 décembre 2018} : le petit grain de magie\index{magie} +est très simple à mettre en oeuvre, mais +très difficle à spotter dans le gazillion d'options. Il semblerait +que mettre \texttt{options.c\_cc[VMIN]} à 1 permet d'avancer vers +l'étape suivante. + % ------------------------------------------------------------------- \section{Détournements} diff --git a/serial/funcs.c b/serial/funcs.c index 52eb1b3..090bf76 100644 --- a/serial/funcs.c +++ b/serial/funcs.c @@ -13,7 +13,15 @@ int vrd[4]; value=0; -foo = sscanf(data+1, "%d %d %d %d", vrd, vrd+1, vrd+2, vrd+3); +if ( 'X' != *line ) { + 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); fprintf(stderr, "sscanf -> %d\n", foo); if (4 != foo) { return -666; diff --git a/serial/t.c b/serial/t.c index 84d5d05..13efc2d 100644 --- a/serial/t.c +++ b/serial/t.c @@ -37,7 +37,7 @@ for (count=0; count<10000; count++) { foo = getline_to(serial_in, ligne, 100, 0); fprintf(stderr, "getline #%d -> %d\n", count, foo); fprintf(stderr, "%s\n", ligne); - foo = parseXvalue(ligne); + foo = parseXvalue(ligne, 'X'); fprintf(stderr, "parse -> %d\n", foo); if (foo>= 0) { printf("%d %d\n", count, foo); From 2a2f7c735f053b2f35e5615a0617f07d83298a90 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 31 Dec 2018 17:19:52 +0100 Subject: [PATCH 014/110] dernier commit de 2018 --- serial/Makefile | 2 +- serial/README.md | 4 +++- serial/funcs.c | 6 ++++-- serial/serial.c | 2 +- serial/t.c | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/serial/Makefile b/serial/Makefile index 492d6af..6448e47 100644 --- a/serial/Makefile +++ b/serial/Makefile @@ -1,5 +1,5 @@ -OPT = -Wall -DDEBUG_LEVEL=1 +OPT = -Wall -DDEBUG_LEVEL=0 serial.o: serial.c serial.h Makefile gcc ${OPT} -c $< diff --git a/serial/README.md b/serial/README.md index f531775..11c1629 100644 --- a/serial/README.md +++ b/serial/README.md @@ -28,7 +28,9 @@ domaine de la magie noire. Mais quand même, coincer sur un `read` qui 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. +plein de subtilités entre les diverses variantes d'Arduino. Mais pas que. + + diff --git a/serial/funcs.c b/serial/funcs.c index 090bf76..9dfe358 100644 --- a/serial/funcs.c +++ b/serial/funcs.c @@ -13,7 +13,7 @@ int vrd[4]; value=0; -if ( 'X' != *line ) { +if ( cflag != *line ) { if (verbosity) { fprintf(stderr, "%s line[0] 0x%x bad\n", __func__, *line); @@ -22,7 +22,9 @@ if ( 'X' != *line ) { } foo = sscanf(line+1, "%d %d %d %d", vrd, vrd+1, vrd+2, vrd+3); -fprintf(stderr, "sscanf -> %d\n", foo); +#if DEBUG_LEVEL +fprintf(stderr, "%s : sscanf -> %d\n", __func__, foo); +#endif if (4 != foo) { return -666; } diff --git a/serial/serial.c b/serial/serial.c index 4854e65..f6df3f4 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -205,7 +205,7 @@ for(;;) { } if (byte < 0) { - fprintf(stderr, "%s : somthing is wrong %d\n", + fprintf(stderr, "%s : something is wrong %d\n", __func__, byte); retval = byte; break; diff --git a/serial/t.c b/serial/t.c index 13efc2d..03f67bb 100644 --- a/serial/t.c +++ b/serial/t.c @@ -33,12 +33,12 @@ serial_in = prepare_UART(argv[1], 9600); fprintf(stderr, "going to listen on %d\n", serial_in); -for (count=0; count<10000; count++) { +for (count=0; count<100000; count++) { foo = getline_to(serial_in, ligne, 100, 0); fprintf(stderr, "getline #%d -> %d\n", count, foo); fprintf(stderr, "%s\n", ligne); foo = parseXvalue(ligne, 'X'); - fprintf(stderr, "parse -> %d\n", foo); + // fprintf(stderr, "parse -> %d\n", foo); if (foo>= 0) { printf("%d %d\n", count, foo); fflush(stdout); From 4447ed460e36348e410288c30cd6e15bb107ba34 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 3 Jan 2019 16:26:46 +0100 Subject: [PATCH 015/110] rrdb : first working code --- .gitignore | 4 +++- gnocchi/README.md | 9 +++++---- influxdb/README.md | 5 ++++- rrdb/README.md | 14 ++++++++++++++ rrdb/commun.sh | 6 ++++++ rrdb/create.sh | 21 +++++++++++++++++++++ rrdb/getvalues.sh | 19 +++++++++++++++++++ rrdb/insert.sh | 14 ++++++++++++++ 8 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 rrdb/commun.sh create mode 100755 rrdb/create.sh create mode 100755 rrdb/getvalues.sh create mode 100755 rrdb/insert.sh diff --git a/.gitignore b/.gitignore index b0aef2a..4052870 100644 --- a/.gitignore +++ b/.gitignore @@ -12,7 +12,9 @@ doc/*.idx doc/*.ilg doc/*.ind -*/foo.dat +*/*.dat + +rrdb/*.png diff --git a/gnocchi/README.md b/gnocchi/README.md index e447827..e8ad94e 100644 --- a/gnocchi/README.md +++ b/gnocchi/README.md @@ -2,10 +2,11 @@ ## blabla commercial - - -_The problem that [Gnocchi](https://gnocchi.xyz/) solves is the storage and indexing of -time series data and resources at a large scale. +_The problem that [Gnocchi](https://gnocchi.xyz/) solves is the storage and +indexing of time series data and resources at a large scale. This is useful in modern cloud platforms which are not only huge but also are dynamic and potentially multi-tenant. Gnocchi takes all of that into account._ + +Bref, il faut essayer ce truc. Un de ces jours... + diff --git a/influxdb/README.md b/influxdb/README.md index 8a603ab..f949aa4 100644 --- a/influxdb/README.md +++ b/influxdb/README.md @@ -12,7 +12,10 @@ purpose-built platform that InfluxData provides._ # On essaye ? -Ok, c'est parti. On va écrire un injecteur en Perl. Puis enchainer sur +Ok, c'est parti. Premier souci, la documentation est assez légère. + + +On va tenter d'écrire un injecteur en Perl. Puis enchainer sur une visualisation dynamique des données en lancer de rayon. Projet ambitieux ? Non, la suite sera bien pire. diff --git a/rrdb/README.md b/rrdb/README.md index 74d6528..1caad84 100644 --- a/rrdb/README.md +++ b/rrdb/README.md @@ -6,11 +6,25 @@ loin d'être évidente pour les newbies. La lecture de la manpage `rrdtutorial` est indispensable. +https://oss.oetiker.ch/rrdtool/tut/rrd-beginners.en.html + ## premier exemple +Un petit peu de code fabriqué à la rache. + +- `create.sh` +- `update.sh` +- `getvalues.sh` + +Suffisant pour comprendre le principe général, mais très flou +sur les détails. ## et après ? +Trouver une interface en C pour faciliter la vie des gens. + + + diff --git a/rrdb/commun.sh b/rrdb/commun.sh new file mode 100644 index 0000000..8b72f42 --- /dev/null +++ b/rrdb/commun.sh @@ -0,0 +1,6 @@ +# +# commun definitions for rrdb tests +# + +export RRDB=$HOME/TMP/tests.rrd + diff --git a/rrdb/create.sh b/rrdb/create.sh new file mode 100755 index 0000000..ebd852c --- /dev/null +++ b/rrdb/create.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +# +# creating the test database +# + +source ./commun.sh + +starttime=$(date +'%s') + +echo creating $RRDB at ${starttime}s since epoch + +rrdtool create $RRDB \ + --start $starttime \ + --step 60 \ + DS:value:GAUGE:150:0:10 \ + RRA:AVERAGE:0.5:1:60 + + + + \ No newline at end of file diff --git a/rrdb/getvalues.sh b/rrdb/getvalues.sh new file mode 100755 index 0000000..861ade4 --- /dev/null +++ b/rrdb/getvalues.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +source ./commun.sh + +rrdtool fetch $RRDB LAST | +tr -d ':' | +awk ' + (!/nan/ && NF==2) { print $1, $2 } + ' \ + > toto + +gnuplot << __EOC__ +set term png size 800,600 +set output "graphe.png" +plot "toto" with lines +__EOC__ + +rm toto + diff --git a/rrdb/insert.sh b/rrdb/insert.sh new file mode 100755 index 0000000..3990eb0 --- /dev/null +++ b/rrdb/insert.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +source ./commun.sh + +ctime=$(date +'%s') +value=$(cut -d ' ' -f 1 /proc/loadavg) + +# write value to a file +echo ${ctime} ${value} | tee -a bar.dat + +# inject value in the rrdb file +rrdtool update $RRDB ${ctime}:${value} + + From 8fd8381fc3d6347dfbcffa9ea2920cabe2277496 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 3 Jan 2019 16:41:02 +0100 Subject: [PATCH 016/110] rrdb : updating doc --- doc/dd2-monitoring.tex | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 13b0a3d..3694ee8 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -107,12 +107,22 @@ Bla bla bla\dots Corrélations, toussa\dots Peut-être demander à Schmod777 des références de documents bourbakistes ? +% ------------------------------------------------------------------- +\section{RRDB} \label{rrdb} +Première tentative d'utilisation le lendemain du premier apéro 2019 +du Tetalab\footnote{Jean-Yves, je vous demande de vous calmer !}. + +Je suis parti sur trois scripts shell, pour créer, mettre à jour et +exploiter l'enregistrement d'une valeur de type \textsc{gauge}. % ------------------------------------------------------------------- \section{InfluxDB} \label{influxdb} +La communication avec la bédédé se fait \textit{over HTTP}, un peu +comme tous ces trucs de d'jeunz d'aujourd'hui\dots + Au programme : écriture d'un injecteur en Perl\index{Perl}. @@ -145,6 +155,10 @@ très difficle à spotter dans le gazillion d'options. Il semblerait que mettre \texttt{options.c\_cc[VMIN]} à 1 permet d'avancer vers l'étape suivante. +Laquelle étape est une tentative d'utilisation de \texttt{select(2)}, +dans l'objectif de pouvoir gérer nous-même le \textit{timeout}, +qui n'est pas du tout concluante. + % ------------------------------------------------------------------- \section{Détournements} From 5aa3f73daac92f9465129297f8d951cea0e0ce4e Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 3 Jan 2019 17:05:55 +0100 Subject: [PATCH 017/110] rrdb : improving doc and code --- doc/dd2-monitoring.tex | 64 ++++++++++++++++++++++++++++++++++++++++-- rrdb/getvalues.sh | 12 ++++++-- 2 files changed, 70 insertions(+), 6 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 3694ee8..8bc88f5 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -68,7 +68,7 @@ par exemple si des algues\footnote{ou des pleurotes.} tentent de s'échapper. Pour entreposer toutes ces valeurs numériques, il existe plusieurs choix, et nous allons en évaluer quelques uns : -\texttt{rrdb}\index{rrdb}, +\texttt{rrdb}\index{rrdb} (page \pageref{rrdb}), \texttt{influxdb}\index{influxdb} (page \pageref{influxdb}), \texttt{gnocchi}\index{gnocchi}... @@ -100,6 +100,8 @@ de bonne efficacité. Promis, on va en mettre ! Dès que ça marche\dots +Premier exemple avec rrdb en page \pageref{rrdb}. + \subsection{Analyses} Bla bla bla\dots Corrélations, toussa\dots @@ -114,7 +116,62 @@ Première tentative d'utilisation le lendemain du premier apéro 2019 du Tetalab\footnote{Jean-Yves, je vous demande de vous calmer !}. Je suis parti sur trois scripts shell, pour créer, mettre à jour et -exploiter l'enregistrement d'une valeur de type \textsc{gauge}. +analyser les enregistrements d'une valeur de type \textsc{gauge}. + +\subsection{Create} +\begin{lstlisting} +#!/bin/bash + +source ./commun.sh + +starttime=$(date +'%s') +echo creating $RRDB at ${starttime}s since epoch +rrdtool create $RRDB \ + --start $starttime \ + --step 60 \ + DS:value:GAUGE:150:0:10 \ + RRA:AVERAGE:0.5:1:60 +\end{lstlisting} + +\subsection{Update} +\index{rrdtool} +\begin{lstlisting} +#!/bin/bash + +source ./commun.sh +ctime=$(date +'%s') +value=$(cut -d ' ' -f 1 /proc/loadavg) + +# inject value in the rrdb file +rrdtool update $RRDB ${ctime}:${value} +\end{lstlisting} + +\subsection{Analyze} +\begin{lstlisting} +#!/bin/bash + +source ./commun.sh +tmpf="somevalues.dat" + +rrdtool fetch $RRDB LAST | +tr -d ':' | +awk ' + (!/nan/ && NF==2) { print $1, $2 } + ' \ + > ${tmpf} + +# as an example, we are gnuploting our datas +gnuplot << __EOC__ +set term png size 800,600 +set output "graphe.png" +set grid +plot "${tmpf}" with lines +__EOC__ + +rm ${tmpf} +\end{lstlisting} + + % ------------------------------------------------------------------- @@ -123,7 +180,8 @@ exploiter l'enregistrement d'une valeur de type \textsc{gauge}. La communication avec la bédédé se fait \textit{over HTTP}, un peu comme tous ces trucs de d'jeunz d'aujourd'hui\dots -Au programme : écriture d'un injecteur en Perl\index{Perl}. +Au programme : écriture d'un injecteur en Perl\index{Perl}, en suivant +plus ou moins l'exemple de rrdb.. % ------------------------------------------------------------------- diff --git a/rrdb/getvalues.sh b/rrdb/getvalues.sh index 861ade4..43fedf1 100755 --- a/rrdb/getvalues.sh +++ b/rrdb/getvalues.sh @@ -2,18 +2,24 @@ source ./commun.sh +tmpf="somevalues.dat" + rrdtool fetch $RRDB LAST | tr -d ':' | awk ' (!/nan/ && NF==2) { print $1, $2 } ' \ - > toto + > ${tmpf} +# +# as an example, we are gnuploting our datas +# gnuplot << __EOC__ set term png size 800,600 set output "graphe.png" -plot "toto" with lines +set grid +plot "${tmpf}" with lines __EOC__ -rm toto +rm ${tmpf} From 96a2d85f55a41912d81edfe78cc1110953717cb8 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 3 Jan 2019 18:23:34 +0100 Subject: [PATCH 018/110] influxdb : c'est pas de la tarte --- README.md | 13 ++++++++++--- influxdb/create.sh | 13 +++++++++++++ influxdb/injecteur.pl | 3 +++ 3 files changed, 26 insertions(+), 3 deletions(-) create mode 100755 influxdb/create.sh diff --git a/README.md b/README.md index 6bf5abb..266f55d 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,25 @@ de _monitoring_ pour le futur Phytotron du Tetalab. Le but premier de ce système est de faciliter la mise au point d'un automate de contrôle de l'enceinte thermostatée. Nous devrons -surveiller température et humidité du dd2, et température du -confinement biologique. +surveiller température et humidité du dd2, +éclairage et température du confinement biologique. Pour en savoir plus sur ce passionnant projet, il y a le canal IRC `#tetalab` sur le réseau Freenode et/ou les rencontres du mercredi soir au DD2, à Mixart-Myrys. +Et aussi https://pad.tetalab.org/p/dd2-monitoring + # WTF status -Le `read` bloquant ne bloque pas. Ça craint grave. La recherche +Seriazl : Le `read` bloquant ne bloque pas. Ça craint grave. La recherche du workaround avance. +Premier essai RRD : ça marchote... + + + + diff --git a/influxdb/create.sh b/influxdb/create.sh new file mode 100755 index 0000000..40c6481 --- /dev/null +++ b/influxdb/create.sh @@ -0,0 +1,13 @@ +#!/bin/bash + +# +# create an inflix databasse +# + +influx -host localhost -port 8086 << __EOC__ + +settings +CREATE DATABASE tests +__EOC__ + +lynx -head -dump http://localhost:8086/ping?verbose=true \ No newline at end of file diff --git a/influxdb/injecteur.pl b/influxdb/injecteur.pl index 0c54195..c113ea5 100755 --- a/influxdb/injecteur.pl +++ b/influxdb/injecteur.pl @@ -2,6 +2,9 @@ use strict; +$host = "localhost"; +$port = 8086; + print "injecteur v 0\n"; 0; From 82c64d81cb8b090d0d405422fcb4015690910556 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 3 Jan 2019 18:43:23 +0100 Subject: [PATCH 019/110] +my --- influxdb/injecteur.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/influxdb/injecteur.pl b/influxdb/injecteur.pl index c113ea5..7a09954 100755 --- a/influxdb/injecteur.pl +++ b/influxdb/injecteur.pl @@ -2,8 +2,8 @@ use strict; -$host = "localhost"; -$port = 8086; +my $host = "localhost"; +my $port = 8086; print "injecteur v 0\n"; From f546418fb495b44417def67b079fd8f21787b422 Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 4 Jan 2019 14:09:02 +0100 Subject: [PATCH 020/110] enhanced gnuplotting --- rrdb/getvalues.sh | 12 ++++++++---- rrdb/insert.sh | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/rrdb/getvalues.sh b/rrdb/getvalues.sh index 43fedf1..9a28cab 100755 --- a/rrdb/getvalues.sh +++ b/rrdb/getvalues.sh @@ -4,7 +4,8 @@ source ./commun.sh tmpf="somevalues.dat" -rrdtool fetch $RRDB LAST | +rrdtool fetch $RRDB LAST \ + --start 0 | tr -d ':' | awk ' (!/nan/ && NF==2) { print $1, $2 } @@ -15,11 +16,14 @@ awk ' # as an example, we are gnuploting our datas # gnuplot << __EOC__ -set term png size 800,600 +set term png size 1024,512 set output "graphe.png" set grid -plot "${tmpf}" with lines +set xdata time +set timefmt "%s" +set format x "%m/%d\n%H:%M" +plot "${tmpf}" using 1:2 with lines __EOC__ -rm ${tmpf} +# rm ${tmpf} diff --git a/rrdb/insert.sh b/rrdb/insert.sh index 3990eb0..ad5dfbc 100755 --- a/rrdb/insert.sh +++ b/rrdb/insert.sh @@ -5,7 +5,7 @@ source ./commun.sh ctime=$(date +'%s') value=$(cut -d ' ' -f 1 /proc/loadavg) -# write value to a file +# display and write value to a file echo ${ctime} ${value} | tee -a bar.dat # inject value in the rrdb file From 7adc8a27ff4e0c60f5573838580640967773312b Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 4 Jan 2019 19:48:03 +0100 Subject: [PATCH 021/110] bon, c'est pas evident ce truc --- rrdb/README.md | 1 + rrdb/mkgraph.sh | 11 +++++++++++ 2 files changed, 12 insertions(+) create mode 100755 rrdb/mkgraph.sh diff --git a/rrdb/README.md b/rrdb/README.md index 1caad84..1350fad 100644 --- a/rrdb/README.md +++ b/rrdb/README.md @@ -15,6 +15,7 @@ Un petit peu de code fabriqué à la rache. - `create.sh` - `update.sh` - `getvalues.sh` +- `mkgraph.sh` Suffisant pour comprendre le principe général, mais très flou sur les détails. diff --git a/rrdb/mkgraph.sh b/rrdb/mkgraph.sh new file mode 100755 index 0000000..5354f9c --- /dev/null +++ b/rrdb/mkgraph.sh @@ -0,0 +1,11 @@ +#!/bin/bash + +source ./commun.sh + +rrdtool graph value.png \ + --start 0 --end now \ + -w 800 -h 600 \ + DEF:value=${RRDB}:value:LAST \ + LINE1:value#0000FF + + From 44575b9e9f91570ecafb38ab14846969bdb4f8f8 Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 4 Jan 2019 19:56:30 +0100 Subject: [PATCH 022/110] krkrkr --- doc/dd2-monitoring.tex | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 8bc88f5..801da9f 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -58,7 +58,8 @@ Actuellement nous disposons d'un \texttt{RDing TEMPERHUM1V1.2}{} qui semble un peu étrange à interpeller, et qui sera destiné à mesurer l'ambiance météo du DD2\footnote{Pas de mauvais esprit, merci...}. -Par la suite, nous pourrons récupérer (par liaison série ?) des données +Par la suite, nous pourrons récupérer (par liaison série, cf p. \pageref{serial}) +des données en provenance de l'automate de contrôle de l'enceinte. Notre dd2monitor devrait donc aussi être capable d'envoyer des alertes en cas de souci, par exemple si des algues\footnote{ou des pleurotes.} tentent de s'échapper. @@ -115,7 +116,7 @@ documents bourbakistes ? Première tentative d'utilisation le lendemain du premier apéro 2019 du Tetalab\footnote{Jean-Yves, je vous demande de vous calmer !}. -Je suis parti sur trois scripts shell, pour créer, mettre à jour et +Je suis parti sur quelques scripts shell, pour créer, mettre à jour et analyser les enregistrements d'une valeur de type \textsc{gauge}. \subsection{Create} @@ -123,7 +124,6 @@ analyser les enregistrements d'une valeur de type \textsc{gauge}. #!/bin/bash source ./commun.sh - starttime=$(date +'%s') echo creating $RRDB at ${starttime}s since epoch rrdtool create $RRDB \ @@ -133,8 +133,10 @@ rrdtool create $RRDB \ RRA:AVERAGE:0.5:1:60 \end{lstlisting} -\subsection{Update} -\index{rrdtool} +\subsection{Update} \index{rrdtool} + +Une fois la base créée, il faut bien la remplir. + \begin{lstlisting} #!/bin/bash @@ -147,12 +149,15 @@ rrdtool update $RRDB ${ctime}:${value} \end{lstlisting} \subsection{Analyze} + +Nous allons essayer d'exploiter les données dûrement acquises +pendant les heures qui précèdent\dots + \begin{lstlisting} #!/bin/bash source ./commun.sh tmpf="somevalues.dat" - rrdtool fetch $RRDB LAST | tr -d ':' | awk ' @@ -171,7 +176,8 @@ __EOC__ rm ${tmpf} \end{lstlisting} - +Il semble bien que l'utilisation de \texttt{fetch} ne soit pas +vraiment prévue pour ça... % ------------------------------------------------------------------- @@ -186,7 +192,7 @@ plus ou moins l'exemple de rrdb.. % ------------------------------------------------------------------- -\section{Serial coms} \index{serial} +\section{Serial coms} \index{serial} \label{serial} Il va y avoir deux liaisons série entre l'automate et le monitoring. La première, que nous allons juste entrevoir, passera par le port @@ -205,7 +211,8 @@ tcsetattr(uart0, TCSANOW, &options); Et en fait, le \texttt{read} sur le \textsl{fd} du serial device n'est pas bloquant, \texttt{perror} annonce \emph{success}, mais -rien ne marche. L'année 2019 va commencer sur du vaudou programming. +rien ne marche. L'année 2019 va commencer sur du vaudou programming% +\footnote {aka shotgun debugging.}. \textit{29 décembre 2018} : le petit grain de magie\index{magie} est très simple à mettre en oeuvre, mais @@ -215,7 +222,7 @@ l'étape suivante. Laquelle étape est une tentative d'utilisation de \texttt{select(2)}, dans l'objectif de pouvoir gérer nous-même le \textit{timeout}, -qui n'est pas du tout concluante. +laquelle tentative n'est pas du tout concluante. % ------------------------------------------------------------------- From 704a51d3b2a357cf90e0ffa8f9f3a0897dc84c72 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 5 Jan 2019 00:19:12 +0100 Subject: [PATCH 023/110] finalement RRD c'est pas si mal --- doc/dd2-monitoring.tex | 18 ++++++++++++++++-- gnocchi/README.md | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 801da9f..1f2819a 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -69,9 +69,10 @@ par exemple si des algues\footnote{ou des pleurotes.} tentent de s'échapper. Pour entreposer toutes ces valeurs numériques, il existe plusieurs choix, et nous allons en évaluer quelques uns : + \texttt{rrdb}\index{rrdb} (page \pageref{rrdb}), -\texttt{influxdb}\index{influxdb} (page \pageref{influxdb}), -\texttt{gnocchi}\index{gnocchi}... +\texttt{influxdb}\index{Influxdb} (page \pageref{influxdb}), +\texttt{gnocchi}\index{Gnocchi} (page \pageref{gnocchi}) \subsection{Affichage} @@ -120,6 +121,7 @@ Je suis parti sur quelques scripts shell, pour créer, mettre à jour et analyser les enregistrements d'une valeur de type \textsc{gauge}. \subsection{Create} + \begin{lstlisting} #!/bin/bash @@ -136,6 +138,8 @@ rrdtool create $RRDB \ \subsection{Update} \index{rrdtool} Une fois la base créée, il faut bien la remplir. +Dans cet exemple, nous allons utiliser le \textit{load} +de notre Linux. \begin{lstlisting} #!/bin/bash @@ -189,6 +193,16 @@ comme tous ces trucs de d'jeunz d'aujourd'hui\dots Au programme : écriture d'un injecteur en Perl\index{Perl}, en suivant plus ou moins l'exemple de rrdb.. +Ceci dit, en Debian stable, on n'a que la version 1.0, qui ne +correspond plus trop à l'actualité. Et la \textit{current} est +trop fatiguante à compiler pour ce soir. + +% ------------------------------------------------------------------- + +\section{Gnocchi} \label{gnocchi} \index{Gnocchi} + +\texttt{pip install gnocchi[postgresql,ceph,keystone]}, finalement, +çe ne me donne pas trop envie. % ------------------------------------------------------------------- diff --git a/gnocchi/README.md b/gnocchi/README.md index e8ad94e..7f9a5a6 100644 --- a/gnocchi/README.md +++ b/gnocchi/README.md @@ -10,3 +10,6 @@ Gnocchi takes all of that into account._ Bref, il faut essayer ce truc. Un de ces jours... +`pip install gnocchi[postgresql,ceph,keystone]` +bon, on va peut-être attendre :) + From dd359c9f82c15eab18fc42a482b54a52bd1a57d3 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 5 Jan 2019 11:47:51 +0100 Subject: [PATCH 024/110] serial/ structuration du code --- serial/essai.sh | 10 +++++++ serial/funcs.c | 7 +++++ serial/serial.h | 1 + serial/t.c | 72 +++++++++++++++++++++++++++++++++++++------------ 4 files changed, 73 insertions(+), 17 deletions(-) create mode 100755 serial/essai.sh diff --git a/serial/essai.sh b/serial/essai.sh new file mode 100755 index 0000000..3056834 --- /dev/null +++ b/serial/essai.sh @@ -0,0 +1,10 @@ +#!/bin/bash + +DEVICE="/dev/ttyACM0" + +for p in {0..15} +do + echo pass $p + ./t ${DEVICE} | tee -a foo.dat + sleep 8 +done diff --git a/serial/funcs.c b/serial/funcs.c index 9dfe358..99c6ae1 100644 --- a/serial/funcs.c +++ b/serial/funcs.c @@ -34,3 +34,10 @@ for (foo=0; foo<4; foo++) { return value; } /* ---------------------------------------------------------------- */ +int parse4values(char *line, char cflag, float array[4]) +{ + + +return -777; +} +/* ---------------------------------------------------------------- */ diff --git a/serial/serial.h b/serial/serial.h index 294d3c4..6b28d65 100644 --- a/serial/serial.h +++ b/serial/serial.h @@ -17,5 +17,6 @@ int getline_to(int fd, char *where, int szm, int to_ms); /* auxiliary and test functions */ int parseXvalue(char *asciidatas, char id); +int parse4values(char *line, char cflag, float array[4]); diff --git a/serial/t.c b/serial/t.c index 03f67bb..27cb32f 100644 --- a/serial/t.c +++ b/serial/t.c @@ -12,38 +12,76 @@ #include //Used for UART #include #include //Used for UART +#include #include "serial.h" int verbosity; /* ---------------------------------------------------------------- */ +int loop(int sfd, int iters) +{ +int count, foo; +long temps; +char ligne[200]; + +for (count=0; count %d\n", count, foo); + fprintf(stderr, "%s\n", ligne); + } + foo = parseXvalue(ligne, 'X'); + // + if (foo >= 0) { + temps = time(NULL); + printf("%ld %d\n", temps, foo); + fflush(stdout); + } + else { + fprintf(stderr, "%s: parse -> %d\n", __func__, foo); + } + } +return 0; +} /* ---------------------------------------------------------------- */ int main (int argc, char *argv[]) { -int serial_in, foo, count; -char ligne[200]; +int serial_in; +char *device; +int nbre, speed, opt; + +/* set some default values */ +verbosity = 0; +nbre = 25; +speed = 9600; +device = "/dev/ttyACM0"; + +while ((opt = getopt(argc, argv, "d:n:v")) != -1) { + switch (opt) { + case 'v': verbosity++; break; + case 'n': nbre = atoi(optarg); break; + case 'd': device = optarg; break; + + default: + fprintf(stderr, "%s : uh ?", argv[0]); + exit(1); + break; + } -if (2 != argc) { - fprintf(stderr, "give me a device name, please.\n"); - return 2; } -serial_in = prepare_UART(argv[1], 9600); +serial_in = prepare_UART(device, speed); +if (serial_in < 0) { + fprintf(stderr, "%s : open device : error %d on %s\n", + argv[0], serial_in, device); + exit(1); + } fprintf(stderr, "going to listen on %d\n", serial_in); -for (count=0; count<100000; count++) { - foo = getline_to(serial_in, ligne, 100, 0); - fprintf(stderr, "getline #%d -> %d\n", count, foo); - fprintf(stderr, "%s\n", ligne); - foo = parseXvalue(ligne, 'X'); - // fprintf(stderr, "parse -> %d\n", foo); - if (foo>= 0) { - printf("%d %d\n", count, foo); - fflush(stdout); - } - } +(void)loop(serial_in, nbre); return 0; } From 082656860496cb449969c3fdc9542174d78839b2 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 5 Jan 2019 16:15:48 +0100 Subject: [PATCH 025/110] reading 4 values from arduino --- .gitignore | 2 +- serial/essai.sh | 27 +++++++++++++++++++++------ serial/funcs.c | 23 +++++++++++++++++++++-- serial/serial.c | 4 +++- serial/t.c | 7 +++++-- simulator/send-random/send-random.ino | 3 ++- 6 files changed, 53 insertions(+), 13 deletions(-) diff --git a/.gitignore b/.gitignore index 4052870..d3701dc 100644 --- a/.gitignore +++ b/.gitignore @@ -15,6 +15,6 @@ doc/*.ind */*.dat rrdb/*.png - +serial/*.png diff --git a/serial/essai.sh b/serial/essai.sh index 3056834..0222503 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -1,10 +1,25 @@ #!/bin/bash DEVICE="/dev/ttyACM0" +DATAFILE="foo.dat" +IMAGE="graphe.png" +NB_READ=1000 + +./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} + +gnuplot << __EOC__ +set term png size 1024,512 +set output "${IMAGE}" +set grid +set xdata time +set timefmt "%s" +set format x "%H:%M:S" +plot "${DATAFILE}" using 1:2 title "foo" with lines, \ + "${DATAFILE}" using 1:3 title "bar" with lines, \ + "${DATAFILE}" using 1:4 title "quux" with lines, \ + "${DATAFILE}" using 1:5 title "booz" with lines +__EOC__ + +# display ${IMAGE} + -for p in {0..15} -do - echo pass $p - ./t ${DEVICE} | tee -a foo.dat - sleep 8 -done diff --git a/serial/funcs.c b/serial/funcs.c index 99c6ae1..6bbd45a 100644 --- a/serial/funcs.c +++ b/serial/funcs.c @@ -1,5 +1,6 @@ #include +#include #include "serial.h" @@ -15,7 +16,7 @@ value=0; if ( cflag != *line ) { if (verbosity) { - fprintf(stderr, "%s line[0] 0x%x bad\n", + fprintf(stderr, "%s : line[0] 0x%x bad\n", __func__, *line); } return -777; @@ -36,8 +37,26 @@ return value; /* ---------------------------------------------------------------- */ int parse4values(char *line, char cflag, float array[4]) { +float ftmp[4]; +int foo; +if ( cflag != *line ) { + if (verbosity) { + fprintf(stderr, "%s : line[0] 0x%x bad\n", + __func__, *line); + } + return -777; + } -return -777; +foo = sscanf(line+1, "%f %f %f %f", ftmp, ftmp+1, ftmp+2, ftmp+3); +if (4 != foo) { + fprintf(stderr, "%s : sscanf -> %d\n", __func__, foo); + return -666; + } +// fprintf(stderr, "\tV %f\n", ftmp[0]); + +memcpy(array, ftmp, 4*sizeof(float)); + +return 4; } /* ---------------------------------------------------------------- */ diff --git a/serial/serial.c b/serial/serial.c index f6df3f4..34c79f5 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -41,7 +41,7 @@ int baudbits; struct termios options; #if DEBUG_LEVEL -fprintf(stderr, "%s ( %s %d )\n", __func__, port, baudrate); +fprintf(stderr, ">>> %s ( %s %d )\n", __func__, port, baudrate); #endif // OPEN THE UART // The flags (defined in fcntl.h): @@ -103,6 +103,8 @@ options.c_cc[VMIN] = 1; /* ask for blocking read */ tcflush(uart0, TCIFLUSH); tcsetattr(uart0, TCSANOW, &options); +tcflush(uart0, TCIFLUSH); /* do it again, sam */ + return uart0; } /* -------------------------------------------------------------------- */ diff --git a/serial/t.c b/serial/t.c index 27cb32f..ed45298 100644 --- a/serial/t.c +++ b/serial/t.c @@ -24,6 +24,7 @@ int loop(int sfd, int iters) int count, foo; long temps; char ligne[200]; +float datas[4]; for (count=0; count %d\n", count, foo); fprintf(stderr, "%s\n", ligne); } - foo = parseXvalue(ligne, 'X'); + foo = parse4values(ligne, 'X', datas); // if (foo >= 0) { temps = time(NULL); - printf("%ld %d\n", temps, foo); + printf("%ld %f %f %f %f\n", temps, + datas[0], datas[1], datas[2], datas[3]); fflush(stdout); } else { fprintf(stderr, "%s: parse -> %d\n", __func__, foo); } + if (verbosity) fprintf(stderr, "\n"); } return 0; } diff --git a/simulator/send-random/send-random.ino b/simulator/send-random/send-random.ino index 8496b28..a937b7b 100644 --- a/simulator/send-random/send-random.ino +++ b/simulator/send-random/send-random.ino @@ -5,6 +5,7 @@ /* -------------------------------------------------- */ #define NBVAL 4 +#define DELAI 1664 int values[NBVAL]; @@ -48,7 +49,7 @@ void sendvalues(void) void loop() { updatevalues(); sendvalues(); - delay(800); + delay(DELAI); } /* -------------------------------------------------- */ From 15ce537f226238a64649592b83e9a91c01e1cb02 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 6 Jan 2019 21:17:33 +0100 Subject: [PATCH 026/110] welcome on board, claire --- serial/README.md | 1 - serial/essai.sh | 12 +++++++----- viz/pg/README.md | 3 +++ 3 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 viz/pg/README.md diff --git a/serial/README.md b/serial/README.md index 11c1629..a89a80a 100644 --- a/serial/README.md +++ b/serial/README.md @@ -1,4 +1,3 @@ - # Serial Input But premier de ce module : recevoir les données fournies par l'automate diff --git a/serial/essai.sh b/serial/essai.sh index 0222503..cedaa1e 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -2,20 +2,22 @@ DEVICE="/dev/ttyACM0" DATAFILE="foo.dat" +TMPFILE="/tmp/dd2data" + IMAGE="graphe.png" -NB_READ=1000 +NB_READ=12000 ./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} gnuplot << __EOC__ -set term png size 1024,512 +set term png size 1600,512 set output "${IMAGE}" set grid set xdata time set timefmt "%s" -set format x "%H:%M:S" -plot "${DATAFILE}" using 1:2 title "foo" with lines, \ - "${DATAFILE}" using 1:3 title "bar" with lines, \ +set format x "%H:%M:%S" +plot "${DATAFILE}" using 1:2 title " foo" with lines, \ + "${DATAFILE}" using 1:3 title " bar" with lines, \ "${DATAFILE}" using 1:4 title "quux" with lines, \ "${DATAFILE}" using 1:5 title "booz" with lines __EOC__ diff --git a/viz/pg/README.md b/viz/pg/README.md new file mode 100644 index 0000000..68198d4 --- /dev/null +++ b/viz/pg/README.md @@ -0,0 +1,3 @@ +# Visualisation avec PyGame + +Welcome on-board, Claire ! From 7e376763b84d480f9b70cc52b272c4f222e147d5 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 6 Jan 2019 21:59:03 +0100 Subject: [PATCH 027/110] finetuning the random sender --- simulator/send-random/send-random.ino | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/simulator/send-random/send-random.ino b/simulator/send-random/send-random.ino index a937b7b..5dbb913 100644 --- a/simulator/send-random/send-random.ino +++ b/simulator/send-random/send-random.ino @@ -5,7 +5,7 @@ /* -------------------------------------------------- */ #define NBVAL 4 -#define DELAI 1664 +#define DELAI 1789 int values[NBVAL]; @@ -23,11 +23,11 @@ void updatevalues(void) { int foo; for (foo=0; foo 1023) { - values[foo] = rand()%25; + values[foo] = rand()%5; } } } From 6fe2c54cfb33fcd0ffe1a8406129113286943aeb Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 10 Jan 2019 01:44:47 +0100 Subject: [PATCH 028/110] boilerplate for ncurses interface --- viz/curses/7segments.c | 21 ++++++++++++ viz/curses/Makefile | 21 ++++++++++++ viz/curses/README.md | 2 ++ viz/curses/ecran.c | 50 +++++++++++++++++++++++++++++ viz/curses/ecran.h | 6 ++++ viz/curses/t.c | 73 ++++++++++++++++++++++++++++++++++++++++++ viz/curses/waterfall.c | 59 ++++++++++++++++++++++++++++++++++ 7 files changed, 232 insertions(+) create mode 100644 viz/curses/7segments.c create mode 100644 viz/curses/Makefile create mode 100644 viz/curses/README.md create mode 100644 viz/curses/ecran.c create mode 100644 viz/curses/ecran.h create mode 100644 viz/curses/t.c create mode 100644 viz/curses/waterfall.c diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c new file mode 100644 index 0000000..fd45595 --- /dev/null +++ b/viz/curses/7segments.c @@ -0,0 +1,21 @@ +/* + * DD2 Monitoring + * + * ncurses seven segment display + */ + +#include +#include +#include +#include +#include + + +#include "ecran.h" + +int verbosity; + +/* ---------------------------------------------------------------- */ + +/* ---------------------------------------------------------------- */ + diff --git a/viz/curses/Makefile b/viz/curses/Makefile new file mode 100644 index 0000000..63d91f6 --- /dev/null +++ b/viz/curses/Makefile @@ -0,0 +1,21 @@ + + +# --------------- *** + +ecran.o: ecran.c Makefile ecran.h + gcc -Wall -c $< + +7segments.o: 7segments.c Makefile + gcc -Wall -c $< + +waterfall.o: waterfall.c Makefile + gcc -Wall -c $< + +# --------------- *** + +OBJ = ecran.o waterfall.o 7segments.o + +t: t.c Makefile $(OBJ) ecran.h + gcc -Wall $< $(OBJ) -lncurses -o $@ + +# --------------- *** diff --git a/viz/curses/README.md b/viz/curses/README.md new file mode 100644 index 0000000..4169e43 --- /dev/null +++ b/viz/curses/README.md @@ -0,0 +1,2 @@ +# Dataviz with AsciiArt + diff --git a/viz/curses/ecran.c b/viz/curses/ecran.c new file mode 100644 index 0000000..46a8ec5 --- /dev/null +++ b/viz/curses/ecran.c @@ -0,0 +1,50 @@ +#include +#include +#include +#include +#include + + +#include "ecran.h" + +int verbosity; + +/* ---------------------------------------------------------------- */ +/* ---------------------------------------------------------------- */ +void barre_inverse(char c, int ligne) +{ +int foo; +standout(); +for (foo=0; foo +#include +#include +#include +#include +#include + +#include "ecran.h" + +int verbosity; + +/* ---------------------------------------------------------------- */ +void demo(int nbl, int k) +{ +int loop; +char line[100]; +WINDOW *water; + +water = open_waterfall("premier essai", 0); + +for (loop=0; loop +#include +#include +#include +#include + + +#include "ecran.h" + +extern int verbosity; + +/* ---------------------------------------------------------------- */ +WINDOW *open_waterfall(char *title, int flags) +{ +WINDOW *win; +int l, c, w, h; + +l = 2; c = 1; +w = COLS - 2; h = LINES -3; + +win = newwin(h, w, l, c); + +return win; +} +/* ---------------------------------------------------------------- */ +int plot_waterfall(WINDOW *wf, float values[4]) +{ +#define TL 1000 +int foo; +char tag, ligne[TL+1]; + +for(foo=0; foo Date: Thu, 10 Jan 2019 14:07:56 +0100 Subject: [PATCH 029/110] first version of ncurses waterfall --- viz/curses/Makefile | 10 ++++--- viz/curses/ecran.c | 17 +++++------ viz/curses/ecran.h | 4 ++- viz/curses/t.c | 34 ++++++++++++++++------ viz/curses/waterfall.c | 66 +++++++++++++++++++++++++++++++++++------- 5 files changed, 98 insertions(+), 33 deletions(-) diff --git a/viz/curses/Makefile b/viz/curses/Makefile index 63d91f6..a275f58 100644 --- a/viz/curses/Makefile +++ b/viz/curses/Makefile @@ -1,21 +1,23 @@ +# --------------- *** +COPT = -Wall -g -DTRACE=0 # --------------- *** ecran.o: ecran.c Makefile ecran.h - gcc -Wall -c $< + gcc $(COPT) -c $< 7segments.o: 7segments.c Makefile - gcc -Wall -c $< + gcc $(COPT) -c $< waterfall.o: waterfall.c Makefile - gcc -Wall -c $< + gcc $(COPT) -c $< # --------------- *** OBJ = ecran.o waterfall.o 7segments.o t: t.c Makefile $(OBJ) ecran.h - gcc -Wall $< $(OBJ) -lncurses -o $@ + gcc $(COPT) $< $(OBJ) -lncurses -o $@ # --------------- *** diff --git a/viz/curses/ecran.c b/viz/curses/ecran.c index 46a8ec5..37dd65b 100644 --- a/viz/curses/ecran.c +++ b/viz/curses/ecran.c @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -21,16 +21,21 @@ standend(); /* refresh(); */ } /* ---------------------------------------------------------------- */ -int fond_ecran(void) +int fond_ecran(char *title) { +char *tp; + #if TRACE int foo; char buffer[200]; #endif +tp = " DD2 MONITORING by tTh 2019 "; +if (NULL != title) tp = title; + barre_inverse('+', 0); standout(); -mvaddstr(0, 2, " DD2 MONITORING by tTh 2019 "); +mvaddstr(0, 2, tp); #if TRACE sprintf(buffer, " ecran %dx%d ", COLS, LINES); foo = strlen(buffer); @@ -39,12 +44,6 @@ mvaddstr(0, COLS-2-foo, buffer); standend(); refresh(); -#if TRACE -fprintf(stderr, "HAUT %3d\n", HAUT); -fprintf(stderr, "HAUT_1 %3d BARRE_1 %3d\n", HAUT_1, BARRE_1); -fprintf(stderr, "HAUT_2 %3d BARRE_2 %3d\n", HAUT_2, BARRE_2); -#endif - return 0; } /* ---------------------------------------------------------------- */ diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index 8fbd681..5f0d60d 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -1,6 +1,8 @@ -int fond_ecran(void); +int fond_ecran(char *titre); WINDOW * open_waterfall(char *title, int flags); +int plot_waterfall(WINDOW *wf, int flags, float values[4]); +int close_waterfall(WINDOW *wf, int notused); diff --git a/viz/curses/t.c b/viz/curses/t.c index 1ce4041..3207949 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -12,20 +12,36 @@ int verbosity; /* ---------------------------------------------------------------- */ void demo(int nbl, int k) { -int loop; -char line[100]; -WINDOW *water; +int loop, foo; +char line[100]; +WINDOW *water; +static float rvals[4]; + water = open_waterfall("premier essai", 0); for (loop=0; loop 1023.0) { + rvals[foo] = (float)(rand() % 15); + } } + + plot_waterfall(water, 1, rvals); + + if (rand()%10 < 1) sleep(1); + } + +close_waterfall(water, 0); + } /* ---------------------------------------------------------------- */ static void finish(int signal) @@ -59,9 +75,9 @@ nonl(); cbreak(); noecho(); keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ -fond_ecran(); +fond_ecran(" Demonstrator "); -demo(1024, 0); +demo(9000, 0); /* * plop, on a fini, restaurer la console diff --git a/viz/curses/waterfall.c b/viz/curses/waterfall.c index 2c16dce..b5c7a57 100644 --- a/viz/curses/waterfall.c +++ b/viz/curses/waterfall.c @@ -22,26 +22,72 @@ WINDOW *open_waterfall(char *title, int flags) WINDOW *win; int l, c, w, h; -l = 2; c = 1; -w = COLS - 2; h = LINES -3; +l = 1; c = 1; +w = COLS - 2; h = LINES - 3; win = newwin(h, w, l, c); +scrollok(win, 1); +waddstr(win, title); waddch(win, '\n'); +wrefresh(win); return win; } /* ---------------------------------------------------------------- */ -int plot_waterfall(WINDOW *wf, float values[4]) +int plot_waterfall(WINDOW *wf, int mode, float values[4]) { #define TL 1000 -int foo; -char tag, ligne[TL+1]; +int foo, idx; +char tag, ligne[TL+1]; +float coef_w; +static long iter; -for(foo=0; foo Date: Thu, 10 Jan 2019 20:35:03 +0100 Subject: [PATCH 030/110] second version of ncurses waterfall --- .gitignore | 1 + viz/curses/7segments.c | 1 - viz/curses/ecran.h | 4 +++- viz/curses/t.c | 4 ++-- viz/curses/waterfall.c | 22 ++++++++++++++-------- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.gitignore b/.gitignore index d3701dc..03de370 100644 --- a/.gitignore +++ b/.gitignore @@ -17,4 +17,5 @@ doc/*.ind rrdb/*.png serial/*.png +/viz/curses/t diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index fd45595..b49b5ab 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -10,7 +10,6 @@ #include #include - #include "ecran.h" int verbosity; diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index 5f0d60d..c2ec246 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -1,4 +1,6 @@ - +/* + * interface ncurses pour dd2 monitoring + */ int fond_ecran(char *titre); diff --git a/viz/curses/t.c b/viz/curses/t.c index 3207949..7b35db7 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -1,5 +1,5 @@ #include -#include +#include #include #include #include @@ -77,7 +77,7 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ fond_ecran(" Demonstrator "); -demo(9000, 0); +demo(90000, 0); /* * plop, on a fini, restaurer la console diff --git a/viz/curses/waterfall.c b/viz/curses/waterfall.c index b5c7a57..30715fa 100644 --- a/viz/curses/waterfall.c +++ b/viz/curses/waterfall.c @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include @@ -42,23 +42,22 @@ float coef_w; static long iter; if (0 == (iter%10)) { - memset(ligne, '-', TL); + memset(ligne, '.', TL); } else { memset(ligne, ' ', TL); } -for (foo=0; foo<500; foo+=10) { - ligne[foo] = '|'; +for (foo=0; foo<500; foo+=20) { + ligne[foo] = '.'; } ligne[COLS-4] = '\0'; iter++; -coef_w = (float)(COLS-2) / 1024.0; +coef_w = (float)(COLS-3) / 1024.0; -#if TRACE -sprintf(ligne, "coef_w = %f\n", coef_w); -waddstr(wf, ligne); waddch(wf, '\n'); +#if TRACE > 1 +fprintf(stderr, "COLS = %d, coef_w = %f\n", COLS, coef_w); #endif switch (mode) { @@ -76,8 +75,15 @@ switch (mode) { tag = "ATOX"[foo]; idx = (int)(values[foo]*coef_w); ligne[idx] = tag; +#if TRACE + fprintf(stderr, "%c %3d ", tag, idx); +#endif } ligne[COLS-4] = '\0'; +#if TRACE + fprintf(stderr, "\n"); fflush(stderr); +#endif + break; } From 7332f876540b11b92115fdb399cd6753a02d6f3a Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 12 Jan 2019 16:26:15 +0100 Subject: [PATCH 031/110] premiere mesure de temperature avec le LM35 --- serial/essai.sh | 4 ++-- serial/t.c | 2 +- simulator/rdtemp/rdtemp.ino | 47 +++++++++++++++++++++++++++++++++++++ viz/curses/7segments.c | 35 +++++++++++++++++++++++++++ viz/curses/ecran.c | 2 +- viz/curses/t.c | 8 +++---- 6 files changed, 90 insertions(+), 8 deletions(-) create mode 100644 simulator/rdtemp/rdtemp.ino diff --git a/serial/essai.sh b/serial/essai.sh index cedaa1e..854ac44 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,9 +5,9 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=12000 +NB_READ=50 -./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} +./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} gnuplot << __EOC__ set term png size 1600,512 diff --git a/serial/t.c b/serial/t.c index ed45298..fe72b05 100644 --- a/serial/t.c +++ b/serial/t.c @@ -33,7 +33,7 @@ for (count=0; count %d\n", count, foo); fprintf(stderr, "%s\n", ligne); } - foo = parse4values(ligne, 'X', datas); + foo = parse4values(ligne, 'T', datas); // if (foo >= 0) { temps = time(NULL); diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino new file mode 100644 index 0000000..cf28832 --- /dev/null +++ b/simulator/rdtemp/rdtemp.ino @@ -0,0 +1,47 @@ +/* + * lecture des capteurs de temperature LM35 + */ +/* -------------------------------------------------- */ + +#define NBVAL 4 +#define DELAI 5000 + +int values[NBVAL]; + +/* -------------------------------------------------- */ +void setup() { + Serial.begin(9600); + pinMode(LED_BUILTIN, OUTPUT); + delay(2000); +} +/* -------------------------------------------------- */ +void updatevalues(void) +{ + int foo; + for (foo=0; foo 1023.0) { - rvals[foo] = (float)(rand() % 15); + rvals[foo] = (float)(rand() % 25); } } @@ -77,7 +77,7 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ fond_ecran(" Demonstrator "); -demo(90000, 0); +demo(190000, 0); /* * plop, on a fini, restaurer la console From 8989ff558badbdaf49a5a74a621872c96761f5bf Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 12 Jan 2019 17:13:30 +0100 Subject: [PATCH 032/110] + 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]; From 0b7a862dd233d30da799913ac097958fefb6e9a4 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 12 Jan 2019 17:49:41 +0100 Subject: [PATCH 033/110] mise a l'echelle du graphe --- serial/essai.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/serial/essai.sh b/serial/essai.sh index 0d9a601..1935161 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,7 +5,7 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=160 +NB_READ=15000 ./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} @@ -16,6 +16,7 @@ set grid set xdata time set timefmt "%s" set format x "%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, \ "${DATAFILE}" using 1:4 title "quux" with lines, \ From 3569e8dae9264575487dbf59e3f25240d086d565 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 12 Jan 2019 18:05:28 +0100 Subject: [PATCH 034/110] un peu de doc en plus --- doc/dd2-monitoring.tex | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 1f2819a..00342f9 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -58,9 +58,10 @@ Actuellement nous disposons d'un \texttt{RDing TEMPERHUM1V1.2}{} qui semble un peu étrange à interpeller, et qui sera destiné à mesurer l'ambiance météo du DD2\footnote{Pas de mauvais esprit, merci...}. -Par la suite, nous pourrons récupérer (par liaison série, cf p. \pageref{serial}) -des données -en provenance de l'automate de contrôle de l'enceinte. Notre dd2monitor +Par la suite, nous pourrons récupérer +(par liaison série, cf page \pageref{serial}) +des données en provenance de l'automate de contrôle de l'enceinte. +Notre dd2monitor devrait donc aussi être capable d'envoyer des alertes en cas de souci, par exemple si des algues\footnote{ou des pleurotes.} tentent de s'échapper. @@ -106,7 +107,7 @@ Premier exemple avec rrdb en page \pageref{rrdb}. \subsection{Analyses} -Bla bla bla\dots Corrélations, toussa\dots +Bla bla bla\dots Corrélations, Gnuplot\index{gnuplot}, toussa\dots Peut-être demander à Schmod777 des références de documents bourbakistes ? @@ -195,14 +196,14 @@ plus ou moins l'exemple de rrdb.. Ceci dit, en Debian stable, on n'a que la version 1.0, qui ne correspond plus trop à l'actualité. Et la \textit{current} est -trop fatiguante à compiler pour ce soir. +trop fatiguante à compiler pour ce soir, ni même pour ce week-end. % ------------------------------------------------------------------- \section{Gnocchi} \label{gnocchi} \index{Gnocchi} \texttt{pip install gnocchi[postgresql,ceph,keystone]}, finalement, -çe ne me donne pas trop envie. +çe ne me donne pas trop envie. C'est du genre \textit{usinagaz}. % ------------------------------------------------------------------- @@ -213,6 +214,8 @@ La première, que nous allons juste entrevoir, passera par le port USB de la carte Arduino. La seconde passera par un port série auxiliaire\footnote{Il y en a 4 sur le mega 2560} de celle-ci. +\subsection{Un gros souci} + \begin{lstlisting} tcgetattr(uart0, &options); options.c_cflag = baudbits | CS8 | CLOCAL | CREAD; @@ -238,6 +241,13 @@ Laquelle étape est une tentative d'utilisation de \texttt{select(2)}, dans l'objectif de pouvoir gérer nous-même le \textit{timeout}, laquelle tentative n'est pas du tout concluante. +\subsection{Protocole} \index{protocole} \label{serialprotocol} + +L'automate va avoir plusieurs types de données à envoyer. +Nous allons donc transférer ces valeurs sous forme de ligne +de texte commençant par un caractère clef (par exemple T pour +les températures) et se terminant par un \textit{newline}. + % ------------------------------------------------------------------- \section{Détournements} @@ -246,9 +256,10 @@ Dans le contexte myryssien, il est évident que l'aspect artistique doit être dès le départ pris en compte. Les possibilités ne seront limitées que par votre manque d'imagination. -Mais si vous voulez un petit exemple, imaginez des courbes de température -qui pilotent un \texttt{uGen} de Chuck\index{chuck} ou des algues dont la lumière -envoie du \texttt{cv/gate} en temps réel... +Si vous voulez un petit exemple, imaginez des courbes de température +qui pilotent un \texttt{uGen} de Chuck\index{chuck} ou des algues dont +la lumière envoie du \texttt{cv/gate} en temps réel. +Le tout en n'utilisant que des circuits\index{ampli op} analogiques. From f995b05cdd20b869384f4408c72a02747e6e0619 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 13 Jan 2019 15:34:27 +0100 Subject: [PATCH 035/110] un titre sur le graphe --- serial/essai.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/serial/essai.sh b/serial/essai.sh index 1935161..31a3189 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -13,6 +13,7 @@ gnuplot << __EOC__ set term png size 1600,512 set output "${IMAGE}" set grid +set title "Dans le Double Dragon 2" set xdata time set timefmt "%s" set format x "%H:%M:%S" From f510cbc5240d709c8088e571341833a3cb85cff1 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 13 Jan 2019 21:54:57 +0100 Subject: [PATCH 036/110] un peu de derivation dans la doc --- doc/dd2-monitoring.tex | 60 +++++++++++++++++++++++++++++++++++------- 1 file changed, 51 insertions(+), 9 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 00342f9..6e8ca2e 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -74,11 +74,13 @@ choix, et nous allons en évaluer quelques uns : \texttt{rrdb}\index{rrdb} (page \pageref{rrdb}), \texttt{influxdb}\index{Influxdb} (page \pageref{influxdb}), \texttt{gnocchi}\index{Gnocchi} (page \pageref{gnocchi}) +\texttt{sqlite}\index{sqlite} (page \pageref{sqlite}) + \subsection{Affichage} Nous allons laisser un petit bac-à-sable pour Fred Fermion\index{nodejs}, -qui nous tartine les oreilles depuis trop longtemps avec son machinjs. +qui nous tartine les oreilles depuis bien trop longtemps avec son machin.js. Mais sachez déja que l'automate sera équipé d'un minitel, pourquoi ne pas en mettre un second sur le monitoring ? @@ -101,16 +103,47 @@ de bonne efficacité. \subsection{Exemples} -Promis, on va en mettre ! Dès que ça marche\dots +\textsf{Promis, on va en mettre ! Dès que ça marche\dots} -Premier exemple avec rrdb en page \pageref{rrdb}. +Un premier exemple avec rrdb en page \pageref{rrdb}. +Le second cause des premiers essais du LM35, capteur de +température analogique. \subsection{Analyses} -Bla bla bla\dots Corrélations, Gnuplot\index{gnuplot}, toussa\dots +\textsf{Bla bla bla\dots Corrélations, Gnuplot\index{gnuplot}, toussa\dots} Peut-être demander à Schmod777 des références de -documents bourbakistes ? +documents bourbakistes ? J'ai entendu parler dans \textsc{irc} +de choses étranges, comme ça : + +\textsl{ s/booz/booze pour la courbe qui majore les autres en moyenne serait +d'une criante justesse scientifique ;)} + +Ce qui donne qunad même à réfléchir. À se demander quel savoir +allons-nous pouvir déduire de ces\footnote{non, c'est pas du bigdata.} +chiffres improbables. + + +\subsection{Archivage} \index{archivage} \label{archivage} + +La création de cet outil de surveillance est un long parcours +pavé d'essais et d'erreurs. Tout cela peut générer beaucoup +de données. À titre d'exemple, la capture de température des +premier essais sort environ 800 Ko par jour. +99.99\% de ces chiffres sont inutiles, mais il peut arriver +qu'on désire conserver l'historique d'une +expérience réussie\footnote{En fait, c'est comme ça que la science existe} +ou d'un +\textit{epicfail\footnote{En fait, c'est comme ça que la science avance}}. + +Nous devons donc rencontrer quelqu'un qui maitrise cette partie +de la mouvance détournementale de l'espionnage. + +% ------------------------------------------------------------------- + + + % ------------------------------------------------------------------- \section{RRDB} \label{rrdb} @@ -182,7 +215,8 @@ rm ${tmpf} \end{lstlisting} Il semble bien que l'utilisation de \texttt{fetch} ne soit pas -vraiment prévue pour ça... +vraiment prévue pour ça, donc j'en arrive à la conclusion que +quelque chose m'échappe. % ------------------------------------------------------------------- @@ -259,16 +293,24 @@ Les possibilités ne seront limitées que par votre manque d'imagination. Si vous voulez un petit exemple, imaginez des courbes de température qui pilotent un \texttt{uGen} de Chuck\index{chuck} ou des algues dont la lumière envoie du \texttt{cv/gate} en temps réel. -Le tout en n'utilisant que des circuits\index{ampli op} analogiques. +Le tout en n'utilisant que des circuits\index{ampli op} analogiques, +et peut-être quelques transistors au germanium\index{germanium}. +Ça vous semble peut-être un peu mélangé, mais bon, +c'est facile de comprendre l'esprit. C'est plus délicat d'imaginer. % ------------------------------------------------------------------- -\section{Conclusion}\label{conclusion}\index{conclusion} +\section{Conclusion} \label{conclusion} \index{conclusion} En fait, tout reste à faire. Mais ça peut être un beau projet -aux implications et usages multiples. +aux implications et usages multiples. + +Un couteau suisse de la capture du monde réel, un point pivot +de nos diverses interprétations du +monde\footnote{non, la terre n'est pas plate} et des interactions +étranges entre des paramètres sans relation clairement definie. % ------------------------------------------------------------------- \setlength{\parskip}{0.05cm plus 0.05cm} From f4c0e627ff6718acf67cf8bbbb392eeeab8a862f Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 13 Jan 2019 22:03:47 +0100 Subject: [PATCH 037/110] structure de la rigueur dans le core --- core/wtf.txt | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 core/wtf.txt diff --git a/core/wtf.txt b/core/wtf.txt new file mode 100644 index 0000000..64f950a --- /dev/null +++ b/core/wtf.txt @@ -0,0 +1,7 @@ + + + +Il est temps de se reprendre en main + + + From 9becddcdac3a87ff55d655c3dc82913e77dfa0b5 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 13 Jan 2019 22:22:21 +0100 Subject: [PATCH 038/110] realistic scale --- serial/essai.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serial/essai.sh b/serial/essai.sh index 31a3189..3a4ff81 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -17,7 +17,7 @@ set title "Dans le Double Dragon 2" set xdata time set timefmt "%s" set format x "%H:%M:%S" -set yrange [-5.0 : 30.0] +set yrange [ 5.0 : 30.0] plot "${DATAFILE}" using 1:2 title " foo" with lines, \ "${DATAFILE}" using 1:3 title " bar" with lines, \ "${DATAFILE}" using 1:4 title "quux" with lines, \ From ae4c5334d0479f7beb25ce82455271b6129ea6dd Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 14 Jan 2019 03:20:54 +0100 Subject: [PATCH 039/110] first lut function --- core/Makefile | 13 ++++++++++ core/lut1024.h | 17 ++++++++++++ core/lut1024f.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++ core/mklut.pl | 10 +++++++ core/t.c | 45 ++++++++++++++++++++++++++++++++ serial/t.c | 3 +-- 6 files changed, 155 insertions(+), 2 deletions(-) create mode 100644 core/Makefile create mode 100644 core/lut1024.h create mode 100644 core/lut1024f.c create mode 100755 core/mklut.pl create mode 100644 core/t.c diff --git a/core/Makefile b/core/Makefile new file mode 100644 index 0000000..766f682 --- /dev/null +++ b/core/Makefile @@ -0,0 +1,13 @@ +# +# +# + +lut1024f.o: lut1024f.c lut1024.h + gcc -Wall -c $< + +t: t.c lut1024f.o lut1024.h + gcc -Wall $< lut1024f.o -o $@ + +foo.lut1024f: mklut.pl Makefile + ./mklut.pl quux > $@ + diff --git a/core/lut1024.h b/core/lut1024.h new file mode 100644 index 0000000..f271685 --- /dev/null +++ b/core/lut1024.h @@ -0,0 +1,17 @@ +/* + * LUT 1024 - DEALING WITH DISCRETE VALUES + */ + + +typedef struct { + int flags; + float vals[1024]; + } Lut1024f; + +/* ---------------------------------------------------------------- */ + +int slurp_lut1024f(FILE *fp, Lut1024f *where, int notused); +int load_lut1024f(char *fname, Lut1024f *where, int notused); + +/* ---------------------------------------------------------------- */ + diff --git a/core/lut1024f.c b/core/lut1024f.c new file mode 100644 index 0000000..accf37b --- /dev/null +++ b/core/lut1024f.c @@ -0,0 +1,69 @@ +/* + * LUT 1024 -> FLOAT + */ + +#include +#include +#include + +#include "lut1024.h" + +extern int verbosity; + +/* ---------------------------------------------------------------- */ + +int slurp_lut1024f(FILE *fp, Lut1024f *where, int notused) +{ +int count, foo; + +for(count=0; count<1024; count++) { + foo = fscanf(fp, "%f", &where->vals[foo]); + if (1 != foo) { + fprintf(stderr, "%s: bad read %d\n", __func__, foo); + return -2; + } + } + +return -1; +} + +/* ---------------------------------------------------------------- */ + +int load_lut1024f(char *fname, Lut1024f *where, int notused) +{ +FILE *fplut; +char firstline[100]; +char label[] = "LUT1024F"; +int foo; + +#if DEBUG_LEVEL +fprintg(stderr, ">>> %s ( '%s' %p %d )\n", __func__, + fname, where, notused); +#endif + +if (NULL==(fplut=fopen(fname, "r"))) { + perror(fname); + return -2; + } + +fprintf(stderr, "%s: getting first line\n", __func__); + +if (NULL==fgets(firstline, 20, fplut)) { + fprintf(stderr, "%s: nothing to read from %s\n", + __func__, fname); + return -3; + } + +foo = strncmp(label, firstline, sizeof(label)-1); +if (foo) { + fprintf(stderr, "%s: bad label [%s]\n", __func__, firstline); + exit(5); + } + + +fclose(fplut); + +return -1; +} + +/* ---------------------------------------------------------------- */ diff --git a/core/mklut.pl b/core/mklut.pl new file mode 100755 index 0000000..d0f1892 --- /dev/null +++ b/core/mklut.pl @@ -0,0 +1,10 @@ +#!/usr/bin/perl + +my $foo; + +print "LUT1024F\n"; + +for ($foo=0; $foo<1024; $foo++) { + print rand()*3.30, "\n"; + } +0; \ No newline at end of file diff --git a/core/t.c b/core/t.c new file mode 100644 index 0000000..df47ff2 --- /dev/null +++ b/core/t.c @@ -0,0 +1,45 @@ +/* + * main de test des core functions + */ + +#include +#include +#include + +#include "lut1024.h" + + +int verbosity; + +/* ---------------------------------------------------------------- */ + +int main (int argc, char *argv[]) +{ +int foo, opt; + +/* set some default values */ +verbosity = 0; + + +while ((opt = getopt(argc, argv, "v")) != -1) { + switch (opt) { + case 'v': verbosity++; break; + + + default: + fprintf(stderr, "%s : uh ?", argv[0]); + exit(1); + break; + } + + } + + +foo = load_lut1024f("foo.lut1024f", NULL, 1); + +fprintf(stderr, "chargement de la lut --> %d\n", foo); + +return 0; +} + +/* ---------------------------------------------------------------- */ diff --git a/serial/t.c b/serial/t.c index fef41c6..eed23c6 100644 --- a/serial/t.c +++ b/serial/t.c @@ -53,14 +53,13 @@ return 0; int main (int argc, char *argv[]) { int serial_in; -char *device; +char *device = "/dev/ttyACM0"; int nbre, speed, opt; /* set some default values */ verbosity = 0; nbre = 25; speed = 9600; -device = "/dev/ttyACM0"; while ((opt = getopt(argc, argv, "d:n:v")) != -1) { switch (opt) { From 4c984ebdcca3ec288077c253b8c134a9f774ec29 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 14 Jan 2019 14:04:17 +0100 Subject: [PATCH 040/110] first lut function, suite --- .gitignore | 1 + core/lut1024f.c | 5 +++-- serial/essai.sh | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 03de370..2f0938d 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ a.out fake-values essai serial/t +core/t doc/*.toc doc/*.log diff --git a/core/lut1024f.c b/core/lut1024f.c index accf37b..59dadb2 100644 --- a/core/lut1024f.c +++ b/core/lut1024f.c @@ -20,11 +20,11 @@ for(count=0; count<1024; count++) { foo = fscanf(fp, "%f", &where->vals[foo]); if (1 != foo) { fprintf(stderr, "%s: bad read %d\n", __func__, foo); - return -2; + return -4; } } -return -1; +return 0; } /* ---------------------------------------------------------------- */ @@ -60,6 +60,7 @@ if (foo) { exit(5); } +foo = slurp_lut1024f(fplut, where, 0); fclose(fplut); diff --git a/serial/essai.sh b/serial/essai.sh index 3a4ff81..9d4e8bc 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -10,7 +10,7 @@ NB_READ=15000 ./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} gnuplot << __EOC__ -set term png size 1600,512 +set term png size 3200,512 set output "${IMAGE}" set grid set title "Dans le Double Dragon 2" From 2f2bfa641a5b18794b6c805d224f38b31d6f47cb Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 16 Jan 2019 23:15:20 +0100 Subject: [PATCH 041/110] thinking about dataplotting --- viz/gnuplot/average4v.awk | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100755 viz/gnuplot/average4v.awk diff --git a/viz/gnuplot/average4v.awk b/viz/gnuplot/average4v.awk new file mode 100755 index 0000000..439dc31 --- /dev/null +++ b/viz/gnuplot/average4v.awk @@ -0,0 +1,20 @@ +#!/usr/bin/awk -f + +BEGIN { + flag_debut = 1; + } + + { + if (flag_debut) { + debut = $1 + flag_debut = 0 + } + minutes = ($1-debut) / 60; + val = ($2 + $3 + $4 + $5) / 4.0; + print minutes, val; + } + + + + + From abdfc44cbee4807910c4c4eec3b6aa9fc6ca93da Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 17 Jan 2019 09:07:47 +0100 Subject: [PATCH 042/110] preparation de la lecture du fichier de conf --- core/Makefile | 12 +++++++-- core/config.h | 21 +++++++++++++++ core/dd2-monitor.conf | 10 +++++++ core/parseconf.c | 61 ++++++++++++++++++++++++++++++++++++++++++ core/t.c | 16 +++++++++-- doc/dd2-monitoring.tex | 36 +++++++++++++++++++------ 6 files changed, 144 insertions(+), 12 deletions(-) create mode 100644 core/config.h create mode 100644 core/dd2-monitor.conf create mode 100644 core/parseconf.c diff --git a/core/Makefile b/core/Makefile index 766f682..ee4ad9d 100644 --- a/core/Makefile +++ b/core/Makefile @@ -2,11 +2,19 @@ # # +OBJS = lut1024f.o parseconf.o + lut1024f.o: lut1024f.c lut1024.h gcc -Wall -c $< -t: t.c lut1024f.o lut1024.h - gcc -Wall $< lut1024f.o -o $@ + +parseconf.o: parseconf.c config.h + gcc -Wall -c $< + + + +t: t.c ${OBJS} lut1024.h config.h + gcc -Wall $< ${OBJS} -o $@ foo.lut1024f: mklut.pl Makefile ./mklut.pl quux > $@ diff --git a/core/config.h b/core/config.h new file mode 100644 index 0000000..4c3b105 --- /dev/null +++ b/core/config.h @@ -0,0 +1,21 @@ +/* + * config.h + */ + +#define SZ_STRINGS 200 + +typedef struct { + + int valid; + + + + + } Configuration; + +/* ---------------------------------------------------------------- */ + +int parse_config(char *fname, int flags); +int show_config(char *title); + +/* ---------------------------------------------------------------- */ diff --git a/core/dd2-monitor.conf b/core/dd2-monitor.conf new file mode 100644 index 0000000..5c648c3 --- /dev/null +++ b/core/dd2-monitor.conf @@ -0,0 +1,10 @@ + + + +input_device s /def/ttyACM0 + + + + + + diff --git a/core/parseconf.c b/core/parseconf.c new file mode 100644 index 0000000..70ef497 --- /dev/null +++ b/core/parseconf.c @@ -0,0 +1,61 @@ +/* + * parseconf + */ + +#include +#include + +#include "config.h" + +extern int verbosity; +extern Configuration config; + +/* ---------------------------------------------------------------- */ +int parse_config(char *fname, int flags) +{ +FILE *fp; +char line[SZ_STRINGS+1]; + + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( '%s' $%x )\n", fname, flags); +#endif + +config.valid = 49; + +if (NULL==(fp=fopen(fname, "r"))) { + perror(fname); + return -2; + } + +while (fgets(line, SZ_STRINGS, fp)) + { + /* massage the end of line */ + + /* skip comments */ + + /* seek for keyword */ + + + } + + + +fclose(fp); + +return -1; +} +/* ---------------------------------------------------------------- */ +int show_config(char *title) +{ + +if (verbosity) { + printf("********** %s **********\n", title); + } + +printf("valid %d\n", config.valid); + +puts(""); +return 0; +} +/* ---------------------------------------------------------------- */ diff --git a/core/t.c b/core/t.c index df47ff2..aaf2f3c 100644 --- a/core/t.c +++ b/core/t.c @@ -7,20 +7,28 @@ #include #include "lut1024.h" - +#include "config.h" int verbosity; +Configuration config; + + /* ---------------------------------------------------------------- */ int main (int argc, char *argv[]) { int foo, opt; +char *conffile = "dd2-monitor.conf"; + + +fprintf(stderr, "+\n+ DD2 MONITOR\n+\n"); /* set some default values */ verbosity = 0; + while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { case 'v': verbosity++; break; @@ -35,9 +43,13 @@ while ((opt = getopt(argc, argv, "v")) != -1) { } +foo = parse_config(conffile, 1); +fprintf(stderr, "parse_config(%s) -> %d\n\n", conffile, foo); +show_config("foo"); + foo = load_lut1024f("foo.lut1024f", NULL, 1); -fprintf(stderr, "chargement de la lut --> %d\n", foo); +fprintf(stderr, "chargement de la lut --> %d\n\n", foo); return 0; } diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 6e8ca2e..f49918a 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -15,7 +15,7 @@ \usepackage[verbose]{layout} \makeindex -\setlength{\parskip}{0.25cm plus 0.25cm} +\setlength{\parskip}{0.20cm plus 0.20cm} % ------------------------------------------------------------------- \title{DD2 Monitoring} @@ -76,6 +76,8 @@ choix, et nous allons en évaluer quelques uns : \texttt{gnocchi}\index{Gnocchi} (page \pageref{gnocchi}) \texttt{sqlite}\index{sqlite} (page \pageref{sqlite}) +La représentation interne des valeurs reste à définir pour +la plupart d'entre elles. \subsection{Affichage} @@ -107,7 +109,8 @@ de bonne efficacité. Un premier exemple avec rrdb en page \pageref{rrdb}. Le second cause des premiers essais du LM35, capteur de -température analogique. +température analogique branché sur un Arduino et relié +par un port série (page \pageref{serialcode}). \subsection{Analyses} @@ -121,8 +124,9 @@ de choses étranges, comme ça : d'une criante justesse scientifique ;)} Ce qui donne qunad même à réfléchir. À se demander quel savoir -allons-nous pouvir déduire de ces\footnote{non, c'est pas du bigdata.} +allons-nous pouvoir déduire de ces\footnote{non, c'est pas du bigdata.} chiffres improbables. +(Re-)Découvrir les lois de l'inertie thermique ? \subsection{Archivage} \index{archivage} \label{archivage} @@ -138,12 +142,22 @@ ou d'un \textit{epicfail\footnote{En fait, c'est comme ça que la science avance}}. Nous devons donc rencontrer quelqu'un qui maitrise cette partie -de la mouvance détournementale de l'espionnage. +de la mouvance détournementale de l'espionnage. Yaya\index{Yaya} ? % ------------------------------------------------------------------- +\section{Configuration} \index{configuration} \label{configuration} +Pour adapter cet outil de surveillance aux variations du monde réel, +nous devons nous-même lui décrire ce monde. Une description qui se +fera avec des lignes de la forme '\texttt{input\_device s /dev/ttyACM0}' +qui représentent des tuples +\textit{clef-type-valeur}\footnote{Laissons les canards tranquilles.} +de. +La syntaxe n'est pas encore fixée, mais un fichier exemple est +disponible pour des explication plus récentes, donc plus en +rapport avec la réalité du code. % ------------------------------------------------------------------- \section{RRDB} \label{rrdb} @@ -239,6 +253,11 @@ trop fatiguante à compiler pour ce soir, ni même pour ce week-end. \texttt{pip install gnocchi[postgresql,ceph,keystone]}, finalement, çe ne me donne pas trop envie. C'est du genre \textit{usinagaz}. +% ------------------------------------------------------------------- +\section{Sqlite} \index{sqlite} \label{sqlite} + +\subsection{À regarder de près} + % ------------------------------------------------------------------- \section{Serial coms} \index{serial} \label{serial} @@ -282,6 +301,10 @@ Nous allons donc transférer ces valeurs sous forme de ligne de texte commençant par un caractère clef (par exemple T pour les températures) et se terminant par un \textit{newline}. + +\subsection{Un peu de code} \label{serialcode} + + % ------------------------------------------------------------------- \section{Détournements} @@ -293,11 +316,8 @@ Les possibilités ne seront limitées que par votre manque d'imagination. Si vous voulez un petit exemple, imaginez des courbes de température qui pilotent un \texttt{uGen} de Chuck\index{chuck} ou des algues dont la lumière envoie du \texttt{cv/gate} en temps réel. -Le tout en n'utilisant que des circuits\index{ampli op} analogiques, -et peut-être quelques transistors au germanium\index{germanium}. -Ça vous semble peut-être un peu mélangé, mais bon, -c'est facile de comprendre l'esprit. C'est plus délicat d'imaginer. +\subsection{Variante} % ------------------------------------------------------------------- From fd4da38f2a4638084f90511eb0d31c9bc698c6e9 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 17 Jan 2019 09:35:48 +0100 Subject: [PATCH 043/110] visualiser la moyenne des dernieres mesures --- viz/gnuplot/average4v.awk | 20 +++++++++++++++++--- viz/gnuplot/plot-one.sh | 20 ++++++++++++++++++++ 2 files changed, 37 insertions(+), 3 deletions(-) create mode 100755 viz/gnuplot/plot-one.sh diff --git a/viz/gnuplot/average4v.awk b/viz/gnuplot/average4v.awk index 439dc31..55d7eaf 100755 --- a/viz/gnuplot/average4v.awk +++ b/viz/gnuplot/average4v.awk @@ -2,16 +2,30 @@ BEGIN { flag_debut = 1; + lastminute = 0; + cumul = 0.0; + compte = 0; } +# iterate over all the input lines { if (flag_debut) { debut = $1 flag_debut = 0 } - minutes = ($1-debut) / 60; - val = ($2 + $3 + $4 + $5) / 4.0; - print minutes, val; + minutes = int(($1-debut) / 60); + if (minutes == lastminute) { + val = ($2 + $3 + $4 + $5); + cumul += val; + compte += 4; + } + else { + val = cumul /compte; + print minutes, val; + lastminute = minutes; + cumul = 0; + compte = 0; + } } diff --git a/viz/gnuplot/plot-one.sh b/viz/gnuplot/plot-one.sh new file mode 100755 index 0000000..8cb6427 --- /dev/null +++ b/viz/gnuplot/plot-one.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +INFILE="../../serial/foo.dat" +NBLINES=2000 +TMPFILE="/tmp/dd2data.$$" +IMAGE="average4v.png" + +tail -${NBLINES} ${INFILE} | ./average4v.awk > ${TMPFILE} + +gnuplot << __EOC__ +set term png size 800,600 +set output "${IMAGE}" +set grid +set title "Average4v" +set xlabel "minutes" +set ylabel "température" +set yrange [ 5.0 : 30.0] +plot "${TMPFILE}" with lines +__EOC__ + From 160b9fc49a37fa71d43c3e9d844d48a41da7429e Mon Sep 17 00:00:00 2001 From: phyto Date: Thu, 17 Jan 2019 09:45:57 +0100 Subject: [PATCH 044/110] un-hide the error messages --- exemple.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exemple.sh b/exemple.sh index 60a0d84..80b52ae 100755 --- a/exemple.sh +++ b/exemple.sh @@ -6,7 +6,7 @@ DATAFILE=/tmp/fake-datafile > ${DATAFILE} for s in $(seq 1 2000) do - v=$(./fake-values -s -t 1 2> /dev/null) + v=$(./fake-values -s -t 1) echo $s $v >> ${DATAFILE} done From 63d71d99a7a6f74d7a5a84c542decd158cd7ea50 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 17 Jan 2019 10:57:12 +0100 Subject: [PATCH 045/110] more gnuplotting --- .gitignore | 3 ++- doc/dd2-monitoring.tex | 5 ++++- viz/gnuplot/av4v-h.awk | 34 ++++++++++++++++++++++++++++++++++ viz/gnuplot/plot-one.sh | 14 ++++++++------ viz/gnuplot/plot-two.sh | 22 ++++++++++++++++++++++ 5 files changed, 70 insertions(+), 8 deletions(-) create mode 100755 viz/gnuplot/av4v-h.awk create mode 100755 viz/gnuplot/plot-two.sh diff --git a/.gitignore b/.gitignore index 2f0938d..c41f84f 100644 --- a/.gitignore +++ b/.gitignore @@ -18,5 +18,6 @@ doc/*.ind rrdb/*.png serial/*.png -/viz/curses/t +viz/curses/t +viz/gnuplot/*.png diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index f49918a..5030824 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -127,6 +127,9 @@ Ce qui donne qunad même à réfléchir. À se demander quel savoir allons-nous pouvoir déduire de ces\footnote{non, c'est pas du bigdata.} chiffres improbables. (Re-)Découvrir les lois de l'inertie thermique ? +Générer des formes d'ondes spatialisables ? +Déplacer des petites \textit{bubulles} colorées ? +Une histoire pour la section \pageref{detournements} ? \subsection{Archivage} \index{archivage} \label{archivage} @@ -307,7 +310,7 @@ les températures) et se terminant par un \textit{newline}. % ------------------------------------------------------------------- -\section{Détournements} +\section{Détournements} \label{detournements} Dans le contexte myryssien, il est évident que l'aspect artistique doit être dès le départ pris en compte. diff --git a/viz/gnuplot/av4v-h.awk b/viz/gnuplot/av4v-h.awk new file mode 100755 index 0000000..e8b353d --- /dev/null +++ b/viz/gnuplot/av4v-h.awk @@ -0,0 +1,34 @@ +#!/usr/bin/awk -f + +BEGIN { + flag_debut = 1; + lasthour = 0; + cumul = 0.0; + compte = 0; + } + +# iterate over all the input lines + { + if (flag_debut) { + debut = $1 + flag_debut = 0 + } + heures = int(($1-debut) / 3600); + if (heures == lasthour) { + val = ($2 + $3 + $4 + $5); + cumul += val; + compte += 4; + } + else { + val = cumul /compte; + print heures, val; + lasthour = heures; + cumul = 0; + compte = 0; + } + } + + + + + diff --git a/viz/gnuplot/plot-one.sh b/viz/gnuplot/plot-one.sh index 8cb6427..ff987c8 100755 --- a/viz/gnuplot/plot-one.sh +++ b/viz/gnuplot/plot-one.sh @@ -1,20 +1,22 @@ #!/bin/bash INFILE="../../serial/foo.dat" -NBLINES=2000 +NBLINES=1600 TMPFILE="/tmp/dd2data.$$" -IMAGE="average4v.png" +IMAGE="av4v-m.png" tail -${NBLINES} ${INFILE} | ./average4v.awk > ${TMPFILE} gnuplot << __EOC__ -set term png size 800,600 +set term png size 1280,420 set output "${IMAGE}" set grid -set title "Average4v" -set xlabel "minutes" -set ylabel "température" +set title "Average on the last ${NBLINES} samples" +set xlabel "Minutes" +set ylabel "Température" set yrange [ 5.0 : 30.0] plot "${TMPFILE}" with lines __EOC__ +tail -20 ${TMPFILE} + diff --git a/viz/gnuplot/plot-two.sh b/viz/gnuplot/plot-two.sh new file mode 100755 index 0000000..207b559 --- /dev/null +++ b/viz/gnuplot/plot-two.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +INFILE="../../serial/foo.dat" +NBLINES=50000 +TMPFILE="/tmp/dd2data.$$" +IMAGE="av4v-h.png" + +tail -${NBLINES} ${INFILE} | ./av4v-h.awk > ${TMPFILE} + +gnuplot << __EOC__ +set term png size 1280,420 +set output "${IMAGE}" +set grid +set title "Hourly average on the last ${NBLINES} samples" +set xlabel "Heures" +set ylabel "Température" +set yrange [ 5.0 : 30.0] +plot "${TMPFILE}" with lines +__EOC__ + +cat -n ${TMPFILE} | tail -20 + From dac48f95b8ab3140de1977585dce4a69b5a16e9d Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 17 Jan 2019 11:51:07 +0100 Subject: [PATCH 046/110] moving funcs around the corner --- BUILD.txt | 12 +++++++++++ core/Makefile | 21 +++++++++++++----- core/utils.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++ core/utils.h | 0 funcs.c | 44 -------------------------------------- 5 files changed, 87 insertions(+), 49 deletions(-) create mode 100644 BUILD.txt create mode 100644 core/utils.c create mode 100644 core/utils.h diff --git a/BUILD.txt b/BUILD.txt new file mode 100644 index 0000000..0a7300c --- /dev/null +++ b/BUILD.txt @@ -0,0 +1,12 @@ + +--------------------------------+ + | how to build the dd2-monitor ? | + +--------------------------------+ + +First step, build some parts of the core library : + + $ cd core + $ make t + $ ./t -v + + + diff --git a/core/Makefile b/core/Makefile index ee4ad9d..904efcc 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1,19 +1,30 @@ # +# dd2 monitoring # +# buil the core functions, use with care # -OBJS = lut1024f.o parseconf.o -lut1024f.o: lut1024f.c lut1024.h +COPT = -Wall -fpic -g -DDEBUG_LEVEL=0 +OBJS = lut1024f.o parseconf.o utils.o +DEPS = Makefile + +# --------------------------------------------------- + +libdd2m-core.a: ${OBJS} + +lut1024f.o: lut1024f.c lut1024.h ${DEPS} gcc -Wall -c $< - -parseconf.o: parseconf.c config.h +parseconf.o: parseconf.c config.h ${DEPS} gcc -Wall -c $< +utils.o: utils.c utils.h ${DEPS} + gcc -Wall -c $< +# --------------------------------------------------- -t: t.c ${OBJS} lut1024.h config.h +t: t.c ${OBJS} lut1024.h config.h utils.h ${DEPS} gcc -Wall $< ${OBJS} -o $@ foo.lut1024f: mklut.pl Makefile diff --git a/core/utils.c b/core/utils.c new file mode 100644 index 0000000..f0a2646 --- /dev/null +++ b/core/utils.c @@ -0,0 +1,59 @@ +/* + * core/utils.c + */ + +#include +#include +#include +#include +#include +#include + +extern int verbosity; + +/* --------------------------------------------------------------- */ +int seed_my_rand(int foo) +{ +long v1, v2; + +v1 = getpid(); v2 = time(NULL); + +return v1 ^ v2; +} +/* --------------------------------------------------------------- */ + +int random1000(int type) +{ +int value; + +#if DEBUG_LEVEL > 1 +fprintf(stderr, ">>> %s(%d)\n", __func__, type); +#endif + +switch (type) { + case 0: + value = rand() % 1000; + break; + case 1: + value = (rand()%1000 + rand()%1000) / 2; + break; + default: + value = -1; + break; + } + +return value; +} +/* --------------------------------------------------------------- */ +double dtime(void) +{ +struct timeval tv; +int foo; + +foo = gettimeofday(&tv, NULL); +if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__); + +return (double)tv.tv_sec + (double)tv.tv_usec / 1e6; +} + +/* --------------------------------------------------------------- */ diff --git a/core/utils.h b/core/utils.h new file mode 100644 index 0000000..e69de29 diff --git a/funcs.c b/funcs.c index e280d0c..1b1f199 100644 --- a/funcs.c +++ b/funcs.c @@ -13,50 +13,6 @@ extern int verbosity; -/* --------------------------------------------------------------- */ -int seed_my_rand(int foo) -{ -long v1, v2; - -v1 = getpid(); v2 = time(NULL); - -return v1 ^ v2; -} -/* --------------------------------------------------------------- */ - -int random1000(int type) -{ -int value; -if (verbosity) - fprintf(stderr, ">>> %s(%d)\n", __func__, type); - -switch (type) { - case 0: - value = rand() % 1000; - break; - case 1: - value = (rand()%1000 + rand()%1000) / 2; - break; - default: - value = -1; - break; - } - -return value; -} - -/* --------------------------------------------------------------- */ - -double dtime(void) -{ -struct timeval tv; -int foo; - -foo = gettimeofday(&tv, NULL); -if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__); - -return (double)tv.tv_sec + (double)tv.tv_usec / 1e6; -} /* --------------------------------------------------------------- */ From ed0b1ffa256357e33dd1c8cb34295252d110f9d5 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 17 Jan 2019 12:34:46 +0100 Subject: [PATCH 047/110] adding build instructions --- BUILD.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/BUILD.txt b/BUILD.txt index 0a7300c..fb24a49 100644 --- a/BUILD.txt +++ b/BUILD.txt @@ -7,6 +7,19 @@ First step, build some parts of the core library : $ cd core $ make t $ ./t -v + $ cd .. + +Then you must have datas for working on. One source of datas +is the four values who came from the Arduino over serial line. + + $ cd serial + $ make t + +Have a look at the 'essai.sh' file for an example of simple +usage of the serial input. For generating all that numbers, +you have to run some code on the Arduino mega. Sources are +in the simulator/ folder. + From c848ebd12db0a8268f44ef5e6c84a3ff39764c23 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 17 Jan 2019 13:54:27 +0100 Subject: [PATCH 048/110] + hostname display on ncurses header bar --- viz/curses/ecran.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/viz/curses/ecran.c b/viz/curses/ecran.c index 71f7f71..8807444 100644 --- a/viz/curses/ecran.c +++ b/viz/curses/ecran.c @@ -1,6 +1,8 @@ #include #include #include +#include + #include #include @@ -24,9 +26,10 @@ standend(); int fond_ecran(char *title) { char *tp; +struct utsname utsn; +int foo; #if TRACE -int foo; char buffer[200]; #endif @@ -41,6 +44,14 @@ sprintf(buffer, " ecran %dx%d ", COLS, LINES); foo = strlen(buffer); mvaddstr(0, COLS-2-foo, buffer); #endif + +/* get and display hostname */ +foo = uname(&utsn); +if ( !foo ) { + mvaddstr(0, 2+strlen(tp), "on"); + mvaddstr(0, 5+strlen(tp), utsn.nodename); + } + standend(); refresh(); From e5cc3571309d0f3b77468f357513bd0b850a9b46 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 17 Jan 2019 14:00:17 +0100 Subject: [PATCH 049/110] more work on config parser --- core/dd2-monitor.conf | 1 + core/parseconf.c | 34 ++++++++++++++++++++++++++++------ core/t.c | 4 ++-- core/utils.c | 2 -- core/utils.h | 8 ++++++++ 5 files changed, 39 insertions(+), 10 deletions(-) diff --git a/core/dd2-monitor.conf b/core/dd2-monitor.conf index 5c648c3..2b79cff 100644 --- a/core/dd2-monitor.conf +++ b/core/dd2-monitor.conf @@ -1,4 +1,5 @@ +# experimental config file input_device s /def/ttyACM0 diff --git a/core/parseconf.c b/core/parseconf.c index 70ef497..56af341 100644 --- a/core/parseconf.c +++ b/core/parseconf.c @@ -1,5 +1,5 @@ /* - * parseconf + * core/parseconf.c */ #include @@ -10,12 +10,14 @@ extern int verbosity; extern Configuration config; +#define CMP(a) (!strcmp(cptr, a)) + /* ---------------------------------------------------------------- */ int parse_config(char *fname, int flags) { FILE *fp; -char line[SZ_STRINGS+1]; - +char line[SZ_STRINGS+1], *cptr; +int numligne; #if DEBUG_LEVEL fprintf(stderr, ">>> %s ( '%s' $%x )\n", fname, flags); @@ -28,19 +30,39 @@ if (NULL==(fp=fopen(fname, "r"))) { return -2; } +numligne = 0; + while (fgets(line, SZ_STRINGS, fp)) { + numligne++; + if ('\0'==line[0]) { + fprintf(stderr, "%s : short read line %d\n", + fname, numligne); + fclose(fp); + return -1; + } + /* massage the end of line */ + line[strlen(line)-1] = '\0'; /* kill EOL */ + if (verbosity) { + fprintf(stderr, "%3d :\t%s\n", numligne, line); + } + + /* seek for the first token in this line */ + if (NULL==(cptr = strtok(line, " \t"))) { + /* Got an empty line */ + continue; + } /* skip comments */ + if ('#'==*cptr) continue; + + if(verbosity) fprintf(stderr, "[%s]\n", cptr); - /* seek for keyword */ } - - fclose(fp); return -1; diff --git a/core/t.c b/core/t.c index aaf2f3c..835fa58 100644 --- a/core/t.c +++ b/core/t.c @@ -33,7 +33,6 @@ while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { case 'v': verbosity++; break; - default: fprintf(stderr, "%s : uh ?", argv[0]); exit(1); @@ -47,9 +46,10 @@ foo = parse_config(conffile, 1); fprintf(stderr, "parse_config(%s) -> %d\n\n", conffile, foo); show_config("foo"); +/* foo = load_lut1024f("foo.lut1024f", NULL, 1); - fprintf(stderr, "chargement de la lut --> %d\n\n", foo); +*/ return 0; } diff --git a/core/utils.c b/core/utils.c index f0a2646..17cf615 100644 --- a/core/utils.c +++ b/core/utils.c @@ -21,7 +21,6 @@ v1 = getpid(); v2 = time(NULL); return v1 ^ v2; } /* --------------------------------------------------------------- */ - int random1000(int type) { int value; @@ -55,5 +54,4 @@ if (foo) fprintf(stderr, "got %d in %s\n", foo, __func__); return (double)tv.tv_sec + (double)tv.tv_usec / 1e6; } - /* --------------------------------------------------------------- */ diff --git a/core/utils.h b/core/utils.h index e69de29..b71651c 100644 --- a/core/utils.h +++ b/core/utils.h @@ -0,0 +1,8 @@ +/* + * core/utils.h + */ + +int seed_my_rand(int foo); +int random1000(int type); + +double dtime(void); From 7c8067fc5ae46719deb08ee6bb7756d7c4d40e0c Mon Sep 17 00:00:00 2001 From: phyto Date: Thu, 17 Jan 2019 18:37:30 +0100 Subject: [PATCH 050/110] nettoyer le brotch --- Makefile | 13 ++++++------- essai.c | 33 +++++++++++++++++++++++++++------ fake-values.c | 2 +- funcs.c | 40 ---------------------------------------- funcs.h | 13 ------------- 5 files changed, 34 insertions(+), 67 deletions(-) delete mode 100644 funcs.c delete mode 100644 funcs.h diff --git a/Makefile b/Makefile index 0fe9533..c3b8d06 100644 --- a/Makefile +++ b/Makefile @@ -8,13 +8,12 @@ CCOPT = -Wall -g all: essai fake-values -essai: essai.c funcs.o Makefile - gcc ${CCOPT} $< funcs.o -o $@ +# --------------------------------------------- +essai: essai.c Makefile + gcc ${CCOPT} $< core/utils.o -o $@ -funcs.o: funcs.c funcs.h Makefile - gcc ${CCOPT} -c $< - -fake-values: fake-values.c funcs.o Makefile - gcc ${CCOPT} $< funcs.o -o $@ +fake-values: fake-values.c Makefile + gcc ${CCOPT} $< core/utils.o -o $@ +# --------------------------------------------- diff --git a/essai.c b/essai.c index 0ad7c09..da02dec 100644 --- a/essai.c +++ b/essai.c @@ -5,24 +5,45 @@ #include #include #include +#include -#include "funcs.h" +#include "core/utils.h" -int verbosity; +int verbosity; + +/* --------------------------------------------------------------- */ + +int get_loadavg(double *where) +{ +FILE *fp; +double loads[3]; +int foo; + +if ( ! (fp=fopen("/proc/loadavg", "r")) ) { + perror("read loadavg"); + return -1; + } + +foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2); +if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo); + +memcpy(where, loads, 3 * sizeof(double)); + +fclose(fp); + +return 0; +} /* --------------------------------------------------------------- */ int main(int argc, char *argv[]) { int opt, foo; -int type = 0; double loads[3]; -while ((opt = getopt(argc, argv, "vst:")) != -1) { +while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { case 'v': verbosity++; break; - case 's': srand(getpid()); break; - case 't': type = atoi(optarg); break; default: break; } } diff --git a/fake-values.c b/fake-values.c index 292e8f3..b536d79 100644 --- a/fake-values.c +++ b/fake-values.c @@ -6,7 +6,7 @@ #include #include -#include "funcs.h" +#include "core/utils.h" int verbosity; diff --git a/funcs.c b/funcs.c deleted file mode 100644 index 1b1f199..0000000 --- a/funcs.c +++ /dev/null @@ -1,40 +0,0 @@ -/* - * funcs.c - */ - -#include -#include -#include -#include -#include -#include - -#include "funcs.h" - -extern int verbosity; - - -/* --------------------------------------------------------------- */ - -int get_loadavg(double *where) -{ -FILE *fp; -double loads[3]; -int foo; - -if ( ! (fp=fopen("/proc/loadavg", "r")) ) { - perror("read loadavg"); - return -1; - } - -foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2); -if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo); - -memcpy(where, loads, 3 * sizeof(double)); - -fclose(fp); - -return 0; -} - -/* --------------------------------------------------------------- */ diff --git a/funcs.h b/funcs.h deleted file mode 100644 index 057594b..0000000 --- a/funcs.h +++ /dev/null @@ -1,13 +0,0 @@ -/* - * funcs.c - */ - -/* return an in random value in [0.999] */ -int random1000(int mode); - -/* get the 'timeofday' as a double float */ -double dtime(void); - -/* only usable on standard Linux ! */ -int get_loadavg(double where[]); - From 22fdf52ccbf473ead7ed24712ac65c9519a83888 Mon Sep 17 00:00:00 2001 From: phyto Date: Fri, 18 Jan 2019 15:39:07 +0100 Subject: [PATCH 051/110] makinf a foo.dat fake file --- .gitignore | 1 + essai.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index c41f84f..36e3eae 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ a.out *.o fake-values essai +foo.dat serial/t core/t diff --git a/essai.c b/essai.c index da02dec..33ab9fa 100644 --- a/essai.c +++ b/essai.c @@ -6,6 +6,7 @@ #include #include #include +#include #include "core/utils.h" @@ -40,6 +41,7 @@ int main(int argc, char *argv[]) { int opt, foo; double loads[3]; +int il[3]; while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { @@ -50,8 +52,12 @@ while ((opt = getopt(argc, argv, "v")) != -1) { foo = get_loadavg(loads); if (foo) fprintf(stderr, "get loadavg -> %d\n", foo); +for (foo=0; foo<3; foo++) { + il[foo] = ((int)(loads[foo] * 900.0)) & 0x3ff; + fprintf(stderr, "%f -> %d\n", loads[foo], il[foo]); + } -printf("%f %f %f %f\n", dtime(), loads[0], loads[1], loads[2]); +printf("T %ld %d %d %d %d\n", time(NULL), getpid()%1024, il[0], il[1], il[2]); return 0; } From 5faccb17249eece0d00dc4b27bf1974da5945790 Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 18 Jan 2019 16:27:06 +0100 Subject: [PATCH 052/110] now making the core static library --- core/Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/Makefile b/core/Makefile index 904efcc..f31a15d 100644 --- a/core/Makefile +++ b/core/Makefile @@ -8,10 +8,11 @@ COPT = -Wall -fpic -g -DDEBUG_LEVEL=0 OBJS = lut1024f.o parseconf.o utils.o DEPS = Makefile - +ALIB = libdd2m-core.a # --------------------------------------------------- -libdd2m-core.a: ${OBJS} +${ALIB}: ${OBJS} + ar r $@ $? lut1024f.o: lut1024f.c lut1024.h ${DEPS} gcc -Wall -c $< @@ -24,8 +25,8 @@ utils.o: utils.c utils.h ${DEPS} # --------------------------------------------------- -t: t.c ${OBJS} lut1024.h config.h utils.h ${DEPS} - gcc -Wall $< ${OBJS} -o $@ +t: t.c ${ALIB} lut1024.h config.h utils.h ${DEPS} + gcc -Wall $< ${ALIB} -o $@ foo.lut1024f: mklut.pl Makefile ./mklut.pl quux > $@ From 254ae77e1a4eea56f1bd8c9e5a2c2908cae89712 Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 18 Jan 2019 17:09:15 +0100 Subject: [PATCH 053/110] random things... --- .gitignore | 1 + BUILD.txt | 1 + core/config.h | 2 +- core/dd2-monitor.conf | 9 ++++----- core/parseconf.c | 32 +++++++++++++++++++++++--------- core/t.c | 2 +- 6 files changed, 31 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index c41f84f..41bac6b 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ fake-values essai serial/t core/t +core/*.a doc/*.toc doc/*.log diff --git a/BUILD.txt b/BUILD.txt index fb24a49..cb4ef81 100644 --- a/BUILD.txt +++ b/BUILD.txt @@ -11,6 +11,7 @@ First step, build some parts of the core library : Then you must have datas for working on. One source of datas is the four values who came from the Arduino over serial line. +At this time, you must look at the configuration file. $ cd serial $ make t diff --git a/core/config.h b/core/config.h index 4c3b105..1e3d063 100644 --- a/core/config.h +++ b/core/config.h @@ -8,7 +8,7 @@ typedef struct { int valid; - + char *input_device; } Configuration; diff --git a/core/dd2-monitor.conf b/core/dd2-monitor.conf index 2b79cff..8020bcb 100644 --- a/core/dd2-monitor.conf +++ b/core/dd2-monitor.conf @@ -1,10 +1,9 @@ - +# # experimental config file +# - -input_device s /def/ttyACM0 - - +input_device s /dev/ttyACM0 +input_speed s 9600 diff --git a/core/parseconf.c b/core/parseconf.c index 56af341..1bf1b99 100644 --- a/core/parseconf.c +++ b/core/parseconf.c @@ -10,13 +10,14 @@ extern int verbosity; extern Configuration config; -#define CMP(a) (!strcmp(cptr, a)) +#define CMP(a) (!strcmp(keyptr, a)) /* ---------------------------------------------------------------- */ int parse_config(char *fname, int flags) { FILE *fp; -char line[SZ_STRINGS+1], *cptr; +char line[SZ_STRINGS+1], + *keyptr, *typeptr, *cptr; int numligne; #if DEBUG_LEVEL @@ -49,23 +50,35 @@ while (fgets(line, SZ_STRINGS, fp)) } /* seek for the first token in this line */ - if (NULL==(cptr = strtok(line, " \t"))) { + if (NULL==(keyptr = strtok(line, " \t"))) { /* Got an empty line */ continue; } - /* skip comments */ - if ('#'==*cptr) continue; - - if(verbosity) fprintf(stderr, "[%s]\n", cptr); + if ('#'==*keyptr) continue; + /* seek for the type field */ + if (NULL==(typeptr = strtok(NULL, " \t"))) { + /* we can(t get a type flag ? wtf ? */ + fprintf(stderr, "ERROR line %d : no type\n", numligne); + continue; + } + if(verbosity) + fprintf(stderr, "[%s] type %s\n", keyptr, typeptr); + if CMP("abort") { + fprintf(stderr, "abort in config file\n"); + } + if (CMP("input_device")) { + config.input_device = strdup(strtok(NULL, " \t")); + continue; + } } fclose(fp); -return -1; +return 0; } /* ---------------------------------------------------------------- */ int show_config(char *title) @@ -75,7 +88,8 @@ if (verbosity) { printf("********** %s **********\n", title); } -printf("valid %d\n", config.valid); +printf("valid : %d\n", config.valid); +printf("input device : %s\n", config.input_device); puts(""); return 0; diff --git a/core/t.c b/core/t.c index 835fa58..059efa1 100644 --- a/core/t.c +++ b/core/t.c @@ -42,7 +42,7 @@ while ((opt = getopt(argc, argv, "v")) != -1) { } -foo = parse_config(conffile, 1); +foo = parse_config(conffile, 0); fprintf(stderr, "parse_config(%s) -> %d\n\n", conffile, foo); show_config("foo"); From 090aba2e6355cd51dd7731ad7aeefc8dfa824a0e Mon Sep 17 00:00:00 2001 From: phyto Date: Fri, 18 Jan 2019 17:56:27 +0100 Subject: [PATCH 054/110] scaling corrected --- essai.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/essai.c b/essai.c index 33ab9fa..bd7bdb8 100644 --- a/essai.c +++ b/essai.c @@ -53,11 +53,11 @@ while ((opt = getopt(argc, argv, "v")) != -1) { foo = get_loadavg(loads); if (foo) fprintf(stderr, "get loadavg -> %d\n", foo); for (foo=0; foo<3; foo++) { - il[foo] = ((int)(loads[foo] * 900.0)) & 0x3ff; + il[foo] = ((int)(loads[foo] * 90.0)) & 0x3ff; fprintf(stderr, "%f -> %d\n", loads[foo], il[foo]); } -printf("T %ld %d %d %d %d\n", time(NULL), getpid()%1024, il[0], il[1], il[2]); +printf("%ld %d %d %d %d\n", time(NULL), getpid()%84, il[0], il[1], il[2]); return 0; } From 3cc52c098320f3b60644a74d91da2e90c5e4a0cd Mon Sep 17 00:00:00 2001 From: phyto Date: Tue, 22 Jan 2019 14:25:26 +0100 Subject: [PATCH 055/110] je ne sais pas trop quoi faire... --- viz/curses/7segments.c | 1 + viz/curses/t.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index 4f44bca..fa76ec2 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -52,4 +52,5 @@ for (numbit=0; numbit<8; numbit++) { return -1; } /* ---------------------------------------------------------------- */ +/* ---------------------------------------------------------------- */ diff --git a/viz/curses/t.c b/viz/curses/t.c index 742668c..dd35c56 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -28,7 +28,7 @@ for (loop=0; loop 1023.0) { rvals[foo] = (float)(rand() % 25); From 824f805ef832f53ce8f5344b67bbf6a3fa67d293 Mon Sep 17 00:00:00 2001 From: phyto Date: Tue, 22 Jan 2019 15:24:49 +0100 Subject: [PATCH 056/110] more eyecandy --- viz/curses/ecran.c | 8 ++++++++ viz/curses/ecran.h | 1 + viz/curses/t.c | 13 +++++++++++-- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/viz/curses/ecran.c b/viz/curses/ecran.c index 8807444..43ba848 100644 --- a/viz/curses/ecran.c +++ b/viz/curses/ecran.c @@ -12,6 +12,14 @@ int verbosity; /* ---------------------------------------------------------------- */ +int message(char *txt) +{ +standout(); +mvaddstr(LINES, 2, txt); +standend(); +refresh(); +return 0; +} /* ---------------------------------------------------------------- */ void barre_inverse(char c, int ligne) { diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index c2ec246..aa45fe5 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -3,6 +3,7 @@ */ int fond_ecran(char *titre); +int message(char *); WINDOW * open_waterfall(char *title, int flags); diff --git a/viz/curses/t.c b/viz/curses/t.c index dd35c56..0f64fb2 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include @@ -16,7 +17,10 @@ int loop, foo; char line[100]; WINDOW *water; static float rvals[4]; +struct timespec ts; +ts.tv_sec = 0; +ts.tv_nsec = 133 * 1000 * 1000; water = open_waterfall("premier essai", 0); @@ -28,7 +32,7 @@ for (loop=0; loop 1023.0) { rvals[foo] = (float)(rand() % 25); @@ -37,7 +41,12 @@ for (loop=0; loop Date: Tue, 22 Jan 2019 16:51:35 +0100 Subject: [PATCH 057/110] more samples are better --- serial/essai.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/serial/essai.sh b/serial/essai.sh index 9d4e8bc..2526c3e 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,7 +5,7 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=15000 +NB_READ=25000 ./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} From 349e0ca2b0eb51f22f1c3a5911f3bccfc85d2b37 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 22 Jan 2019 17:23:11 +0100 Subject: [PATCH 058/110] grosse flemme aujouird'hui --- core/Makefile | 2 +- core/config.h | 2 ++ core/dd2-monitor.conf | 12 +++++++----- core/parseconf.c | 11 +++++++++++ doc/dd2-monitoring.tex | 4 ++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/core/Makefile b/core/Makefile index f31a15d..752f602 100644 --- a/core/Makefile +++ b/core/Makefile @@ -1,7 +1,7 @@ # # dd2 monitoring # -# buil the core functions, use with care +# build the core functions, use with care # diff --git a/core/config.h b/core/config.h index 1e3d063..ec7d75d 100644 --- a/core/config.h +++ b/core/config.h @@ -9,12 +9,14 @@ typedef struct { int valid; char *input_device; + int input_speed; } Configuration; /* ---------------------------------------------------------------- */ +int set_default_config(Configuration *cfg); int parse_config(char *fname, int flags); int show_config(char *title); diff --git a/core/dd2-monitor.conf b/core/dd2-monitor.conf index 8020bcb..5910bda 100644 --- a/core/dd2-monitor.conf +++ b/core/dd2-monitor.conf @@ -1,10 +1,12 @@ -# +# # experimental config file # +# -------------------------------------------------- +# serial input from the control cpu + input_device s /dev/ttyACM0 -input_speed s 9600 - - - +input_speed i 9600 +# -------------------------------------------------- +# -------------------------------------------------- diff --git a/core/parseconf.c b/core/parseconf.c index 1bf1b99..baf4f4e 100644 --- a/core/parseconf.c +++ b/core/parseconf.c @@ -3,6 +3,7 @@ */ #include +#include #include #include "config.h" @@ -74,6 +75,15 @@ while (fgets(line, SZ_STRINGS, fp)) config.input_device = strdup(strtok(NULL, " \t")); continue; } + + + if (CMP("input_speed")) { + config.input_speed = atoi(strtok(NULL, " \t")); +#if DEBUG_LEVEL + fprintf(stderr, "input speed = %d\n", config.input_speed); +#endif + } + } fclose(fp); @@ -90,6 +100,7 @@ if (verbosity) { printf("valid : %d\n", config.valid); printf("input device : %s\n", config.input_device); +printf("input speed : %d\n", config.input_speed); puts(""); return 0; diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 5030824..8a12b81 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -331,8 +331,8 @@ En fait, tout reste à faire. Mais ça peut être un beau projet aux implications et usages multiples. Un couteau suisse de la capture du monde réel, un point pivot -de nos diverses interprétations du -monde\footnote{non, la terre n'est pas plate} et des interactions +de nos diverses interprétations de +l'univers\footnote{non, la terre n'est pas plate} et des interactions étranges entre des paramètres sans relation clairement definie. % ------------------------------------------------------------------- From dce67b491dc52f6636a844d40381c61ed0394f51 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 23 Jan 2019 22:39:03 +0100 Subject: [PATCH 059/110] some work on the eyecandy curses display --- core/dd2-monitor.conf | 8 ++++++-- core/parseconf.c | 6 +++++- viz/curses/Makefile | 5 ++++- viz/curses/ecran.h | 2 ++ viz/curses/t.c | 6 +++--- viz/curses/vumetre.c | 36 ++++++++++++++++++++++++++++++++++++ viz/curses/waterfall.c | 8 ++++---- 7 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 viz/curses/vumetre.c diff --git a/core/dd2-monitor.conf b/core/dd2-monitor.conf index 5910bda..494e4a3 100644 --- a/core/dd2-monitor.conf +++ b/core/dd2-monitor.conf @@ -5,8 +5,12 @@ # -------------------------------------------------- # serial input from the control cpu -input_device s /dev/ttyACM0 -input_speed i 9600 +input_device s /dev/ttyACM0 +input_speed i 9600 # -------------------------------------------------- +# some values for the eyecandy displays + +eyecandy_banner s hacked by tTh + # -------------------------------------------------- diff --git a/core/parseconf.c b/core/parseconf.c index baf4f4e..bce5c44 100644 --- a/core/parseconf.c +++ b/core/parseconf.c @@ -76,7 +76,6 @@ while (fgets(line, SZ_STRINGS, fp)) continue; } - if (CMP("input_speed")) { config.input_speed = atoi(strtok(NULL, " \t")); #if DEBUG_LEVEL @@ -84,6 +83,11 @@ while (fgets(line, SZ_STRINGS, fp)) #endif } + if (CMP("eyecandy_banner")) { + config.eyecandy_banner = strdup(strtok(NULL, " \t")); + continue; + } + } fclose(fp); diff --git a/viz/curses/Makefile b/viz/curses/Makefile index a275f58..bc75dcc 100644 --- a/viz/curses/Makefile +++ b/viz/curses/Makefile @@ -13,9 +13,12 @@ ecran.o: ecran.c Makefile ecran.h waterfall.o: waterfall.c Makefile gcc $(COPT) -c $< +vumetre.o: vumetre.c Makefile + gcc $(COPT) -c $< + # --------------- *** -OBJ = ecran.o waterfall.o 7segments.o +OBJ = ecran.o waterfall.o 7segments.o vumetre.o t: t.c Makefile $(OBJ) ecran.h gcc $(COPT) $< $(OBJ) -lncurses -o $@ diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index aa45fe5..0ad0234 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -9,3 +9,5 @@ int message(char *); WINDOW * open_waterfall(char *title, int flags); int plot_waterfall(WINDOW *wf, int flags, float values[4]); int close_waterfall(WINDOW *wf, int notused); + +int vumetre_0(WINDOW * win, int lig, int col, float val, int larg); diff --git a/viz/curses/t.c b/viz/curses/t.c index 0f64fb2..1aec788 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -11,7 +11,7 @@ int verbosity; /* ---------------------------------------------------------------- */ -void demo(int nbl, int k) +void demo_waterfall(int nbl, int k) { int loop, foo; char line[100]; @@ -20,7 +20,7 @@ static float rvals[4]; struct timespec ts; ts.tv_sec = 0; -ts.tv_nsec = 133 * 1000 * 1000; +ts.tv_nsec = 200 * 1000 * 1000; water = open_waterfall("premier essai", 0); @@ -86,7 +86,7 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ fond_ecran(" Demonstrator "); -demo(190000, 0); +demo_waterfall(190000, 0); /* * plop, on a fini, restaurer la console diff --git a/viz/curses/vumetre.c b/viz/curses/vumetre.c new file mode 100644 index 0000000..6382029 --- /dev/null +++ b/viz/curses/vumetre.c @@ -0,0 +1,36 @@ +/* + * DD2 Monitoring + * + * ncurses seven segment display + */ + +#include +#include +#include +#include +#include + +#include "ecran.h" + +int verbosity; + +/* ---------------------------------------------------------------- */ +int vumetre_0(WINDOW *win, int lig, int col, float val, int larg) +{ +int foo; + +#if DEBUG_LEVEL +fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n", + __func__, win, lig, col, val, larg); +#endif + +for (foo=0; foo 1 fprintf(stderr, "COLS = %d, coef_w = %f\n", COLS, coef_w); @@ -79,7 +79,7 @@ switch (mode) { fprintf(stderr, "%c %3d ", tag, idx); #endif } - ligne[COLS-4] = '\0'; + ligne[COLS-1] = '\0'; #if TRACE fprintf(stderr, "\n"); fflush(stderr); #endif From 2f5617d3b452640dfc9acba05f84f2393129df39 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 24 Jan 2019 01:00:18 +0100 Subject: [PATCH 060/110] second eyecandy prototype is running nicely --- viz/curses/t.c | 40 ++++++++++++++++++++++++++++++++++++---- viz/curses/vumetre.c | 18 ++++++++++++------ 2 files changed, 48 insertions(+), 10 deletions(-) diff --git a/viz/curses/t.c b/viz/curses/t.c index 1aec788..277fdb4 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -10,6 +10,34 @@ int verbosity; +/* ---------------------------------------------------------------- */ +void demo_vumetres(int nbl, int notused) +{ +int loop, idx; +int hpos; +char ligne[100]; +float value; + +for (loop=0; loop>> %s ( %p %d %d %f %d )\n", __func__, win, lig, col, val, larg); #endif -for (foo=0; foo Date: Thu, 24 Jan 2019 01:20:39 +0100 Subject: [PATCH 061/110] fix the 'message' function --- viz/curses/ecran.c | 2 +- viz/curses/t.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/viz/curses/ecran.c b/viz/curses/ecran.c index 43ba848..e813791 100644 --- a/viz/curses/ecran.c +++ b/viz/curses/ecran.c @@ -15,7 +15,7 @@ int verbosity; int message(char *txt) { standout(); -mvaddstr(LINES, 2, txt); +mvaddstr(LINES-1, 2, txt); standend(); refresh(); return 0; diff --git a/viz/curses/t.c b/viz/curses/t.c index 277fdb4..551db8b 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -54,8 +54,9 @@ water = open_waterfall("premier essai", 0); for (loop=0; loop Date: Thu, 24 Jan 2019 01:41:08 +0100 Subject: [PATCH 062/110] more eyecandy with drand48 --- viz/curses/t.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viz/curses/t.c b/viz/curses/t.c index 277fdb4..8ebbde8 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -25,7 +25,7 @@ for (loop=0; loop Date: Thu, 24 Jan 2019 13:06:26 +0100 Subject: [PATCH 063/110] deux vumetres, est-ce assez ? --- .gitignore | 1 + viz/curses/Makefile | 21 +++++++++++++-------- viz/curses/ecran.h | 2 ++ viz/curses/t.c | 9 ++++----- viz/curses/vumetre.c | 40 +++++++++++++++++++++++++++++++++++++++- 5 files changed, 59 insertions(+), 14 deletions(-) diff --git a/.gitignore b/.gitignore index 250ce90..3480d38 100644 --- a/.gitignore +++ b/.gitignore @@ -22,4 +22,5 @@ serial/*.png viz/curses/t viz/gnuplot/*.png +viz/*.a diff --git a/viz/curses/Makefile b/viz/curses/Makefile index bc75dcc..825e937 100644 --- a/viz/curses/Makefile +++ b/viz/curses/Makefile @@ -1,26 +1,31 @@ # --------------- *** -COPT = -Wall -g -DTRACE=0 +COPT = -Wall -g -fpic -DTRACE=0 +OBJS = ecran.o 7segments.o waterfall.o vumetre.o +ALIB = ../libdd2m-viz.a + +# --------------- *** + +${ALIB}: ${OBJS} + ar r $@ $? # --------------- *** ecran.o: ecran.c Makefile ecran.h gcc $(COPT) -c $< -7segments.o: 7segments.c Makefile +7segments.o: 7segments.c Makefile ecran.h gcc $(COPT) -c $< -waterfall.o: waterfall.c Makefile +waterfall.o: waterfall.c Makefile ecran.h gcc $(COPT) -c $< -vumetre.o: vumetre.c Makefile +vumetre.o: vumetre.c Makefile ecran.h gcc $(COPT) -c $< # --------------- *** -OBJ = ecran.o waterfall.o 7segments.o vumetre.o - -t: t.c Makefile $(OBJ) ecran.h - gcc $(COPT) $< $(OBJ) -lncurses -o $@ +t: t.c Makefile $(ALIB) ecran.h + gcc $(COPT) $< $(ALIB) -lncurses -o $@ # --------------- *** diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index 0ad0234..ceac133 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -10,4 +10,6 @@ WINDOW * open_waterfall(char *title, int flags); int plot_waterfall(WINDOW *wf, int flags, float values[4]); int close_waterfall(WINDOW *wf, int notused); + int vumetre_0(WINDOW * win, int lig, int col, float val, int larg); +int vumetre_1(WINDOW * win, int lig, int col, float val, int larg); diff --git a/viz/curses/t.c b/viz/curses/t.c index 7e21c0a..ba0fd62 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -22,14 +22,13 @@ for (loop=0; loop>> %s ( %p %d %d %f %d )\n", @@ -26,8 +27,11 @@ fprintf(stderr, ">>> %s ( %p %d %d %f %d )\n", posc = (int)(val * (float)larg); +sprintf(ligne, "%6.3f", val); +mvwaddstr(win, lig, 2, ligne); + for (foo=0; foo>> %s ( %p %d %d %f %d )\n", + __func__, win, lig, col, val, larg); +#endif + +posc = (int)(val * (float)larg); + +sprintf(ligne, "%6.3f", val); +mvwaddstr(win, lig, 2, ligne); + +for (foo=0; foo Date: Sat, 26 Jan 2019 16:10:12 +0100 Subject: [PATCH 064/110] premier afficheir 7 segments --- viz/curses/7segments.c | 82 ++++++++++++++++++++++++++++++++++-------- viz/curses/ecran.h | 3 ++ viz/curses/t.c | 32 +++++++++++++++-- 3 files changed, 100 insertions(+), 17 deletions(-) diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index fa76ec2..853a5a2 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -15,42 +16,93 @@ int verbosity; /* ---------------------------------------------------------------- */ -int afficheur_7segs(WINDOW * win, int lig, int col, int bits, int k) +int aff7segs_base(WINDOW * win, int lig, int col, int bits, int k) { int numbit, mask; +int foo; +for (foo=0; foo<9; foo++) { + mvwhline(win, lig+foo, col, '~', 6); + } + +wstandout(win); for (numbit=0; numbit<8; numbit++) { mask = 1 << numbit; - - switch(mask) { - + switch(mask & bits) { case 0x01: - + mvwaddstr(win, lig, col+1, " "); + break; case 0x02: - + mvwaddch(win, lig+1, col+5, ' '); + mvwaddch(win, lig+2, col+5, ' '); + mvwaddch(win, lig+3, col+5, ' '); + break; case 0x04: - + mvwaddch(win, lig+5, col+5, ' '); + mvwaddch(win, lig+6, col+5, ' '); + mvwaddch(win, lig+7, col+5, ' '); + break; case 0x08: - + mvwaddstr(win, lig+8, col+1, " "); + break; case 0x10: - + mvwaddch(win, lig+5, col, ' '); + mvwaddch(win, lig+6, col, ' '); + mvwaddch(win, lig+7, col, ' '); + break; case 0x20: - + mvwaddch(win, lig+1, col , ' '); + mvwaddch(win, lig+2, col , ' '); + mvwaddch(win, lig+3, col , ' '); + break; case 0x40: - + mvwaddstr(win, lig+4, col+1, " "); + break; case 0x80: /* decimal point */ break; - default: - fprintf(stderr, "%s mask is wrong\n", __func__); - break; } } +wstandend(win); -return -1; +return 0; } /* ---------------------------------------------------------------- */ +int aff7segs_digit(WINDOW * win, int lig, int col, char digit) +{ +int bits; + +#if TRACE +fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__, + win, lig, col, digit); +#endif + +if (!isdigit(digit)) { + return -1; + } + +switch (digit) { + case '0': bits = 0x3f; break; + case '1': bits = 0x06; break; + case '2': bits = 0x5b; break; + case '3': bits = 0x4f; break; + case '4': bits = 0x66; break; + case '5': bits = 0x6d; break; + case '6': bits = 0x7d; break; + case '7': bits = 0x07; break; + case '8': bits = 0x7f; break; + case '9': bits = 0x6f; break; + + default: + bits = 0x40; + break; + } + +aff7segs_base(win, lig, col, bits, 0); + +return 0; +} /* ---------------------------------------------------------------- */ diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index ceac133..c2bba24 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -5,6 +5,9 @@ int fond_ecran(char *titre); int message(char *); +int aff7segs_base(WINDOW * win, int lig, int col, int bits, int k); +int aff7segs_digit(WINDOW * win, int lig, int col, char digit); + WINDOW * open_waterfall(char *title, int flags); int plot_waterfall(WINDOW *wf, int flags, float values[4]); diff --git a/viz/curses/t.c b/viz/curses/t.c index ba0fd62..1b11ea7 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -10,12 +10,39 @@ int verbosity; +/* ---------------------------------------------------------------- */ +void demo_7segments(int nbl, int notused) +{ +int loop, idx, c, p; +char ligne[100]; + + +for (idx=0; idx<10; idx++) { + c = '0'+idx; + p = 1+(idx*8); + aff7segs_digit(stdscr, 17, p, c); + mvaddch(16, p, c); + } + +for (loop=0; loop Date: Sat, 26 Jan 2019 16:32:10 +0100 Subject: [PATCH 065/110] fix the 7 segments demo --- viz/curses/t.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/viz/curses/t.c b/viz/curses/t.c index 1b11ea7..f370538 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -19,20 +19,20 @@ char ligne[100]; for (idx=0; idx<10; idx++) { c = '0'+idx; - p = 1+(idx*8); + p = 1+(idx*9); aff7segs_digit(stdscr, 17, p, c); mvaddch(16, p, c); } for (loop=0; loop Date: Sun, 27 Jan 2019 11:01:33 +0100 Subject: [PATCH 066/110] demo ncurses: + opt nb_loops --- viz/curses/t.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/viz/curses/t.c b/viz/curses/t.c index f370538..49b9e4c 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -117,15 +117,18 @@ int main (int argc, char *argv[]) { int opt; int demonum = 0; +int nb_loops = 200; /* set some default values */ verbosity = 0; -while ((opt = getopt(argc, argv, "vy:")) != -1) { +while ((opt = getopt(argc, argv, "n:vy:")) != -1) { switch (opt) { - case 'v': verbosity++; break; + case 'n': nb_loops = atoi(optarg); break; - case 'y': demonum = atoi(optarg); break; + case 'v': verbosity++; break; + + case 'y': demonum = atoi(optarg); break; default: fprintf(stderr, "%s : uh ?", argv[0]); @@ -143,9 +146,9 @@ keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ fond_ecran(" Demonstrator "); switch (demonum) { - case 0: demo_vumetres(666, 0); break; - case 1: demo_waterfall(666, 0); break; - case 2: demo_7segments(4567, 0); break; + case 0: demo_vumetres(nb_loops, 0); break; + case 1: demo_waterfall(nb_loops, 0); break; + case 2: demo_7segments(nb_loops, 0); break; } /* From 5e0d33cfe1ec99be27bdd7a0a7b73aef97740c88 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 27 Jan 2019 11:36:51 +0100 Subject: [PATCH 067/110] enhancing the seven segments display --- viz/curses/7segments.c | 48 +++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 22 deletions(-) diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index 853a5a2..d895dc7 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -25,41 +25,48 @@ for (foo=0; foo<9; foo++) { mvwhline(win, lig+foo, col, '~', 6); } +#define KC '+' +#define KS "++++" + wstandout(win); for (numbit=0; numbit<8; numbit++) { mask = 1 << numbit; switch(mask & bits) { case 0x01: - mvwaddstr(win, lig, col+1, " "); + mvwaddstr(win, lig, col+1, KS); break; case 0x02: - mvwaddch(win, lig+1, col+5, ' '); - mvwaddch(win, lig+2, col+5, ' '); - mvwaddch(win, lig+3, col+5, ' '); + mvwaddch(win, lig+1, col+5, KC); + mvwaddch(win, lig+2, col+5, KC); + mvwaddch(win, lig+3, col+5, KC); break; case 0x04: - mvwaddch(win, lig+5, col+5, ' '); - mvwaddch(win, lig+6, col+5, ' '); - mvwaddch(win, lig+7, col+5, ' '); + mvwaddch(win, lig+5, col+5, KC); + mvwaddch(win, lig+6, col+5, KC); + mvwaddch(win, lig+7, col+5, KC); break; case 0x08: - mvwaddstr(win, lig+8, col+1, " "); + mvwaddstr(win, lig+8, col+1, KS); break; case 0x10: - mvwaddch(win, lig+5, col, ' '); - mvwaddch(win, lig+6, col, ' '); - mvwaddch(win, lig+7, col, ' '); + mvwaddch(win, lig+5, col, KC); + mvwaddch(win, lig+6, col, KC); + mvwaddch(win, lig+7, col, KC); break; case 0x20: - mvwaddch(win, lig+1, col , ' '); - mvwaddch(win, lig+2, col , ' '); - mvwaddch(win, lig+3, col , ' '); + mvwaddch(win, lig+1, col , KC); + mvwaddch(win, lig+2, col , KC); + mvwaddch(win, lig+3, col , KC); break; case 0x40: - mvwaddstr(win, lig+4, col+1, " "); + mvwaddstr(win, lig+4, col+1, KS); break; case 0x80: /* decimal point */ + mvwaddch(win, lig+7, col+2 , KC); + mvwaddch(win, lig+7, col+3 , KC); + mvwaddch(win, lig+8, col+2 , KC); + mvwaddch(win, lig+8, col+3 , KC); break; } @@ -79,10 +86,6 @@ fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__, win, lig, col, digit); #endif -if (!isdigit(digit)) { - return -1; - } - switch (digit) { case '0': bits = 0x3f; break; case '1': bits = 0x06; break; @@ -95,9 +98,10 @@ switch (digit) { case '8': bits = 0x7f; break; case '9': bits = 0x6f; break; - default: - bits = 0x40; - break; + case ' ': bits = 0; break; + case '.': bits = 0x80; break; + + default: bits = 0x09; break; } aff7segs_base(win, lig, col, bits, 0); From bc7e6379e6473a323751d60956688a5d9c10c3ea Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 27 Jan 2019 11:55:25 +0100 Subject: [PATCH 068/110] deleting a subwin in waterfall --- viz/curses/waterfall.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/viz/curses/waterfall.c b/viz/curses/waterfall.c index 7dbadf3..9d0f3dc 100644 --- a/viz/curses/waterfall.c +++ b/viz/curses/waterfall.c @@ -100,12 +100,18 @@ return -1; /* ---------------------------------------------------------------- */ int close_waterfall(WINDOW *wf, int notused) { +int foo; if (NULL == wf) { fprintf(stderr, "%s wf is null\n", __func__); return -1; } +foo = delwin(wf); +if (ERR==foo) { + fprintf(stderr, "%s : err on delwin\n", __func__); + return -1; + } return 0; } /* ---------------------------------------------------------------- */ From 7b168e26bd5c8fdf387d31f33b30acc912190339 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 27 Jan 2019 12:12:49 +0100 Subject: [PATCH 069/110] c'est l'heure de l'apero --- viz/curses/ecran.c | 25 +++++++++++++------------ viz/curses/t.c | 17 +++++++++++------ 2 files changed, 24 insertions(+), 18 deletions(-) diff --git a/viz/curses/ecran.c b/viz/curses/ecran.c index e813791..6012a2b 100644 --- a/viz/curses/ecran.c +++ b/viz/curses/ecran.c @@ -14,7 +14,10 @@ int verbosity; /* ---------------------------------------------------------------- */ int message(char *txt) { +static int pass = 0; + standout(); +mvaddch(LINES-1, 0, "\\|/-"[(pass++)%4]); mvaddstr(LINES-1, 2, txt); standend(); refresh(); @@ -33,13 +36,10 @@ standend(); /* ---------------------------------------------------------------- */ int fond_ecran(char *title) { -char *tp; -struct utsname utsn; -int foo; - -#if TRACE -char buffer[200]; -#endif +char *tp; +struct utsname utsn; +int foo; +char buffer[200]; tp = " DD2 MONITORING by tTh 2019 "; if (NULL != title) tp = title; @@ -47,11 +47,12 @@ if (NULL != title) tp = title; barre_inverse(' ', 0); standout(); mvaddstr(0, 2, tp); -#if TRACE -sprintf(buffer, " ecran %dx%d ", COLS, LINES); -foo = strlen(buffer); -mvaddstr(0, COLS-2-foo, buffer); -#endif + +if (verbosity) { + sprintf(buffer, " ecran %dx%d ", COLS, LINES); + foo = strlen(buffer); + mvaddstr(0, COLS-2-foo, buffer); + } /* get and display hostname */ foo = uname(&utsn); diff --git a/viz/curses/t.c b/viz/curses/t.c index 49b9e4c..bce2b39 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -20,20 +20,25 @@ char ligne[100]; for (idx=0; idx<10; idx++) { c = '0'+idx; p = 1+(idx*9); - aff7segs_digit(stdscr, 17, p, c); - mvaddch(16, p, c); + aff7segs_digit(stdscr, 4, p, c); + mvaddch(3, p, c); } for (loop=0; loop Date: Sun, 27 Jan 2019 12:23:35 +0100 Subject: [PATCH 070/110] c'est l'heure de la pizza --- viz/curses/t.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/viz/curses/t.c b/viz/curses/t.c index bce2b39..afb036d 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -17,24 +17,17 @@ int loop, idx, c, p; char ligne[100]; -for (idx=0; idx<10; idx++) { - c = '0'+idx; - p = 1+(idx*9); - aff7segs_digit(stdscr, 4, p, c); - mvaddch(3, p, c); - } - for (loop=0; loop Date: Sun, 27 Jan 2019 13:03:59 +0100 Subject: [PATCH 071/110] working on fake values --- core/utils.c | 8 +++++++- exemple.sh | 15 +++++++++++---- fake-values.c | 4 +++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/core/utils.c b/core/utils.c index 17cf615..90049c6 100644 --- a/core/utils.c +++ b/core/utils.c @@ -23,7 +23,7 @@ return v1 ^ v2; /* --------------------------------------------------------------- */ int random1000(int type) { -int value; +int value, foo; #if DEBUG_LEVEL > 1 fprintf(stderr, ">>> %s(%d)\n", __func__, type); @@ -36,6 +36,12 @@ switch (type) { case 1: value = (rand()%1000 + rand()%1000) / 2; break; + case 4: + value = 0; + for (foo=0; foo<4; foo++) + value += rand() % 1000; + value /= 4; + break; default: value = -1; break; diff --git a/exemple.sh b/exemple.sh index 80b52ae..3e1824a 100755 --- a/exemple.sh +++ b/exemple.sh @@ -6,21 +6,28 @@ DATAFILE=/tmp/fake-datafile > ${DATAFILE} for s in $(seq 1 2000) do - v=$(./fake-values -s -t 1) + v=$(./fake-values -s -t 4) echo $s $v >> ${DATAFILE} done +tail -5 ${DATAFILE} + #----- do dome useless computations awk ' - NR==1 { debut = $2 } + NR==1 { + debut = $2 + } + { # print $2-debut, $3 - v = int($3/25); + v = int($3/35); bucket[v]++; } + END { for (v=0; v<40; v++) { - for (foo=0; foo @@ -30,7 +32,7 @@ if (verbosity > 1) { fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__); } -printf("%f %d\n", dtime(), random1000(type)); +printf("%.3f %d\n", dtime(), random1000(type)); return 0; } From e5168df124f7848576d7dcf53e2a9bd6e3ddda55 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 27 Jan 2019 13:06:02 +0100 Subject: [PATCH 072/110] missing member un config struct --- core/config.h | 1 + 1 file changed, 1 insertion(+) diff --git a/core/config.h b/core/config.h index ec7d75d..25fdbe9 100644 --- a/core/config.h +++ b/core/config.h @@ -11,6 +11,7 @@ typedef struct { char *input_device; int input_speed; + char *eyecandy_banner; } Configuration; From efa4604e3a33596b751cf979bd21603fdb145f7c Mon Sep 17 00:00:00 2001 From: phyto Date: Sun, 27 Jan 2019 13:15:33 +0100 Subject: [PATCH 073/110] debug of the useless makefile --- Makefile | 14 +++++++------- fake-values.c | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c3b8d06..d43301d 100644 --- a/Makefile +++ b/Makefile @@ -2,18 +2,18 @@ # must be run with gnu make # -CC = gcc - -CCOPT = -Wall -g +CC = gcc +CCOPT = -Wall -g +CLIB = core/libdd2m-core.a all: essai fake-values # --------------------------------------------- -essai: essai.c Makefile - gcc ${CCOPT} $< core/utils.o -o $@ +essai: essai.c Makefile $(CLIB) + $(CC) ${CCOPT} $< $(CLIB) -o $@ -fake-values: fake-values.c Makefile - gcc ${CCOPT} $< core/utils.o -o $@ +fake-values: fake-values.c Makefile $(CLIB) + $(CC) ${CCOPT} $< $(CLIB) -o $@ # --------------------------------------------- diff --git a/fake-values.c b/fake-values.c index 1bb7ba8..88c3d4c 100644 --- a/fake-values.c +++ b/fake-values.c @@ -32,7 +32,7 @@ if (verbosity > 1) { fprintf(stderr, "fake values - %s %s\n", __DATE__, __TIME__); } -printf("%.3f %d\n", dtime(), random1000(type)); +printf("%.3f %4d\n", dtime(), random1000(type)); return 0; } From beffb2748315c7f51a77a944f99bd355511e7501 Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 27 Jan 2019 14:42:44 +0100 Subject: [PATCH 074/110] more doc is more doc --- doc/dd2-monitoring.tex | 65 ++++++++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 9 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 8a12b81..db95589 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -15,7 +15,7 @@ \usepackage[verbose]{layout} \makeindex -\setlength{\parskip}{0.20cm plus 0.20cm} +\setlength{\parskip}{0.21cm plus 0.21cm} % ------------------------------------------------------------------- \title{DD2 Monitoring} @@ -52,15 +52,29 @@ de découvrir plein de capteurs différents : température, humidité, \section{Présentation générale} + + \subsection{Capteurs} \index{capteurs} -Actuellement nous disposons d'un \texttt{RDing TEMPERHUM1V1.2}{} qui +Actuellement nous disposons d'un capteur température et +humidité, le +\texttt{RDing} \texttt{TEMPERHUM1V1.2}{} qui semble un peu étrange à interpeller, et qui sera destiné à mesurer -l'ambiance météo du DD2\footnote{Pas de mauvais esprit, merci...}. +l'ambiance météo du Double Dragon\footnote{Pas de mauvais esprit, merci...}, +l'influence humaine n'étant pas à négliger en cas d'afflux du public.. Par la suite, nous pourrons récupérer (par liaison série, cf page \pageref{serial}) -des données en provenance de l'automate de contrôle de l'enceinte. +des données diverses en provenance de l'automate de contrôle de l'enceinte. + +Le premier capteur de température sélectionné est le \textsc{LM35}\index{LM35} +qui fournit en sortie une tension linéairement proportionnle à +la température. Ils seront connectés sur l'automate qui s'en +servira pour la régulation thermostatique. + +Il nous reste à choisir d'autres capteurs pour d'autres métriques : +humidité, lumière, vibrations\dots + Notre dd2monitor devrait donc aussi être capable d'envoyer des alertes en cas de souci, par exemple si des algues\footnote{ou des pleurotes.} tentent de s'échapper. @@ -85,7 +99,9 @@ Nous allons laisser un petit bac-à-sable pour Fred Fermion\index{nodejs}, qui nous tartine les oreilles depuis bien trop longtemps avec son machin.js. Mais sachez déja que l'automate sera équipé d'un minitel, pourquoi ne -pas en mettre un second sur le monitoring ? +pas en mettre un second sur le monitoring ? Après tout, un peu +d'eyecandy\index{eyecandy} ne peut pas faire de mal. +C'est expliqué à la page \pageref{eyecandy}\index{curses}. % ------------------------------------------------------------------- \section{Outils} @@ -112,6 +128,10 @@ Le second cause des premiers essais du LM35, capteur de température analogique branché sur un Arduino et relié par un port série (page \pageref{serialcode}). +Pour continuer dans une démarche disruptive, des outils +avancés de visualisation sont proposés dans la rubrique +\ref{eyecandy} qui parle de \texttt{vt100}\label{vt100}. + \subsection{Analyses} \textsf{Bla bla bla\dots Corrélations, Gnuplot\index{gnuplot}, toussa\dots} @@ -123,7 +143,7 @@ de choses étranges, comme ça : \textsl{ s/booz/booze pour la courbe qui majore les autres en moyenne serait d'une criante justesse scientifique ;)} -Ce qui donne qunad même à réfléchir. À se demander quel savoir +Ce qui donne quand même à réfléchir. À se demander quel savoir allons-nous pouvoir déduire de ces\footnote{non, c'est pas du bigdata.} chiffres improbables. (Re-)Découvrir les lois de l'inertie thermique ? @@ -145,7 +165,9 @@ ou d'un \textit{epicfail\footnote{En fait, c'est comme ça que la science avance}}. Nous devons donc rencontrer quelqu'un qui maitrise cette partie -de la mouvance détournementale de l'espionnage. Yaya\index{Yaya} ? +de la mouvance détournementale de l'espionnage. +Je pense que Yaya\index{Yaya} pourra nous éclairer de ses lumières, +si on lui demande gentiment. % ------------------------------------------------------------------- @@ -160,7 +182,16 @@ de. La syntaxe n'est pas encore fixée, mais un fichier exemple est disponible pour des explication plus récentes, donc plus en -rapport avec la réalité du code. +rapport avec la réalité du code. En voici un extrait : + +\begin{verbatim} +# serial input from the control cpu +input_device s /dev/ttyACM0 +input_speed i 9600 +# -------------------------------------------------- +# some values for the eyecandy displays +eyecandy_banner s hacked by tTh +\end{verbatim} % ------------------------------------------------------------------- \section{RRDB} \label{rrdb} @@ -261,6 +292,10 @@ trop fatiguante à compiler pour ce soir, ni même pour ce week-end. \subsection{À regarder de près} +Est-il possible de traiter des \textit{time series} en SQL\index{SQL} ? + + + % ------------------------------------------------------------------- \section{Serial coms} \index{serial} \label{serial} @@ -320,7 +355,19 @@ Si vous voulez un petit exemple, imaginez des courbes de température qui pilotent un \texttt{uGen} de Chuck\index{chuck} ou des algues dont la lumière envoie du \texttt{cv/gate} en temps réel. -\subsection{Variante} +\subsection{Variante sonore} + +Un peu de \texttt{awk} pipé dans du \texttt{sox} ? + +\subsection{Eye candy}\index{eyecandy}\label{eyecandy} + +Pour maximiser l'impact visuel, il sera convenant de sortir du +cadre pseudo-moderne des omniprésents écrans de ces +smartphones\footnote{Quand les téléphones étaient attachés par +un fil, les humains étaient libres.} qui nous lavent le cerveau. +Sortons donc du contexte pixeliste et revenons aux fondamentaux : +le caractère, avec toute la simplicité de son concept sémantique. + % ------------------------------------------------------------------- From 23a8881b5cd17acd3de51cb55bdedc7096314c2b Mon Sep 17 00:00:00 2001 From: tth Date: Sun, 27 Jan 2019 14:59:26 +0100 Subject: [PATCH 075/110] slowing down the temp system --- simulator/rdtemp/rdtemp.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index 0df852c..fb0125c 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -12,6 +12,7 @@ int values[NBVAL]; void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); + Serial.print("\n"); delay(2000); } /* -------------------------------------------------- */ @@ -20,7 +21,7 @@ void updatevalues(void) int foo; for (foo=0; foo Date: Sun, 27 Jan 2019 15:25:40 +0100 Subject: [PATCH 076/110] GOING PURE ASCII --- viz/gnuplot/plot-two.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viz/gnuplot/plot-two.sh b/viz/gnuplot/plot-two.sh index 207b559..fad3882 100755 --- a/viz/gnuplot/plot-two.sh +++ b/viz/gnuplot/plot-two.sh @@ -13,7 +13,7 @@ set output "${IMAGE}" set grid set title "Hourly average on the last ${NBLINES} samples" set xlabel "Heures" -set ylabel "Température" +set ylabel "Temperature" set yrange [ 5.0 : 30.0] plot "${TMPFILE}" with lines __EOC__ From 32e9b6cc2b4856302667ba08b280705313df6072 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 28 Jan 2019 13:25:13 +0100 Subject: [PATCH 077/110] adding more technobabbage to the doc --- doc/dd2-monitoring.tex | 46 +++++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index db95589..8cd9c1b 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -48,8 +48,17 @@ Les valeurs à mesurer étant de diverses natures, nous aurons l'occasion de découvrir plein de capteurs différents : température, humidité, \texttt{pH}, transparence, lumière, vibrations\dots +\setlength{\parskip}{0.05cm plus 0.05cm} +\tableofcontents +\setlength{\parskip}{0.21cm plus 0.21cm} + +\vspace{5cm} + +Bonne lecture. + % ------------------------------------------------------------------- +\pagebreak \section{Présentation générale} @@ -77,7 +86,7 @@ humidité, lumière, vibrations\dots Notre dd2monitor devrait donc aussi être capable d'envoyer des alertes en cas de souci, -par exemple si des algues\footnote{ou des pleurotes.} tentent de s'échapper. +par exemple si des algues\footnote{Ou des pleurotes.} tentent de s'échapper. \subsection{Stockage} @@ -88,7 +97,7 @@ choix, et nous allons en évaluer quelques uns : \texttt{rrdb}\index{rrdb} (page \pageref{rrdb}), \texttt{influxdb}\index{Influxdb} (page \pageref{influxdb}), \texttt{gnocchi}\index{Gnocchi} (page \pageref{gnocchi}) -\texttt{sqlite}\index{sqlite} (page \pageref{sqlite}) +\texttt{Sqlite}\index{sqlite} (page \pageref{sqlite}) La représentation interne des valeurs reste à définir pour la plupart d'entre elles. @@ -154,6 +163,8 @@ Une histoire pour la section \pageref{detournements} ? \subsection{Archivage} \index{archivage} \label{archivage} +\textsf{Conserver la mémoire de nos échecs.} + La création de cet outil de surveillance est un long parcours pavé d'essais et d'erreurs. Tout cela peut générer beaucoup de données. À titre d'exemple, la capture de température des @@ -178,9 +189,9 @@ nous devons nous-même lui décrire ce monde. Une description qui se fera avec des lignes de la forme '\texttt{input\_device s /dev/ttyACM0}' qui représentent des tuples \textit{clef-type-valeur}\footnote{Laissons les canards tranquilles.} -de. +de choses diverses. -La syntaxe n'est pas encore fixée, mais un fichier exemple est +La syntaxe n'est pas encore vraiment fixée, mais un fichier exemple est disponible pour des explication plus récentes, donc plus en rapport avec la réalité du code. En voici un extrait : @@ -193,6 +204,9 @@ input_speed i 9600 eyecandy_banner s hacked by tTh \end{verbatim} +Certains de ces paramètres pourront être surchargé par des options +de la ligne de commande\index{cli} ou des variables d'environnement. + % ------------------------------------------------------------------- \section{RRDB} \label{rrdb} @@ -266,6 +280,8 @@ Il semble bien que l'utilisation de \texttt{fetch} ne soit pas vraiment prévue pour ça, donc j'en arrive à la conclusion que quelque chose m'échappe. +On va laisser ça en suspens pour le moment. + % ------------------------------------------------------------------- \section{InfluxDB} \label{influxdb} @@ -290,10 +306,12 @@ trop fatiguante à compiler pour ce soir, ni même pour ce week-end. % ------------------------------------------------------------------- \section{Sqlite} \index{sqlite} \label{sqlite} -\subsection{À regarder de près} +\textsf{À regarder de près} Est-il possible de traiter des \textit{time series} en SQL\index{SQL} ? - +Peut-on utiliser Sqlite depuis un programme en Perl\index{Perl} ? +Faut-il commencer à trouver un \textit{usecase} crédible ? +NodeJs\index{nodejs} peut-il lire du Sqlite ? % ------------------------------------------------------------------- @@ -342,22 +360,27 @@ les températures) et se terminant par un \textit{newline}. \subsection{Un peu de code} \label{serialcode} +TODO\index{TODO} + % ------------------------------------------------------------------- \section{Détournements} \label{detournements} -Dans le contexte myryssien, il est évident que l'aspect artistique +Dans le contexte myryssien\index{Myrys}, il est évident que l'aspect +artistique\index{Art} doit être dès le départ pris en compte. Les possibilités ne seront limitées que par votre manque d'imagination. Si vous voulez un petit exemple, imaginez des courbes de température -qui pilotent un \texttt{uGen} de Chuck\index{chuck} ou des algues dont -la lumière envoie du \texttt{cv/gate} en temps réel. +qui pilotent un \texttt{uGen} de Chuck\index{Chuck} ou des algues dont +les pulses lumineux envoie du \texttt{cv/gate} en temps réel. \subsection{Variante sonore} Un peu de \texttt{awk} pipé dans du \texttt{sox} ? +Voire même l'occasion (ou un bon prétexte) de résoudre ce problème +de saut de phase qui me tracasse depuis des mois ? \subsection{Eye candy}\index{eyecandy}\label{eyecandy} @@ -366,9 +389,8 @@ cadre pseudo-moderne des omniprésents écrans de ces smartphones\footnote{Quand les téléphones étaient attachés par un fil, les humains étaient libres.} qui nous lavent le cerveau. Sortons donc du contexte pixeliste et revenons aux fondamentaux : -le caractère, avec toute la simplicité de son concept sémantique. - - +le caractère\index{ncurses}, +avec toute la simplicité de son concept sémantique. % ------------------------------------------------------------------- From 15c6cbd8aea47cdab3b58f4614c54fd1b9538357 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 28 Jan 2019 14:42:33 +0100 Subject: [PATCH 078/110] working on serial protocol --- serial/README.md | 2 ++ serial/essai.sh | 8 ++++---- serial/funcs.c | 13 ++++++++++++- serial/serial.h | 2 +- serial/t.c | 7 ++++++- 5 files changed, 25 insertions(+), 7 deletions(-) diff --git a/serial/README.md b/serial/README.md index a89a80a..7d76e1e 100644 --- a/serial/README.md +++ b/serial/README.md @@ -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. diff --git a/serial/essai.sh b/serial/essai.sh index 2526c3e..6c5d337 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -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, \ diff --git a/serial/funcs.c b/serial/funcs.c index bc59658..cfd1808 100644 --- a/serial/funcs.c +++ b/serial/funcs.c @@ -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++) { diff --git a/serial/serial.h b/serial/serial.h index 158a2d1..bf6977c 100644 --- a/serial/serial.h +++ b/serial/serial.h @@ -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]); diff --git a/serial/t.c b/serial/t.c index eed23c6..69af8a7 100644 --- a/serial/t.c +++ b/serial/t.c @@ -37,7 +37,7 @@ for (count=0; count= 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", From 1e2a5e9f3171b4236a40feb40617863788c8cbfd Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 28 Jan 2019 15:00:33 +0100 Subject: [PATCH 079/110] using sprintf on Arduino --- simulator/send-random/send-random.ino | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/simulator/send-random/send-random.ino b/simulator/send-random/send-random.ino index 5dbb913..6090f86 100644 --- a/simulator/send-random/send-random.ino +++ b/simulator/send-random/send-random.ino @@ -36,14 +36,13 @@ void updatevalues(void) void sendvalues(void) { int foo; + char ligne[100]; - Serial.print("X"); - for (foo=0; foo Date: Mon, 28 Jan 2019 15:58:56 +0100 Subject: [PATCH 080/110] tuning --- serial/essai.sh | 2 +- serial/t.c | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/serial/essai.sh b/serial/essai.sh index 6c5d337..4b2d194 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,7 +5,7 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=25 +NB_READ=9500 ./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} diff --git a/serial/t.c b/serial/t.c index 69af8a7..4f4b2e3 100644 --- a/serial/t.c +++ b/serial/t.c @@ -30,7 +30,8 @@ for (count=0; count 1) { - fprintf(stderr, "getline #%d -> %d\n", count, foo); + fprintf(stderr, "getline #%d on %d -> %d\n", + count, iters, foo); fprintf(stderr, "%s\n", ligne); } foo = parse4values(ligne, 'T', datas); From 1dcbc6746c824d703c048ab9fa5847e489b37043 Mon Sep 17 00:00:00 2001 From: tth Date: Mon, 28 Jan 2019 16:07:48 +0100 Subject: [PATCH 081/110] 7 seg : adding hex letters --- viz/curses/7segments.c | 10 ++++++++++ viz/curses/t.c | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index d895dc7..6b52458 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -86,6 +86,8 @@ fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__, win, lig, col, digit); #endif +if (isxdigit(digit)) digit = toupper(digit); + switch (digit) { case '0': bits = 0x3f; break; case '1': bits = 0x06; break; @@ -98,6 +100,14 @@ switch (digit) { case '8': bits = 0x7f; break; case '9': bits = 0x6f; break; + /* hexadecimal letters */ + case 'A': bits = 0x77; break; + case 'B': bits = 0x7c; break; + case 'C': bits = 0x39; break; + case 'D': bits = 0x5e; break; + case 'E': bits = 0x79; break; + case 'F': bits = 0x71; break; + case ' ': bits = 0; break; case '.': bits = 0x80; break; diff --git a/viz/curses/t.c b/viz/curses/t.c index afb036d..4143376 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -18,7 +18,7 @@ char ligne[100]; for (loop=0; loop Date: Mon, 28 Jan 2019 16:38:06 +0100 Subject: [PATCH 082/110] i like eyecandy --- viz/curses/t.c | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/viz/curses/t.c b/viz/curses/t.c index 4143376..9bc30b7 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -14,20 +14,26 @@ int verbosity; void demo_7segments(int nbl, int notused) { int loop, idx, c, p; -char ligne[100]; - +char ligne[120]; +time_t temps; for (loop=0; loop Date: Mon, 28 Jan 2019 16:57:45 +0100 Subject: [PATCH 083/110] adding core/sysmetrics.[ch] --- core/Makefile | 11 +++++++---- core/sysmetrics.c | 38 ++++++++++++++++++++++++++++++++++++++ core/sysmetrics.h | 4 ++++ core/t.c | 20 ++++++++++++++++++-- essai.c | 26 +++----------------------- 5 files changed, 70 insertions(+), 29 deletions(-) create mode 100644 core/sysmetrics.c create mode 100644 core/sysmetrics.h diff --git a/core/Makefile b/core/Makefile index 752f602..778f052 100644 --- a/core/Makefile +++ b/core/Makefile @@ -6,7 +6,7 @@ COPT = -Wall -fpic -g -DDEBUG_LEVEL=0 -OBJS = lut1024f.o parseconf.o utils.o +OBJS = lut1024f.o parseconf.o utils.o sysmetrics.o DEPS = Makefile ALIB = libdd2m-core.a # --------------------------------------------------- @@ -15,13 +15,16 @@ ${ALIB}: ${OBJS} ar r $@ $? lut1024f.o: lut1024f.c lut1024.h ${DEPS} - gcc -Wall -c $< + gcc $(COPT) -c $< parseconf.o: parseconf.c config.h ${DEPS} - gcc -Wall -c $< + gcc $(COPT) -c $< utils.o: utils.c utils.h ${DEPS} - gcc -Wall -c $< + gcc $(COPT) -c $< + +sysmetrics.o: sysmetrics.c ${DEPS} + gcc $(COPT) -c $< # --------------------------------------------------- diff --git a/core/sysmetrics.c b/core/sysmetrics.c new file mode 100644 index 0000000..2e536f8 --- /dev/null +++ b/core/sysmetrics.c @@ -0,0 +1,38 @@ +/* + * core/sysmetrics.c + */ + +#include +#include +#include +#include +#include + +#include "sysmetrics.h" + +extern int verbosity; + +/* --------------------------------------------------------------- */ + +int get_loadavg(double *where) +{ +FILE *fp; +double loads[3]; +int foo; + +if ( ! (fp=fopen("/proc/loadavg", "r")) ) { + perror("read loadavg"); + return -1; + } + +foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2); +if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo); + +memcpy(where, loads, 3 * sizeof(double)); + +fclose(fp); + +return 0; +} + +/* --------------------------------------------------------------- */ diff --git a/core/sysmetrics.h b/core/sysmetrics.h new file mode 100644 index 0000000..f27b60c --- /dev/null +++ b/core/sysmetrics.h @@ -0,0 +1,4 @@ + + +int get_loadavg(double *where); + diff --git a/core/t.c b/core/t.c index 059efa1..873a529 100644 --- a/core/t.c +++ b/core/t.c @@ -8,12 +8,29 @@ #include "lut1024.h" #include "config.h" +#include "sysmetrics.h" int verbosity; Configuration config; +/* ---------------------------------------------------------------- */ +int essai_sysmetrics(int k) +{ +double dvalues3[3]; +int foo; + +foo = get_loadavg(dvalues3); +if (foo) { + fprintf(stderr, "err get load avg %d\n", foo); + return -1; + } + +printf("load avg %f %f %f\n", dvalues3[0], dvalues3[1], dvalues3[2]); + +return 0; +} /* ---------------------------------------------------------------- */ int main (int argc, char *argv[]) @@ -21,14 +38,12 @@ int main (int argc, char *argv[]) int foo, opt; char *conffile = "dd2-monitor.conf"; - fprintf(stderr, "+\n+ DD2 MONITOR\n+\n"); /* set some default values */ verbosity = 0; - while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { case 'v': verbosity++; break; @@ -46,6 +61,7 @@ foo = parse_config(conffile, 0); fprintf(stderr, "parse_config(%s) -> %d\n\n", conffile, foo); show_config("foo"); +essai_sysmetrics(0); /* foo = load_lut1024f("foo.lut1024f", NULL, 1); fprintf(stderr, "chargement de la lut --> %d\n\n", foo); diff --git a/essai.c b/essai.c index bd7bdb8..01565c7 100644 --- a/essai.c +++ b/essai.c @@ -9,32 +9,11 @@ #include #include "core/utils.h" +#include "core/sysmetrics.h" int verbosity; /* --------------------------------------------------------------- */ - -int get_loadavg(double *where) -{ -FILE *fp; -double loads[3]; -int foo; - -if ( ! (fp=fopen("/proc/loadavg", "r")) ) { - perror("read loadavg"); - return -1; - } - -foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2); -if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo); - -memcpy(where, loads, 3 * sizeof(double)); - -fclose(fp); - -return 0; -} - /* --------------------------------------------------------------- */ int main(int argc, char *argv[]) @@ -54,7 +33,8 @@ foo = get_loadavg(loads); if (foo) fprintf(stderr, "get loadavg -> %d\n", foo); for (foo=0; foo<3; foo++) { il[foo] = ((int)(loads[foo] * 90.0)) & 0x3ff; - fprintf(stderr, "%f -> %d\n", loads[foo], il[foo]); + if (verbosity) + fprintf(stderr, "%f -> %d\n", loads[foo], il[foo]); } printf("%ld %d %d %d %d\n", time(NULL), getpid()%84, il[0], il[1], il[2]); From c52b1659b592e86a9c4374965faec8d74503f2d2 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 29 Jan 2019 23:25:59 +0100 Subject: [PATCH 084/110] more improvment on seven segments --- viz/curses/7segments.c | 35 +++++++++++++++++++++++++++++++++-- viz/curses/ecran.c | 3 +++ viz/curses/ecran.h | 2 ++ viz/curses/t.c | 38 +++++++++++++++++++++++++++++++++----- 4 files changed, 71 insertions(+), 7 deletions(-) diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index 6b52458..ad94fed 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include @@ -110,8 +110,9 @@ switch (digit) { case ' ': bits = 0; break; case '.': bits = 0x80; break; + case '-': bits = 0x40; break; - default: bits = 0x09; break; + default: bits = 0x49; break; } aff7segs_base(win, lig, col, bits, 0); @@ -119,4 +120,34 @@ aff7segs_base(win, lig, col, bits, 0); return 0; } /* ---------------------------------------------------------------- */ +int aff7segs_short(WINDOW * win, int lig, int col, short value) +{ +char buff[10]; +int idx; +sprintf(buff, "%6d", value); +mvwaddstr(win, lig-1, col, buff); +for (idx=0; idx Date: Wed, 30 Jan 2019 16:44:43 +0100 Subject: [PATCH 085/110] ready for the next step ? --- viz/curses/7segments.c | 6 +++--- viz/curses/ecran.c | 10 +++++++--- viz/curses/t.c | 16 +++++++++++----- viz/curses/vumetre.c | 24 ++++++++++++++++-------- 4 files changed, 37 insertions(+), 19 deletions(-) diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index ad94fed..ff12449 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -81,7 +81,7 @@ int aff7segs_digit(WINDOW * win, int lig, int col, char digit) { int bits; -#if TRACE +#if TRACE > 1 fprintf(stderr, ">>> %s ( %p %d %d '%c' )\n", __func__, win, lig, col, digit); #endif @@ -126,7 +126,7 @@ char buff[10]; int idx; sprintf(buff, "%6d", value); -mvwaddstr(win, lig-1, col, buff); +// mvwaddstr(win, lig-1, col, buff); for (idx=0; idx %s\n", __func__, buffer); foo = strlen(buffer); mvaddstr(0, COLS-2-foo, buffer); } diff --git a/viz/curses/t.c b/viz/curses/t.c index 17992cd..a74f4ab 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include @@ -21,16 +22,21 @@ float fval; for (loop=0; loop>> %s ( %p %d %d %f %d )\n", __func__, win, lig, col, val, larg); #endif -posc = (int)(val * (float)larg); +posc = (int)(val * (float)(larg-5)); sprintf(ligne, "%6.3f", val); -mvwaddstr(win, lig, 2, ligne); +mvwaddstr(win, lig, 0, ligne); for (foo=0; foo Date: Wed, 30 Jan 2019 19:14:40 +0100 Subject: [PATCH 086/110] making a perfmeter --- Makefile | 4 ++-- core/sysmetrics.c | 8 ++++---- core/sysmetrics.h | 2 +- core/t.c | 6 +++--- essai.c | 47 +++++++++++++++++++++++++++++++++++++---------- 5 files changed, 47 insertions(+), 20 deletions(-) diff --git a/Makefile b/Makefile index d43301d..8f8bf2d 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,14 @@ CC = gcc CCOPT = -Wall -g -CLIB = core/libdd2m-core.a +CLIB = core/libdd2m-core.a viz/libdd2m-viz.a all: essai fake-values # --------------------------------------------- essai: essai.c Makefile $(CLIB) - $(CC) ${CCOPT} $< $(CLIB) -o $@ + $(CC) ${CCOPT} $< $(CLIB) -lncurses -o $@ fake-values: fake-values.c Makefile $(CLIB) $(CC) ${CCOPT} $< $(CLIB) -o $@ diff --git a/core/sysmetrics.c b/core/sysmetrics.c index 2e536f8..032da13 100644 --- a/core/sysmetrics.c +++ b/core/sysmetrics.c @@ -14,10 +14,10 @@ extern int verbosity; /* --------------------------------------------------------------- */ -int get_loadavg(double *where) +int get_loadavg(float *where) { FILE *fp; -double loads[3]; +float loads[3]; int foo; if ( ! (fp=fopen("/proc/loadavg", "r")) ) { @@ -25,10 +25,10 @@ if ( ! (fp=fopen("/proc/loadavg", "r")) ) { return -1; } -foo = fscanf(fp, "%lf %lf %lf", loads, loads+1, loads+2); +foo = fscanf(fp, "%f %f %f", loads, loads+1, loads+2); if (3 != foo) fprintf(stderr, "%s : read %d vals\n", __func__, foo); -memcpy(where, loads, 3 * sizeof(double)); +memcpy(where, loads, 3 * sizeof(float)); fclose(fp); diff --git a/core/sysmetrics.h b/core/sysmetrics.h index f27b60c..bb99b15 100644 --- a/core/sysmetrics.h +++ b/core/sysmetrics.h @@ -1,4 +1,4 @@ -int get_loadavg(double *where); +int get_loadavg(float *where); diff --git a/core/t.c b/core/t.c index 873a529..5fbeda1 100644 --- a/core/t.c +++ b/core/t.c @@ -18,16 +18,16 @@ Configuration config; /* ---------------------------------------------------------------- */ int essai_sysmetrics(int k) { -double dvalues3[3]; +float fvalues3[3]; int foo; -foo = get_loadavg(dvalues3); +foo = get_loadavg(fvalues3); if (foo) { fprintf(stderr, "err get load avg %d\n", foo); return -1; } -printf("load avg %f %f %f\n", dvalues3[0], dvalues3[1], dvalues3[2]); +printf("load avg %f %f %f\n", fvalues3[0], fvalues3[1], fvalues3[2]); return 0; } diff --git a/essai.c b/essai.c index 01565c7..2697382 100644 --- a/essai.c +++ b/essai.c @@ -6,21 +6,44 @@ #include #include #include +#include #include #include "core/utils.h" #include "core/sysmetrics.h" +#include "viz/curses/ecran.h" int verbosity; /* --------------------------------------------------------------- */ +int affiche_loadavg(int nbloops, int k) +{ +int idx, foo; +float lds[3]; + +for (idx=0; idx %d\n", foo); + + foo = aff7segs_float(stdscr, 4, 9, lds[0]); + foo = aff7segs_float(stdscr, 14, 9, lds[1]); + foo = aff7segs_float(stdscr, 24, 9, lds[2]); + + usleep(200*1000); + } +return 0; +} +/* --------------------------------------------------------------- */ +static void finish(int signal) +{ +endwin(); exit(0); +} /* --------------------------------------------------------------- */ int main(int argc, char *argv[]) { int opt, foo; -double loads[3]; -int il[3]; while ((opt = getopt(argc, argv, "v")) != -1) { switch (opt) { @@ -29,15 +52,19 @@ while ((opt = getopt(argc, argv, "v")) != -1) { } } -foo = get_loadavg(loads); -if (foo) fprintf(stderr, "get loadavg -> %d\n", foo); -for (foo=0; foo<3; foo++) { - il[foo] = ((int)(loads[foo] * 90.0)) & 0x3ff; - if (verbosity) - fprintf(stderr, "%f -> %d\n", loads[foo], il[foo]); - } -printf("%ld %d %d %d %d\n", time(NULL), getpid()%84, il[0], il[1], il[2]); +initscr(); +nonl(); cbreak(); noecho(); +keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ +fond_ecran(" Demonstrator "); + +affiche_loadavg(10000, 0); + +/* + * plop, on a fini, il faut restaurer la console + */ +finish(0); + return 0; } From a68ba6393bb73992c8a0350949c4d2c1186a0ff8 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 2 Feb 2019 03:52:30 +0100 Subject: [PATCH 087/110] are we ready for primetime ? --- essai.c | 4 +++- serial/essai.sh | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/essai.c b/essai.c index 2697382..46b2fb7 100644 --- a/essai.c +++ b/essai.c @@ -37,7 +37,9 @@ return 0; /* --------------------------------------------------------------- */ static void finish(int signal) { -endwin(); exit(0); +endwin(); +fprintf(stderr, "end of pid %d\n", getpid()); +exit(0); } /* --------------------------------------------------------------- */ diff --git a/serial/essai.sh b/serial/essai.sh index 4b2d194..e0014fc 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,9 +5,9 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=9500 +NB_READ=5000 -./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} +./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} gnuplot << __EOC__ set term png size 3200,512 From 58cf450675effb8363a6a77db16e2543b9dd63b2 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 2 Feb 2019 17:40:56 +0100 Subject: [PATCH 088/110] verbosity IS a global variable --- viz/curses/7segments.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viz/curses/7segments.c b/viz/curses/7segments.c index ff12449..9965a08 100644 --- a/viz/curses/7segments.c +++ b/viz/curses/7segments.c @@ -13,7 +13,7 @@ #include "ecran.h" -int verbosity; +extern int verbosity; /* ---------------------------------------------------------------- */ int aff7segs_base(WINDOW * win, int lig, int col, int bits, int k) From f29c8c330c0061b9f4958e81e0f4b3d1cd395a73 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 5 Feb 2019 12:16:27 +0100 Subject: [PATCH 089/110] introdicing the so cute minidigits ! --- storage/Makefile | 0 storage/t.c | 0 viz/curses/Makefile | 7 +++- viz/curses/ecran.c | 2 +- viz/curses/ecran.h | 2 + viz/curses/minidigits.c | 88 +++++++++++++++++++++++++++++++++++++++++ viz/curses/t.c | 37 ++++++++++++++++- 7 files changed, 133 insertions(+), 3 deletions(-) create mode 100644 storage/Makefile create mode 100644 storage/t.c create mode 100644 viz/curses/minidigits.c diff --git a/storage/Makefile b/storage/Makefile new file mode 100644 index 0000000..e69de29 diff --git a/storage/t.c b/storage/t.c new file mode 100644 index 0000000..e69de29 diff --git a/viz/curses/Makefile b/viz/curses/Makefile index 825e937..6f076e9 100644 --- a/viz/curses/Makefile +++ b/viz/curses/Makefile @@ -1,7 +1,9 @@ # --------------- *** COPT = -Wall -g -fpic -DTRACE=0 -OBJS = ecran.o 7segments.o waterfall.o vumetre.o +OBJS = ecran.o 7segments.o waterfall.o vumetre.o \ + minidigits.o + ALIB = ../libdd2m-viz.a # --------------- *** @@ -23,6 +25,9 @@ waterfall.o: waterfall.c Makefile ecran.h vumetre.o: vumetre.c Makefile ecran.h gcc $(COPT) -c $< +minidigits.o: minidigits.c Makefile ecran.h + gcc $(COPT) -c $< + # --------------- *** t: t.c Makefile $(ALIB) ecran.h diff --git a/viz/curses/ecran.c b/viz/curses/ecran.c index 4ba94c9..7f72116 100644 --- a/viz/curses/ecran.c +++ b/viz/curses/ecran.c @@ -21,7 +21,7 @@ fprintf(stderr, "%s [%s]\n", __func__, txt); #endif standout(); -mvhline(LINES-1, 0, '~', COLS); +mvhline(LINES-1, 0, ' ', COLS); mvaddch(LINES-1, 0, "\\|/-"[(pass++)%4]); mvaddstr(LINES-1, 2, txt); standend(); diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index f7770dd..8f317d3 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -10,6 +10,8 @@ int aff7segs_digit(WINDOW * win, int lig, int col, char digit); int aff7segs_short(WINDOW * win, int lig, int col, short value); int aff7segs_float(WINDOW * win, int lig, int col, float value); +int minidigit_0(WINDOW *win, int lig, int col, char digit, int k); + WINDOW * open_waterfall(char *title, int flags); int plot_waterfall(WINDOW *wf, int flags, float values[4]); diff --git a/viz/curses/minidigits.c b/viz/curses/minidigits.c new file mode 100644 index 0000000..0f305f0 --- /dev/null +++ b/viz/curses/minidigits.c @@ -0,0 +1,88 @@ +/* + * DD2 Monitoring + * + * mini digits + */ + +#include +#include +#include +#include +#include +#include + +#include "ecran.h" + +extern int verbosity; + +/* ---------------------------------------------------------------- */ +static void makedot(WINDOW *win, int li, int col, int ch) +{ +if ('_'==ch) { + mvwaddch(win, li, col, ' '); + mvwaddch(win, li, col+1, ' '); + } +else { + wstandout(win); + mvwaddch(win, li, col, ' '); + mvwaddch(win, li, col+1, ' '); + wstandend(win); + } +} +/* ---------------------------------------------------------------- */ + +int minidigit_0(WINDOW *win, int lig, int col, char digit, int k) +{ +static char LX[] = "_X_X_X_X_X_X_X_"; +static char L0[] = "XXXX_XX_XX_XXXX"; +static char L1[] = "__X__X__X__X__X"; +static char L2[] = "XXX__XXXXX__XXX"; +static char L3[] = "XXX__XXXX__XXXX"; +static char L4[] = "X_XX_XXXX__X__X"; +static char L5[] = "XXXX__XXX__XXXX"; +static char L6[] = "XXXX__XXXX_XXXX"; +static char L7[] = "XXX__X__X__X__X"; +static char L8[] = "XXXX_XXXXX_XXXX"; +static char L9[] = "XXXX_XXXX__XXXX"; + +static char Lsp[] = "_______________"; /* space */ +static char Lmo[] = "______XXX______"; /* moins */ +static char Lco[] = "____X_____X____"; + +char *cptr; +int l, c; + +switch (digit) { + + case '0': cptr = L0; break; + case '1': cptr = L1; break; + case '2': cptr = L2; break; + case '3': cptr = L3; break; + case '4': cptr = L4; break; + case '5': cptr = L5; break; + case '6': cptr = L6; break; + case '7': cptr = L7; break; + case '8': cptr = L8; break; + case '9': cptr = L9; break; + + case ' ': cptr = Lsp; break; + case '-': cptr = Lmo; break; + case ':': cptr = Lco; break; + + default: cptr = LX; break; + + } + +for (l=0; l<5; l++) { + for (c=0; c<3; c++) { + + makedot(win, l+lig, (c*2)+col, *cptr++); + + } + } + +wrefresh(win); + +return 0; +} +/* ---------------------------------------------------------------- */ diff --git a/viz/curses/t.c b/viz/curses/t.c index a74f4ab..50d1565 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -11,6 +11,40 @@ int verbosity; +/* ---------------------------------------------------------------- */ +int demo_minidigits(int nbl, int k) +{ +int loop, foo; +char chaine[100]; +struct tm *p_tms; +time_t temps; + +for (loop=0; loop Date: Tue, 5 Feb 2019 15:18:45 +0100 Subject: [PATCH 090/110] better 1 digit --- viz/curses/minidigits.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/viz/curses/minidigits.c b/viz/curses/minidigits.c index 0f305f0..1adcf2b 100644 --- a/viz/curses/minidigits.c +++ b/viz/curses/minidigits.c @@ -35,7 +35,7 @@ int minidigit_0(WINDOW *win, int lig, int col, char digit, int k) { static char LX[] = "_X_X_X_X_X_X_X_"; static char L0[] = "XXXX_XX_XX_XXXX"; -static char L1[] = "__X__X__X__X__X"; +static char L1[] = "_X__X__X__X__X_"; static char L2[] = "XXX__XXXXX__XXX"; static char L3[] = "XXX__XXXX__XXXX"; static char L4[] = "X_XX_XXXX__X__X"; From ca420bc745c362ed0c5bc0541b4fdaf6f1415276 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 5 Feb 2019 15:36:01 +0100 Subject: [PATCH 091/110] adding decimal dot to minidigit --- viz/curses/minidigits.c | 4 +++- viz/curses/t.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/viz/curses/minidigits.c b/viz/curses/minidigits.c index 1adcf2b..412ecdb 100644 --- a/viz/curses/minidigits.c +++ b/viz/curses/minidigits.c @@ -47,7 +47,8 @@ static char L9[] = "XXXX_XXXX__XXXX"; static char Lsp[] = "_______________"; /* space */ static char Lmo[] = "______XXX______"; /* moins */ -static char Lco[] = "____X_____X____"; +static char Lco[] = "____X_____X____"; /* colomn */ +static char Ldp[] = "_____________X_"; /* decimal dot */ char *cptr; int l, c; @@ -68,6 +69,7 @@ switch (digit) { case ' ': cptr = Lsp; break; case '-': cptr = Lmo; break; case ':': cptr = Lco; break; + case '.': cptr = Ldp; break; default: cptr = LX; break; diff --git a/viz/curses/t.c b/viz/curses/t.c index 50d1565..b1204a5 100644 --- a/viz/curses/t.c +++ b/viz/curses/t.c @@ -38,7 +38,7 @@ for (loop=0; loop Date: Tue, 5 Feb 2019 16:50:09 +0100 Subject: [PATCH 092/110] des minidigits pour afficher l'heure --- viz/curses/ecran.h | 1 + viz/curses/minidigits.c | 17 +++++++++++++++++ viz/curses/t.c | 16 ++++++---------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/viz/curses/ecran.h b/viz/curses/ecran.h index 8f317d3..40ae535 100644 --- a/viz/curses/ecran.h +++ b/viz/curses/ecran.h @@ -11,6 +11,7 @@ int aff7segs_short(WINDOW * win, int lig, int col, short value); int aff7segs_float(WINDOW * win, int lig, int col, float value); int minidigit_0(WINDOW *win, int lig, int col, char digit, int k); +int minidigit_HMS(WINDOW *win, int lig, int col, int k); WINDOW * open_waterfall(char *title, int flags); diff --git a/viz/curses/minidigits.c b/viz/curses/minidigits.c index 412ecdb..b86b9b9 100644 --- a/viz/curses/minidigits.c +++ b/viz/curses/minidigits.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -88,3 +89,19 @@ wrefresh(win); return 0; } /* ---------------------------------------------------------------- */ +int minidigit_HMS(WINDOW *win, int lig, int col, int k) +{ +int foo; +char chaine[20]; +struct tm *p_tms; +time_t temps; + +temps = time(NULL); +p_tms = localtime(&temps); +(void)strftime(chaine, 19, "%H:%M:%S", p_tms); +for (foo=0; foo Date: Wed, 6 Feb 2019 17:22:32 +0100 Subject: [PATCH 093/110] bloup... --- essai.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/essai.c b/essai.c index 46b2fb7..4f1e175 100644 --- a/essai.c +++ b/essai.c @@ -2,16 +2,16 @@ * essai.c */ -#include -#include -#include -#include +#include +#include +#include +#include #include -#include +#include -#include "core/utils.h" -#include "core/sysmetrics.h" -#include "viz/curses/ecran.h" +#include "core/utils.h" +#include "core/sysmetrics.h" +#include "viz/curses/ecran.h" int verbosity; From 4aa595060cccf7fbdaba0b72f5175ff37dcb8883 Mon Sep 17 00:00:00 2001 From: phyto Date: Wed, 6 Feb 2019 22:18:50 +0100 Subject: [PATCH 094/110] pimp up my minidigit --- viz/curses/minidigits.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/viz/curses/minidigits.c b/viz/curses/minidigits.c index b86b9b9..0d4ff1a 100644 --- a/viz/curses/minidigits.c +++ b/viz/curses/minidigits.c @@ -25,8 +25,8 @@ if ('_'==ch) { } else { wstandout(win); - mvwaddch(win, li, col, ' '); - mvwaddch(win, li, col+1, ' '); + mvwaddch(win, li, col, '+'); + mvwaddch(win, li, col+1, '+'); wstandend(win); } } From 1538abe15f32c953e778f2efa0bdb020be6f41b5 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 6 Feb 2019 23:01:48 +0100 Subject: [PATCH 095/110] bla bla --- doc/dd2-monitoring.tex | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 8cd9c1b..d5ac234 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -82,11 +82,12 @@ la température. Ils seront connectés sur l'automate qui s'en servira pour la régulation thermostatique. Il nous reste à choisir d'autres capteurs pour d'autres métriques : -humidité, lumière, vibrations\dots +humidité, lumière, vibrations, perturbations psychiques\dots Notre dd2monitor devrait donc aussi être capable d'envoyer des alertes en cas de souci, -par exemple si des algues\footnote{Ou des pleurotes.} tentent de s'échapper. +par exemple si des algues\footnote{Ou des pleurotes, ou des morilles...} +tentent de s'échapper. \subsection{Stockage} @@ -133,8 +134,9 @@ de bonne efficacité. \textsf{Promis, on va en mettre ! Dès que ça marche\dots} Un premier exemple avec rrdb en page \pageref{rrdb}. -Le second cause des premiers essais du LM35, capteur de -température analogique branché sur un Arduino et relié +Le second cause des premiers essais du LM35\index{LM35}, +capteur de +température analogique branché sur un Arduino Mega et relié par un port série (page \pageref{serialcode}). Pour continuer dans une démarche disruptive, des outils @@ -163,7 +165,7 @@ Une histoire pour la section \pageref{detournements} ? \subsection{Archivage} \index{archivage} \label{archivage} -\textsf{Conserver la mémoire de nos échecs.} +\textsf{Conserver la mémoire de nos échecs.} La création de cet outil de surveillance est un long parcours pavé d'essais et d'erreurs. Tout cela peut générer beaucoup @@ -397,7 +399,8 @@ avec toute la simplicité de son concept sémantique. \section{Conclusion} \label{conclusion} \index{conclusion} En fait, tout reste à faire. Mais ça peut être un beau projet -aux implications et usages multiples. +aux implications et usages multiples. À condition de bien +faire les choses. Un couteau suisse de la capture du monde réel, un point pivot de nos diverses interprétations de @@ -407,7 +410,7 @@ l'univers\footnote{non, la terre n'est pas plate} et des interactions % ------------------------------------------------------------------- \setlength{\parskip}{0.05cm plus 0.05cm} -\pagebreak \tableofcontents +% \pagebreak \tableofcontents \printindex From acd1248fa5b84ea4c34a668a96b41302996726d5 Mon Sep 17 00:00:00 2001 From: tth Date: Thu, 7 Feb 2019 10:18:10 +0100 Subject: [PATCH 096/110] using 1.1v Vref on the Arduino analog to digital converter for better precision --- serial/essai.sh | 6 +++--- serial/funcs.c | 8 +++++++- serial/t.c | 6 +++--- simulator/rdtemp/rdtemp.ino | 13 ++++++++++--- 4 files changed, 23 insertions(+), 10 deletions(-) diff --git a/serial/essai.sh b/serial/essai.sh index e0014fc..9f9f773 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -7,17 +7,17 @@ TMPFILE="/tmp/dd2data" IMAGE="graphe.png" NB_READ=5000 -./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 term png size 3200,640 set output "${IMAGE}" set grid set title "Temperature dans le Double Dragon 2" set xdata time set timefmt "%s" set format x "%a, %H:%M:%S" -set yrange [ 5.0 : 30.0] +set yrange [ 0.0 : 30.0] plot "${DATAFILE}" using 1:2 title " foo" with lines, \ "${DATAFILE}" using 1:3 title " bar" with lines, \ "${DATAFILE}" using 1:4 title "quux" with lines, \ diff --git a/serial/funcs.c b/serial/funcs.c index cfd1808..d670534 100644 --- a/serial/funcs.c +++ b/serial/funcs.c @@ -45,12 +45,18 @@ return value; /* * this fonction is specific to the LM35 thermo-sensor * connected to a ADC pin of an Arduino Mega + * + * WARNING ! + * this function _must_ be modofied if you change the + * Vref of the Analog to Digital converter on the + * Arduino ! + * */ int values2temperature(float array[4]) { int foo; for (foo=0; foo<4; foo++) { - array[foo] *= (5.0 / 1023.0 * 100.0); + array[foo] *= (1.1 / 1023.0 * 100.0); } return 0; } diff --git a/serial/t.c b/serial/t.c index 4f4b2e3..02a73c9 100644 --- a/serial/t.c +++ b/serial/t.c @@ -29,9 +29,9 @@ float datas[4]; for (count=0; count 1) { - fprintf(stderr, "getline #%d on %d -> %d\n", - count, iters, foo); + if (verbosity) { + /* fprintf(stderr, "getline #%d on %d -> %d\n", + count, iters, foo); */ fprintf(stderr, "%s\n", ligne); } foo = parse4values(ligne, 'T', datas); diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index fb0125c..9f2610c 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -4,7 +4,7 @@ /* -------------------------------------------------- */ #define NBVAL 4 -#define DELAI 10000 +#define DELAI 12000 int values[NBVAL]; @@ -13,7 +13,14 @@ void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); Serial.print("\n"); - delay(2000); + /* XXX */ + /* changing the voltage reference of the ADC + * greatly increase the prcision on the limited + * range of our temperatures. + */ + analogReference(INTERNAL1V1); // Pour Arduino Mega2560 + + delay(1000); } /* -------------------------------------------------- */ void updatevalues(void) @@ -21,7 +28,7 @@ void updatevalues(void) int foo; for (foo=0; foo Date: Sat, 9 Feb 2019 04:06:09 +0100 Subject: [PATCH 097/110] better temperature hourly plot --- serial/essai.sh | 4 ++-- viz/gnuplot/av4v-h.awk | 2 +- viz/gnuplot/plot-two.sh | 11 ++++++++--- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/serial/essai.sh b/serial/essai.sh index 9f9f773..06ab908 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -10,13 +10,13 @@ NB_READ=5000 ./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} gnuplot << __EOC__ -set term png size 3200,640 +set term png size 4200,640 set output "${IMAGE}" set grid set title "Temperature dans le Double Dragon 2" set xdata time set timefmt "%s" -set format x "%a, %H:%M:%S" +set format x "%d, %H:%M:%S" set yrange [ 0.0 : 30.0] plot "${DATAFILE}" using 1:2 title " foo" with lines, \ "${DATAFILE}" using 1:3 title " bar" with lines, \ diff --git a/viz/gnuplot/av4v-h.awk b/viz/gnuplot/av4v-h.awk index e8b353d..115fd44 100755 --- a/viz/gnuplot/av4v-h.awk +++ b/viz/gnuplot/av4v-h.awk @@ -21,7 +21,7 @@ BEGIN { } else { val = cumul /compte; - print heures, val; + print $1, val; lasthour = heures; cumul = 0; compte = 0; diff --git a/viz/gnuplot/plot-two.sh b/viz/gnuplot/plot-two.sh index fad3882..b177d1a 100755 --- a/viz/gnuplot/plot-two.sh +++ b/viz/gnuplot/plot-two.sh @@ -1,7 +1,7 @@ #!/bin/bash INFILE="../../serial/foo.dat" -NBLINES=50000 +NBLINES=60000 TMPFILE="/tmp/dd2data.$$" IMAGE="av4v-h.png" @@ -14,8 +14,13 @@ set grid set title "Hourly average on the last ${NBLINES} samples" set xlabel "Heures" set ylabel "Temperature" -set yrange [ 5.0 : 30.0] -plot "${TMPFILE}" with lines +set yrange [ 0.0 : 30.0] + +set xdata time +set timefmt "%s" +set format x "%d, %H:%M" + +plot "${TMPFILE}" using 1:2 title "celcius" with lines __EOC__ cat -n ${TMPFILE} | tail -20 From 1290ee1dff0191b280558da4afe345094b8a431f Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 20 Feb 2019 16:12:15 +0100 Subject: [PATCH 098/110] + exemple gnuplot / + format flatfile --- doc/dd2-monitoring.tex | 62 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index d5ac234..3ae1300 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -1,4 +1,3 @@ - \documentclass[a4paper,11pt]{article} % \listfiles % pour le debug @@ -50,13 +49,14 @@ de découvrir plein de capteurs différents : température, humidité, \setlength{\parskip}{0.05cm plus 0.05cm} \tableofcontents -\setlength{\parskip}{0.21cm plus 0.21cm} +\setlength{\parskip}{0.16cm plus 0.16cm} \vspace{5cm} Bonne lecture. % ------------------------------------------------------------------- +% =================================================================== \pagebreak \section{Présentation générale} @@ -95,6 +95,7 @@ tentent de s'échapper. Pour entreposer toutes ces valeurs numériques, il existe plusieurs choix, et nous allons en évaluer quelques uns : +\texttt{flatfile}\index{flatfile} (page \pageref{flatfile}), \texttt{rrdb}\index{rrdb} (page \pageref{rrdb}), \texttt{influxdb}\index{Influxdb} (page \pageref{influxdb}), \texttt{gnocchi}\index{Gnocchi} (page \pageref{gnocchi}) @@ -114,6 +115,7 @@ d'eyecandy\index{eyecandy} ne peut pas faire de mal. C'est expliqué à la page \pageref{eyecandy}\index{curses}. % ------------------------------------------------------------------- +% =================================================================== \section{Outils} \subsection{Simulations} @@ -128,6 +130,7 @@ Nous avons également un générateur de nombres divers et incohérents qui envoie des quadruplets d'entiers 10 bits précédés d'un caractere de bonne efficacité. +% ------------------------------------------------------------------- \subsection{Exemples} @@ -142,6 +145,7 @@ par un port série (page \pageref{serialcode}). Pour continuer dans une démarche disruptive, des outils avancés de visualisation sont proposés dans la rubrique \ref{eyecandy} qui parle de \texttt{vt100}\label{vt100}. +% ------------------------------------------------------------------- \subsection{Analyses} @@ -162,6 +166,7 @@ Générer des formes d'ondes spatialisables ? Déplacer des petites \textit{bubulles} colorées ? Une histoire pour la section \pageref{detournements} ? +% ------------------------------------------------------------------- \subsection{Archivage} \index{archivage} \label{archivage} @@ -184,6 +189,36 @@ si on lui demande gentiment. % ------------------------------------------------------------------- +\subsection{Affichage}\index{affichage} + +Un exemple d'affichage avec Gnuplot\index{gnuplot} d'un fichier +de température (décrit page \pageref{foo.dat}) : + +\begin{verbatim} +DATAFILE="foo.dat" +IMAGE="graphe.png" + +gnuplot << __EOC__ +set term png size 4200,640 +set output "${IMAGE}" +set grid +set title "Temperature dans le Double Dragon 2" +set xdata time +set timefmt "%s" +set format x "%d, %H:%M:%S" +set yrange [ 0.0 : 30.0] +plot "${DATAFILE}" using 1:2 title " foo" with lines, \ + "${DATAFILE}" using 1:3 title " bar" with lines, \ + "${DATAFILE}" using 1:4 title "quux" with lines, \ + "${DATAFILE}" using 1:5 title "booz" with lines +__EOC__ + +\end{verbatim} + + + +% =================================================================== + \section{Configuration} \index{configuration} \label{configuration} Pour adapter cet outil de surveillance aux variations du monde réel, @@ -208,6 +243,29 @@ eyecandy_banner s hacked by tTh Certains de ces paramètres pourront être surchargé par des options de la ligne de commande\index{cli} ou des variables d'environnement. +% =================================================================== + +\section{Flatfile} \label{flatfile} + +Parfois, un fichier à plat est bien pratique, parce qu'il est facilement +machinable avec des outils comme Awk\index{Awk}. +Après tout, un \textsl{timestamp}\index{timestamp} et quelques valeurs +numériques peuvent suffire à beaucoup de \textsl{usecases} de la +vie courante. + +Voici un exemple, un format\label{foo.dat} d'enregistrement de +température facilement exploitable avec Gnuplot : + +\begin{verbatim} +tth@phytotron:~/DD2-monitor/doc$ tail -3 ../serial/foo.dat +1550673785 20.215054 20.107527 20.107527 20.215054 +1550673811 20.215054 20.215054 20.215054 20.215054 +1550673836 20.215054 20.107527 20.215054 20.215054 +\end{verbatim} + +Prochainement, dès que le premier prototype matériel fournira des +données, une tentative de visualisation animée sera faite avec +POVray\index{POV}. % ------------------------------------------------------------------- \section{RRDB} \label{rrdb} From c0f3e128aaf7f62837d82925d3b0cbe9df0a780a Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 22 Feb 2019 15:42:24 +0100 Subject: [PATCH 099/110] modularisation du source de la documentation, LaTeX p0w4 --- doc/automate.tex | 39 +++++++++++++++++++++ doc/dd2-monitoring.tex | 78 +++++++++++------------------------------- doc/serial.tex | 58 +++++++++++++++++++++++++++++++ 3 files changed, 117 insertions(+), 58 deletions(-) create mode 100644 doc/automate.tex create mode 100644 doc/serial.tex diff --git a/doc/automate.tex b/doc/automate.tex new file mode 100644 index 0000000..38850e4 --- /dev/null +++ b/doc/automate.tex @@ -0,0 +1,39 @@ +\section{Automate} \index{automate} \label{automate} + +L'automate qui contrôle les fonctions vitales des petites +\textit{Pyrocystis Fusiformis} est basé sur un Arduino Mega\index{mega}, +qui a été choisi pour sa profusion d'entrées sorties\index{io}. +Il va remplir plusieurs fonctions mises au point les unes et les autres. + +Dans un premier temps, le logiciel sera développé avec l'\textsl{IDE} +standard de l'Arduiono, malgré ses limitations. +Il existe des solutions alternatives à base de \texttt{makefile}, que +nous découvrirons un jour, si le besoin s'en fait sentir. + +% ------------------------------------------------------------------- +\subsection{Dialogue} + +% ------------------------------------------------------------------- +\subsection{Température} \index{temperature} + +% ------------------------------------------------------------------- +\subsection{Voyants} + +Il faut \textbf{toujours} intégrer dans un projet une gestion avancée +des \textsc{LED}\index{LED} qui clignotent avec entrain. + +% ------------------------------------------------------------------- +\subsection{Chauffage} \index{chauffage} + + +% ------------------------------------------------------------------- +\subsection{Refroidissement}. + +% ------------------------------------------------------------------- + + + + + + + diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 3ae1300..9957913 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -14,7 +14,7 @@ \usepackage[verbose]{layout} \makeindex -\setlength{\parskip}{0.21cm plus 0.21cm} +% \setlength{\parskip}{0.16cm plus 0.16cm} % ------------------------------------------------------------------- \title{DD2 Monitoring} @@ -47,11 +47,11 @@ Les valeurs à mesurer étant de diverses natures, nous aurons l'occasion de découvrir plein de capteurs différents : température, humidité, \texttt{pH}, transparence, lumière, vibrations\dots -\setlength{\parskip}{0.05cm plus 0.05cm} +% \setlength{\parskip}{0.01cm plus 0.01cm} \tableofcontents -\setlength{\parskip}{0.16cm plus 0.16cm} +% \setlength{\parskip}{0.16cm plus 0.16cm} -\vspace{5cm} +\vspace{4cm} Bonne lecture. @@ -61,8 +61,6 @@ Bonne lecture. \pagebreak \section{Présentation générale} - - \subsection{Capteurs} \index{capteurs} Actuellement nous disposons d'un capteur température et @@ -75,6 +73,7 @@ l'influence humaine n'étant pas à négliger en cas d'afflux du public.. Par la suite, nous pourrons récupérer (par liaison série, cf page \pageref{serial}) des données diverses en provenance de l'automate de contrôle de l'enceinte. +Cet automate\index{automate} est décrit page \pageref{automate}. Le premier capteur de température sélectionné est le \textsc{LM35}\index{LM35} qui fournit en sortie une tension linéairement proportionnle à @@ -116,6 +115,12 @@ C'est expliqué à la page \pageref{eyecandy}\index{curses}. % ------------------------------------------------------------------- % =================================================================== +% nouveau 2019-02-22 + +\input{automate} + +% =================================================================== + \section{Outils} \subsection{Simulations} @@ -191,7 +196,8 @@ si on lui demande gentiment. \subsection{Affichage}\index{affichage} -Un exemple d'affichage avec Gnuplot\index{gnuplot} d'un fichier +Pour commencer presque simple, un exemple d'affichage avec +Gnuplot\index{gnuplot} d'un fichier plat de température (décrit page \pageref{foo.dat}) : \begin{verbatim} @@ -215,6 +221,9 @@ __EOC__ \end{verbatim} +Prochainement, dès que le premier prototype matériel fournira des +données, une tentative de visualisation animée sera faite avec +POVray\index{POV}. % =================================================================== @@ -243,6 +252,7 @@ eyecandy_banner s hacked by tTh Certains de ces paramètres pourront être surchargé par des options de la ligne de commande\index{cli} ou des variables d'environnement. + % =================================================================== \section{Flatfile} \label{flatfile} @@ -254,7 +264,7 @@ numériques peuvent suffire à beaucoup de \textsl{usecases} de la vie courante. Voici un exemple, un format\label{foo.dat} d'enregistrement de -température facilement exploitable avec Gnuplot : +température facilement exploitable avec Awk ou Gnuplot : \begin{verbatim} tth@phytotron:~/DD2-monitor/doc$ tail -3 ../serial/foo.dat @@ -263,9 +273,6 @@ tth@phytotron:~/DD2-monitor/doc$ tail -3 ../serial/foo.dat 1550673836 20.215054 20.107527 20.215054 20.215054 \end{verbatim} -Prochainement, dès que le premier prototype matériel fournira des -données, une tentative de visualisation animée sera faite avec -POVray\index{POV}. % ------------------------------------------------------------------- \section{RRDB} \label{rrdb} @@ -353,7 +360,7 @@ Au programme : écriture d'un injecteur en Perl\index{Perl}, en suivant plus ou moins l'exemple de rrdb.. Ceci dit, en Debian stable, on n'a que la version 1.0, qui ne -correspond plus trop à l'actualité. Et la \textit{current} est +correspond plus trop à l'actualité. Et la \textit{current} semble trop fatiguante à compiler pour ce soir, ni même pour ce week-end. % ------------------------------------------------------------------- @@ -376,52 +383,7 @@ NodeJs\index{nodejs} peut-il lire du Sqlite ? % ------------------------------------------------------------------- -\section{Serial coms} \index{serial} \label{serial} - -Il va y avoir deux liaisons série entre l'automate et le monitoring. -La première, que nous allons juste entrevoir, passera par le port -USB de la carte Arduino. La seconde passera par un port série -auxiliaire\footnote{Il y en a 4 sur le mega 2560} de celle-ci. - -\subsection{Un gros souci} - -\begin{lstlisting} -tcgetattr(uart0, &options); -options.c_cflag = baudbits | CS8 | CLOCAL | CREAD; -options.c_iflag = IGNPAR; -options.c_oflag = 0; -options.c_lflag = 0; -tcflush(uart0, TCIFLUSH); -tcsetattr(uart0, TCSANOW, &options); -\end{lstlisting} - -Et en fait, le \texttt{read} sur le \textsl{fd} du serial device -n'est pas bloquant, \texttt{perror} annonce \emph{success}, mais -rien ne marche. L'année 2019 va commencer sur du vaudou programming% -\footnote {aka shotgun debugging.}. - -\textit{29 décembre 2018} : le petit grain de magie\index{magie} -est très simple à mettre en oeuvre, mais -très difficle à spotter dans le gazillion d'options. Il semblerait -que mettre \texttt{options.c\_cc[VMIN]} à 1 permet d'avancer vers -l'étape suivante. - -Laquelle étape est une tentative d'utilisation de \texttt{select(2)}, -dans l'objectif de pouvoir gérer nous-même le \textit{timeout}, -laquelle tentative n'est pas du tout concluante. - -\subsection{Protocole} \index{protocole} \label{serialprotocol} - -L'automate va avoir plusieurs types de données à envoyer. -Nous allons donc transférer ces valeurs sous forme de ligne -de texte commençant par un caractère clef (par exemple T pour -les températures) et se terminant par un \textit{newline}. - - -\subsection{Un peu de code} \label{serialcode} - -TODO\index{TODO} - + \input{serial} % ------------------------------------------------------------------- diff --git a/doc/serial.tex b/doc/serial.tex new file mode 100644 index 0000000..aa55089 --- /dev/null +++ b/doc/serial.tex @@ -0,0 +1,58 @@ +% =================================================================== + +\section{Serial coms} \index{serial} \label{serial} + +Il va y avoir deux liaisons série entre l'automate et le monitoring. +La première, que nous allons juste entrevoir, passera par le port +USB de la carte Arduino. La seconde passera par un port série +auxiliaire\footnote{Il y en a 4 sur le mega 2560} de celle-ci. + +% ------------------------------------------------------------------- +\subsection{Un gros souci} + +\begin{lstlisting} +tcgetattr(uart0, &options); +options.c_cflag = baudbits | CS8 | CLOCAL | CREAD; +options.c_iflag = IGNPAR; +options.c_oflag = 0; +options.c_lflag = 0; +tcflush(uart0, TCIFLUSH); +tcsetattr(uart0, TCSANOW, &options); +\end{lstlisting} + +Et en fait, le \texttt{read} sur le \textsl{fd} du serial device +n'est pas bloquant, \texttt{perror} annonce \emph{success}, mais +rien ne marche. L'année 2019 va commencer sur du vaudou programming% +\footnote {aka shotgun debugging.}. + +\textit{29 décembre 2018} : le petit grain de magie\index{magie} +est très simple à mettre en oeuvre, mais +très difficle à spotter dans le gazillion d'options. Il semblerait +que mettre \texttt{options.c\_cc[VMIN]} à 1 permet d'avancer vers +l'étape suivante. + +Laquelle étape est une tentative d'utilisation de \texttt{select(2)}, +dans l'objectif de pouvoir gérer nous-même le \textit{timeout}, +laquelle tentative n'est pas du tout concluante. + +% ------------------------------------------------------------------- +\subsection{Protocole} \index{protocole} \label{serialprotocol} + +L'automate va avoir plusieurs types de données à envoyer. +Nous allons donc transférer ces valeurs sous forme de ligne +de texte commençant par un caractère clef (par exemple T pour +les températures) et se terminant par un \textit{newline}. + + +% ------------------------------------------------------------------- +\subsection{Un peu de code} \label{serialcode} + +\begin{lstlisting} +main() +{ + while(fork()); +} +\end{lstlisting} + + +% =================================================================== From c381b61b6082a1a80304deabb7b379c480010282 Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 22 Feb 2019 15:55:50 +0100 Subject: [PATCH 100/110] adding help() to test program --- serial/t.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/serial/t.c b/serial/t.c index 02a73c9..f56318b 100644 --- a/serial/t.c +++ b/serial/t.c @@ -51,6 +51,14 @@ for (count=0; count Date: Fri, 22 Feb 2019 16:02:01 +0100 Subject: [PATCH 101/110] more verbose display (timestamp) --- serial/t.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/serial/t.c b/serial/t.c index f56318b..9d4c3a7 100644 --- a/serial/t.c +++ b/serial/t.c @@ -25,6 +25,7 @@ int count, foo; long temps; char ligne[200]; float datas[4]; +struct tm *p_tms; for (count=0; count %d\n", __func__, foo); } - if (verbosity > 1) fprintf(stderr, "\n"); + // + if (verbosity > 1) + { + p_tms = localtime(&temps); + (void)strftime(ligne, 19, "%H:%M:%S", p_tms); + fprintf(stderr, "\t%s\n", ligne); + } } return 0; } From faca30264bdad57411fe41f6c5e6cadfb9b120d7 Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 22 Feb 2019 17:08:16 +0100 Subject: [PATCH 102/110] better verbose display --- serial/t.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/serial/t.c b/serial/t.c index 9d4c3a7..fffe1f1 100644 --- a/serial/t.c +++ b/serial/t.c @@ -35,6 +35,13 @@ for (count=0; count 1) + { + p_tms = localtime(&temps); + (void)strftime(ligne, 19, "%H:%M:%S", p_tms); + fprintf(stderr, "%6d %s\n", count, ligne); + } foo = parse4values(ligne, 'T', datas); // if (foo >= 0) { @@ -47,13 +54,6 @@ for (count=0; count %d\n", __func__, foo); } - // - if (verbosity > 1) - { - p_tms = localtime(&temps); - (void)strftime(ligne, 19, "%H:%M:%S", p_tms); - fprintf(stderr, "\t%s\n", ligne); - } } return 0; } From b6d49bd6f85f16bce35ce67490ad714e7f088d29 Mon Sep 17 00:00:00 2001 From: tth Date: Fri, 22 Feb 2019 17:16:01 +0100 Subject: [PATCH 103/110] now reading all 4 tempecaptors --- simulator/rdtemp/rdtemp.ino | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index 9f2610c..6042e2f 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -6,8 +6,6 @@ #define NBVAL 4 #define DELAI 12000 -int values[NBVAL]; - /* -------------------------------------------------- */ void setup() { Serial.begin(9600); @@ -21,33 +19,43 @@ void setup() { analogReference(INTERNAL1V1); // Pour Arduino Mega2560 delay(1000); + Serial.print("M running\n"); } /* -------------------------------------------------- */ -void updatevalues(void) +/* ================================================== */ +short adc_pins[] = { A0, A1, A2, A4 }; +/* -------------------------------------------------- */ +void updatevalues(short *ptr) { int foo; for (foo=0; foo Date: Fri, 22 Feb 2019 17:25:24 +0100 Subject: [PATCH 104/110] patching and testing again... --- serial/essai.sh | 6 +++--- serial/t.c | 7 ++++--- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/serial/essai.sh b/serial/essai.sh index 06ab908..b6b3d4e 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,19 +5,19 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=5000 +NB_READ=500 ./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} gnuplot << __EOC__ -set term png size 4200,640 +set term png size 1280,640 set output "${IMAGE}" set grid set title "Temperature dans le Double Dragon 2" set xdata time set timefmt "%s" set format x "%d, %H:%M:%S" -set yrange [ 0.0 : 30.0] +set yrange [ 0.0 : 30.0 ] plot "${DATAFILE}" using 1:2 title " foo" with lines, \ "${DATAFILE}" using 1:3 title " bar" with lines, \ "${DATAFILE}" using 1:4 title "quux" with lines, \ diff --git a/serial/t.c b/serial/t.c index fffe1f1..3eef5fe 100644 --- a/serial/t.c +++ b/serial/t.c @@ -23,7 +23,7 @@ int loop(int sfd, int iters) { int count, foo; long temps; -char ligne[200]; +char ligne[200], buff[200]; float datas[4]; struct tm *p_tms; @@ -39,9 +39,10 @@ for (count=0; count 1) { p_tms = localtime(&temps); - (void)strftime(ligne, 19, "%H:%M:%S", p_tms); - fprintf(stderr, "%6d %s\n", count, ligne); + (void)strftime(buff, 19, "%H:%M:%S", p_tms); + fprintf(stderr, "%s %6d / %d\n", buff, count, iters); } + // foo = parse4values(ligne, 'T', datas); // if (foo >= 0) { From 71534c19bc7a74c5570f997f77bf586e30f58d78 Mon Sep 17 00:00:00 2001 From: tth Date: Sat, 23 Feb 2019 16:39:04 +0100 Subject: [PATCH 105/110] adding blinkenlight --- simulator/rdtemp/rdtemp.ino | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index 6042e2f..3d7bc69 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -10,6 +10,7 @@ void setup() { Serial.begin(9600); pinMode(LED_BUILTIN, OUTPUT); + Serial.print("\n"); /* XXX */ /* changing the voltage reference of the ADC @@ -28,10 +29,12 @@ short adc_pins[] = { A0, A1, A2, A4 }; void updatevalues(short *ptr) { int foo; + digitalWrite(LED_BUILTIN, HIGH); for (foo=0; foo Date: Sat, 23 Feb 2019 16:40:02 +0100 Subject: [PATCH 106/110] no more seconds --- serial/essai.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/serial/essai.sh b/serial/essai.sh index b6b3d4e..7e4dca2 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,7 +5,7 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=500 +NB_READ=2500 ./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} @@ -16,7 +16,7 @@ set grid set title "Temperature dans le Double Dragon 2" set xdata time set timefmt "%s" -set format x "%d, %H:%M:%S" +set format x "%d, %H:%M" set yrange [ 0.0 : 30.0 ] plot "${DATAFILE}" using 1:2 title " foo" with lines, \ "${DATAFILE}" using 1:3 title " bar" with lines, \ From 8a5d00f2895d5cb28a79278e1ced6d0a66aff9b0 Mon Sep 17 00:00:00 2001 From: tth Date: Tue, 26 Feb 2019 11:18:46 +0100 Subject: [PATCH 107/110] un peu plus de doc... --- doc/automate.tex | 46 +++++++++++- doc/dd2-monitoring.tex | 163 +++++------------------------------------ doc/detournements.tex | 29 ++++++++ doc/storages.tex | 111 ++++++++++++++++++++++++++++ 4 files changed, 202 insertions(+), 147 deletions(-) create mode 100644 doc/detournements.tex create mode 100644 doc/storages.tex diff --git a/doc/automate.tex b/doc/automate.tex index 38850e4..b7882c8 100644 --- a/doc/automate.tex +++ b/doc/automate.tex @@ -2,7 +2,7 @@ L'automate qui contrôle les fonctions vitales des petites \textit{Pyrocystis Fusiformis} est basé sur un Arduino Mega\index{mega}, -qui a été choisi pour sa profusion d'entrées sorties\index{io}. +qui a été choisi pour sa profusion d'entrées sorties\index{i/o}. Il va remplir plusieurs fonctions mises au point les unes et les autres. Dans un premier temps, le logiciel sera développé avec l'\textsl{IDE} @@ -10,25 +10,67 @@ standard de l'Arduiono, malgré ses limitations. Il existe des solutions alternatives à base de \texttt{makefile}, que nous découvrirons un jour, si le besoin s'en fait sentir. +Ce lo + % ------------------------------------------------------------------- \subsection{Dialogue} +Le but étant d'avoir un système +\textsl{standalone}\footnote{lowcost and easytouse ?}, le dialogue +avec les humains extérieur sera plus que limité en fonctionnement +courant. + +Pour la configuration, nous allons créer une \textsc{CLI}\index{cli} +rudimentaire qui sera accessible par le port USB et un émulateur +de terminal\footnote{Minicom, Putty...}. + % ------------------------------------------------------------------- \subsection{Température} \index{temperature} +Les capteurs utilisés sont des LM35\index{LM35}, à sortie analogique +entre 0 et 5v pour une gamme de température de 0 à ??? degrés Celsius. + +Le convertisseur \small{A/D} a une résolution de 10 bits, qu'il +est possible d'augmenter en changeant son Vref, soit pour une +référence externe, soit pour une référence interne à 1.1 V. + % ------------------------------------------------------------------- \subsection{Voyants} Il faut \textbf{toujours} intégrer dans un projet une gestion avancée -des \textsc{LED}\index{LED} qui clignotent avec entrain. +des \textsc{led}\index{LED} qui clignotent avec entrain pour raconter +la vie interne de la machinerie. + +Une paire Rouge/Bleue indiquera les sorties de l'intervalle +de température pré-programmé. +Une \textsc{led} orange clignotante indiquera une erreur +en s'exprimant en code Morse. + +Quand à la \textsc{led} verte, elle sera là pour ne rien dire de précis, +mais avec brio. % ------------------------------------------------------------------- \subsection{Chauffage} \index{chauffage} +En première approche, un choix simple a été fait~: nous allons +utiliser un chauffage intégré d'aquarium en de basant d'abord +sur son thermostat intégré. + +Si ce n'est pas satisfaisant, pour diverses raisons (matériel +chinois à 3 balles, par exemple), +nous serons obligés de commander nous-même ce chauffage. + +C'est à ce moment que les choses deviennent sérieuses, il va +falloir commuter du 230v, tension assez mortelle dans les faits. +Une solution à base d'opto-coupleur semble s'imposer. % ------------------------------------------------------------------- \subsection{Refroidissement}. +Puisque l'enceinte choisi est un frigorifique de +récupération\footnote{Merci DomDom :)}, nous pourrons utiliser son +groupe froid. Comme pour le chauffage, nous sommes sur du 230v. + % ------------------------------------------------------------------- diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index 9957913..a30a71e 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -1,4 +1,4 @@ -\documentclass[a4paper,11pt]{article} +\documentclass[a4paper,10pt]{article} % \listfiles % pour le debug @@ -25,6 +25,12 @@ \pagebreak +% \setlength{\parskip}{0.01cm plus 0.01cm} +\tableofcontents +% \setlength{\parskip}{0.16cm plus 0.16cm} + +\pagebreak + % ------------------------------------------------------------------- \section{Introduction} @@ -41,15 +47,14 @@ arrivons parfois à le faire. La première étape sera donc la mise au point d'un \textsl{cadriciel} permettant d'essayer diverses options en se basant sur une conception -modulaire de l'ensemble. +modulaire de l'ensemble. Une grosse partie sera écrite en C\index{C}, +avec d'éventuels modules en langages de script : +Perl\index{Perl}, Awk\index{Awk}, Bash\index{Bash}\dots Les valeurs à mesurer étant de diverses natures, nous aurons l'occasion de découvrir plein de capteurs différents : température, humidité, \texttt{pH}, transparence, lumière, vibrations\dots -% \setlength{\parskip}{0.01cm plus 0.01cm} -\tableofcontents -% \setlength{\parskip}{0.16cm plus 0.16cm} \vspace{4cm} @@ -92,7 +97,7 @@ tentent de s'échapper. \subsection{Stockage} Pour entreposer toutes ces valeurs numériques, il existe plusieurs -choix, et nous allons en évaluer quelques uns : +choix, et nous allons en évaluer quelques uns~: \texttt{flatfile}\index{flatfile} (page \pageref{flatfile}), \texttt{rrdb}\index{rrdb} (page \pageref{rrdb}), @@ -115,9 +120,9 @@ C'est expliqué à la page \pageref{eyecandy}\index{curses}. % ------------------------------------------------------------------- % =================================================================== -% nouveau 2019-02-22 +% nouveau 2019-02-22 -\input{automate} + \input{automate} % =================================================================== @@ -150,6 +155,7 @@ par un port série (page \pageref{serialcode}). Pour continuer dans une démarche disruptive, des outils avancés de visualisation sont proposés dans la rubrique \ref{eyecandy} qui parle de \texttt{vt100}\label{vt100}. + % ------------------------------------------------------------------- \subsection{Analyses} @@ -263,8 +269,8 @@ Après tout, un \textsl{timestamp}\index{timestamp} et quelques valeurs numériques peuvent suffire à beaucoup de \textsl{usecases} de la vie courante. -Voici un exemple, un format\label{foo.dat} d'enregistrement de -température facilement exploitable avec Awk ou Gnuplot : +Voici le premier exemple, un format\label{foo.dat} d'enregistrement de +température facilement exploitable avec Awk ou Gnuplot : \begin{verbatim} tth@phytotron:~/DD2-monitor/doc$ tail -3 ../serial/foo.dat @@ -275,145 +281,12 @@ tth@phytotron:~/DD2-monitor/doc$ tail -3 ../serial/foo.dat % ------------------------------------------------------------------- -\section{RRDB} \label{rrdb} - -Première tentative d'utilisation le lendemain du premier apéro 2019 -du Tetalab\footnote{Jean-Yves, je vous demande de vous calmer !}. - -Je suis parti sur quelques scripts shell, pour créer, mettre à jour et -analyser les enregistrements d'une valeur de type \textsc{gauge}. - -\subsection{Create} - -\begin{lstlisting} -#!/bin/bash - -source ./commun.sh -starttime=$(date +'%s') -echo creating $RRDB at ${starttime}s since epoch -rrdtool create $RRDB \ - --start $starttime \ - --step 60 \ - DS:value:GAUGE:150:0:10 \ - RRA:AVERAGE:0.5:1:60 -\end{lstlisting} - -\subsection{Update} \index{rrdtool} - -Une fois la base créée, il faut bien la remplir. -Dans cet exemple, nous allons utiliser le \textit{load} -de notre Linux. - -\begin{lstlisting} -#!/bin/bash - -source ./commun.sh -ctime=$(date +'%s') -value=$(cut -d ' ' -f 1 /proc/loadavg) - -# inject value in the rrdb file -rrdtool update $RRDB ${ctime}:${value} -\end{lstlisting} - -\subsection{Analyze} - -Nous allons essayer d'exploiter les données dûrement acquises -pendant les heures qui précèdent\dots - -\begin{lstlisting} -#!/bin/bash - -source ./commun.sh -tmpf="somevalues.dat" -rrdtool fetch $RRDB LAST | -tr -d ':' | -awk ' - (!/nan/ && NF==2) { print $1, $2 } - ' \ - > ${tmpf} - -# as an example, we are gnuploting our datas -gnuplot << __EOC__ -set term png size 800,600 -set output "graphe.png" -set grid -plot "${tmpf}" with lines -__EOC__ - -rm ${tmpf} -\end{lstlisting} - -Il semble bien que l'utilisation de \texttt{fetch} ne soit pas -vraiment prévue pour ça, donc j'en arrive à la conclusion que -quelque chose m'échappe. - -On va laisser ça en suspens pour le moment. - -% ------------------------------------------------------------------- - -\section{InfluxDB} \label{influxdb} - -La communication avec la bédédé se fait \textit{over HTTP}, un peu -comme tous ces trucs de d'jeunz d'aujourd'hui\dots - -Au programme : écriture d'un injecteur en Perl\index{Perl}, en suivant -plus ou moins l'exemple de rrdb.. - -Ceci dit, en Debian stable, on n'a que la version 1.0, qui ne -correspond plus trop à l'actualité. Et la \textit{current} semble -trop fatiguante à compiler pour ce soir, ni même pour ce week-end. - -% ------------------------------------------------------------------- - -\section{Gnocchi} \label{gnocchi} \index{Gnocchi} - -\texttt{pip install gnocchi[postgresql,ceph,keystone]}, finalement, -çe ne me donne pas trop envie. C'est du genre \textit{usinagaz}. - -% ------------------------------------------------------------------- -\section{Sqlite} \index{sqlite} \label{sqlite} - -\textsf{À regarder de près} - -Est-il possible de traiter des \textit{time series} en SQL\index{SQL} ? -Peut-on utiliser Sqlite depuis un programme en Perl\index{Perl} ? -Faut-il commencer à trouver un \textit{usecase} crédible ? -NodeJs\index{nodejs} peut-il lire du Sqlite ? - + \input{storages} % ------------------------------------------------------------------- \input{serial} - -% ------------------------------------------------------------------- - -\section{Détournements} \label{detournements} - -Dans le contexte myryssien\index{Myrys}, il est évident que l'aspect -artistique\index{Art} -doit être dès le départ pris en compte. -Les possibilités ne seront limitées que par votre manque d'imagination. - -Si vous voulez un petit exemple, imaginez des courbes de température -qui pilotent un \texttt{uGen} de Chuck\index{Chuck} ou des algues dont -les pulses lumineux envoie du \texttt{cv/gate} en temps réel. - -\subsection{Variante sonore} - -Un peu de \texttt{awk} pipé dans du \texttt{sox} ? -Voire même l'occasion (ou un bon prétexte) de résoudre ce problème -de saut de phase qui me tracasse depuis des mois ? - -\subsection{Eye candy}\index{eyecandy}\label{eyecandy} - -Pour maximiser l'impact visuel, il sera convenant de sortir du -cadre pseudo-moderne des omniprésents écrans de ces -smartphones\footnote{Quand les téléphones étaient attachés par -un fil, les humains étaient libres.} qui nous lavent le cerveau. -Sortons donc du contexte pixeliste et revenons aux fondamentaux : -le caractère\index{ncurses}, -avec toute la simplicité de son concept sémantique. - + \input{detournements} % ------------------------------------------------------------------- \section{Conclusion} \label{conclusion} \index{conclusion} diff --git a/doc/detournements.tex b/doc/detournements.tex new file mode 100644 index 0000000..d68bd45 --- /dev/null +++ b/doc/detournements.tex @@ -0,0 +1,29 @@ +% ------------------------------------------------------------------- + +\section{Détournements} \label{detournements} + +Dans le contexte myryssien\index{Myrys}, il est évident que l'aspect +artistique\index{Art} +doit être dès le départ pris en compte. +Les possibilités ne seront limitées que par votre manque d'imagination. + +Si vous voulez un petit exemple, imaginez des courbes de température +qui pilotent un \texttt{uGen} de Chuck\index{Chuck} ou des algues dont +les pulses lumineux envoie du \texttt{cv/gate} en temps réel. + +\subsection{Variante sonore} + +Un peu de \texttt{awk} pipé dans du \texttt{sox} ? +Voire même l'occasion (ou un bon prétexte) de résoudre ce problème +de saut de phase qui me tracasse depuis des mois ? + +\subsection{Eye candy}\index{eyecandy}\label{eyecandy} + +Pour maximiser l'impact visuel, il sera convenant de sortir du +cadre pseudo-moderne des omniprésents écrans de ces +smartphones\footnote{Quand les téléphones étaient attachés par +un fil, les humains étaient libres.} qui nous lavent le cerveau. +Sortons donc du contexte pixeliste et revenons aux fondamentaux : +le caractère\index{ncurses} blanc sur fond noir, +avec toute la simplicité de son concept sémantique. + diff --git a/doc/storages.tex b/doc/storages.tex new file mode 100644 index 0000000..9be6d84 --- /dev/null +++ b/doc/storages.tex @@ -0,0 +1,111 @@ +% ============================================ +% +% Various storages systems +% +% ============================================ + +\section{RRDB} \label{rrdb} + +Première tentative d'utilisation le lendemain du premier apéro 2019 +du Tetalab\footnote{Jean-Yves, je vous demande de vous calmer !}. + +Je suis parti sur quelques scripts shell, pour créer, mettre à jour et +analyser les enregistrements d'une valeur de type \textsc{gauge}. + +\subsection{Create} + +\begin{lstlisting} +#!/bin/bash + +source ./commun.sh +starttime=$(date +'%s') +echo creating $RRDB at ${starttime}s since epoch +rrdtool create $RRDB \ + --start $starttime \ + --step 60 \ + DS:value:GAUGE:150:0:10 \ + RRA:AVERAGE:0.5:1:60 +\end{lstlisting} + +\subsection{Update} \index{rrdtool} + +Une fois la base créée, il faut bien la remplir. +Dans cet exemple, nous allons utiliser le \textit{load} +de notre Linux. + +\begin{lstlisting} +#!/bin/bash + +source ./commun.sh +ctime=$(date +'%s') +value=$(cut -d ' ' -f 1 /proc/loadavg) + +# inject value in the rrdb file +rrdtool update $RRDB ${ctime}:${value} +\end{lstlisting} + +\subsection{Analyze} + +Nous allons essayer d'exploiter les données dûrement acquises +pendant les heures qui précèdent\dots + +\begin{lstlisting} +#!/bin/bash + +source ./commun.sh +tmpf="somevalues.dat" +rrdtool fetch $RRDB LAST | +tr -d ':' | +awk ' + (!/nan/ && NF==2) { print $1, $2 } + ' \ + > ${tmpf} + +# as an example, we are gnuploting our datas +gnuplot << __EOC__ +set term png size 800,600 +set output "graphe.png" +set grid +plot "${tmpf}" with lines +__EOC__ + +rm ${tmpf} +\end{lstlisting} + +Il semble bien que l'utilisation de \texttt{fetch} ne soit pas +vraiment prévue pour ça, donc j'en arrive à la conclusion que +quelque chose m'échappe. + +On va laisser ça en suspens pour le moment. + +% ------------------------------------------------------------------- + +\section{InfluxDB} \label{influxdb} + +La communication avec la bédédé se fait \textit{over HTTP}, un peu +comme tous ces trucs de d'jeunz d'aujourd'hui\dots + +Au programme : écriture d'un injecteur en Perl\index{Perl}, en suivant +plus ou moins l'exemple de rrdb.. + +Ceci dit, en Debian stable, on n'a que la version 1.0, qui ne +correspond plus trop à l'actualité. Et la \textit{current} semble +trop fatiguante à compiler pour ce soir, ni même pour ce week-end. + +% ------------------------------------------------------------------- + +\section{Gnocchi} \label{gnocchi} \index{Gnocchi} + +\texttt{pip install gnocchi[postgresql,ceph,keystone]}, finalement, +çe ne me donne pas trop envie. C'est du genre \textit{usinagaz}. + +% ------------------------------------------------------------------- +\section{Sqlite} \index{sqlite} \label{sqlite} + +\textsf{À regarder de près} + +Est-il possible de traiter des \textit{time series} en SQL\index{SQL} ? +Peut-on utiliser Sqlite depuis un programme en Perl\index{Perl} ? +Faut-il commencer à trouver un \textit{usecase} crédible ? +NodeJs\index{nodejs} peut-il lire du Sqlite ? + From 3e1ad5b3c96e59980eac638e05facfc349ab4950 Mon Sep 17 00:00:00 2001 From: tth Date: Wed, 27 Feb 2019 08:24:29 +0100 Subject: [PATCH 108/110] nothing important to see --- doc/dd2-monitoring.tex | 2 +- doc/serial.tex | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/doc/dd2-monitoring.tex b/doc/dd2-monitoring.tex index a30a71e..dce648c 100644 --- a/doc/dd2-monitoring.tex +++ b/doc/dd2-monitoring.tex @@ -1,4 +1,4 @@ -\documentclass[a4paper,10pt]{article} +\documentclass[a4paper,11pt]{article} % \listfiles % pour le debug diff --git a/doc/serial.tex b/doc/serial.tex index aa55089..287ed20 100644 --- a/doc/serial.tex +++ b/doc/serial.tex @@ -40,8 +40,9 @@ laquelle tentative n'est pas du tout concluante. L'automate va avoir plusieurs types de données à envoyer. Nous allons donc transférer ces valeurs sous forme de ligne -de texte commençant par un caractère clef (par exemple T pour -les températures) et se terminant par un \textit{newline}. +de texte commençant par un caractère clef +(par exemple \texttt{T} pour les températures) +et se terminant par un \textit{newline}. % ------------------------------------------------------------------- From 17ec8dd47de73dd285b2448fb623ddc814cc857d Mon Sep 17 00:00:00 2001 From: phyto Date: Wed, 27 Mar 2019 21:52:16 +0100 Subject: [PATCH 109/110] les affaires repartent --- serial/essai.sh | 8 ++++---- simulator/rdtemp/rdtemp.ino | 8 +++++--- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/serial/essai.sh b/serial/essai.sh index 7e4dca2..7ad73b6 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,12 +5,12 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=2500 +NB_READ=100 -./t -vv -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} +./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} gnuplot << __EOC__ -set term png size 1280,640 +set term png size 1600,640 set output "${IMAGE}" set grid set title "Temperature dans le Double Dragon 2" @@ -24,6 +24,6 @@ plot "${DATAFILE}" using 1:2 title " foo" with lines, \ "${DATAFILE}" using 1:5 title "booz" with lines __EOC__ -# display ${IMAGE} +# display ${IMAGE} diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index 3d7bc69..d5ebe76 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -4,7 +4,7 @@ /* -------------------------------------------------- */ #define NBVAL 4 -#define DELAI 12000 +#define DELAI 2000 /* -------------------------------------------------- */ void setup() { @@ -21,6 +21,7 @@ void setup() { delay(1000); Serial.print("M running\n"); + } /* -------------------------------------------------- */ /* ================================================== */ @@ -31,8 +32,10 @@ void updatevalues(short *ptr) int foo; digitalWrite(LED_BUILTIN, HIGH); for (foo=0; foo Date: Thu, 28 Mar 2019 12:04:40 +0100 Subject: [PATCH 110/110] first real run on the phytotron --- Makefile | 4 ++- essai.c | 50 +++++++++++++++++++++++++++++-------- serial/Makefile | 8 ++++-- serial/essai.sh | 2 +- simulator/rdtemp/rdtemp.ino | 4 +-- 5 files changed, 51 insertions(+), 17 deletions(-) diff --git a/Makefile b/Makefile index 8f8bf2d..fd68c20 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,10 @@ all: essai fake-values # --------------------------------------------- +O = serial/serial.o serial/funcs.o + essai: essai.c Makefile $(CLIB) - $(CC) ${CCOPT} $< $(CLIB) -lncurses -o $@ + $(CC) ${CCOPT} $< $(CLIB) ${O} -lncurses -o $@ fake-values: fake-values.c Makefile $(CLIB) $(CC) ${CCOPT} $< $(CLIB) -o $@ diff --git a/essai.c b/essai.c index 4f1e175..4ccb172 100644 --- a/essai.c +++ b/essai.c @@ -11,26 +11,36 @@ #include "core/utils.h" #include "core/sysmetrics.h" +#include "serial/serial.h" #include "viz/curses/ecran.h" int verbosity; /* --------------------------------------------------------------- */ -int affiche_loadavg(int nbloops, int k) +int affiche_valeurs(int sfd, int nbloops) { int idx, foo; -float lds[3]; +char ligne[200], buff[200]; +float datas[4]; for (idx=0; idx %d\n", foo); + foo = getline_to(sfd, ligne, 100, 0); +#if DEBUG_LEVEL + if (foo) fprintf(stderr, "get values -> %d\n", foo); +#endif - foo = aff7segs_float(stdscr, 4, 9, lds[0]); - foo = aff7segs_float(stdscr, 14, 9, lds[1]); - foo = aff7segs_float(stdscr, 24, 9, lds[2]); + foo = parse4values(ligne, 'T', datas); +#if DEBUG_LEVEL + if (foo) fprintf(stderr, "parse -> %d\n", foo); +#endif + + values2temperature(datas); + + foo = aff7segs_float(stdscr, 3, 5, datas[0]); + foo = aff7segs_float(stdscr, 14, 5, datas[1]); + foo = aff7segs_float(stdscr, 25, 5, datas[2]); - usleep(200*1000); } return 0; } @@ -42,25 +52,45 @@ fprintf(stderr, "end of pid %d\n", getpid()); exit(0); } /* --------------------------------------------------------------- */ +void help(int k) +{ +puts("options : "); +puts("\t-d\tserial device to read."); +puts("\t-v\tincrease verbosity."); +exit(0); +} +/* --------------------------------------------------------------- */ int main(int argc, char *argv[]) { int opt, foo; +int serial_in; +char *device = "/dev/ttyACM0"; -while ((opt = getopt(argc, argv, "v")) != -1) { +while ((opt = getopt(argc, argv, "d:hv")) != -1) { switch (opt) { + case 'd': device = optarg; break; + case 'h': help(0); break; case 'v': verbosity++; break; default: break; } } +serial_in = prepare_UART(device, 9600); +if (serial_in < 0) { + fprintf(stderr, "%s : open device : error %d on %s\n", + argv[0], serial_in, device); + exit(1); + } + + initscr(); nonl(); cbreak(); noecho(); keypad(stdscr, TRUE); /* acces aux touches 'curseur' */ fond_ecran(" Demonstrator "); -affiche_loadavg(10000, 0); +affiche_valeurs(serial_in, 10000); /* * plop, on a fini, il faut restaurer la console diff --git a/serial/Makefile b/serial/Makefile index 6448e47..8ceb6ee 100644 --- a/serial/Makefile +++ b/serial/Makefile @@ -1,5 +1,7 @@ OPT = -Wall -DDEBUG_LEVEL=0 +OBJS = serial.o funcs.o +# --------------------------------------------------- serial.o: serial.c serial.h Makefile gcc ${OPT} -c $< @@ -7,6 +9,8 @@ serial.o: serial.c serial.h Makefile funcs.o: funcs.c serial.h Makefile gcc ${OPT} -c $< -t: t.c serial.o funcs.o Makefile - gcc ${OPT} $< serial.o funcs.o -o $@ +# --------------------------------------------------- + +t: t.c Makefile ${OBJS} + gcc ${OPT} $< ${OBJS} -o $@ diff --git a/serial/essai.sh b/serial/essai.sh index 7ad73b6..f40b101 100755 --- a/serial/essai.sh +++ b/serial/essai.sh @@ -5,7 +5,7 @@ DATAFILE="foo.dat" TMPFILE="/tmp/dd2data" IMAGE="graphe.png" -NB_READ=100 +NB_READ=10 ./t -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE} diff --git a/simulator/rdtemp/rdtemp.ino b/simulator/rdtemp/rdtemp.ino index d5ebe76..81695d7 100644 --- a/simulator/rdtemp/rdtemp.ino +++ b/simulator/rdtemp/rdtemp.ino @@ -4,7 +4,7 @@ /* -------------------------------------------------- */ #define NBVAL 4 -#define DELAI 2000 +#define DELAI 5000 /* -------------------------------------------------- */ void setup() { @@ -32,9 +32,7 @@ void updatevalues(short *ptr) int foo; digitalWrite(LED_BUILTIN, HIGH); for (foo=0; foo