Browse Source

+ conversion sortie lm25 -> celsius

tth 1 year ago
parent
commit
8989ff558b
5 changed files with 16 additions and 4 deletions
  1. 1
    1
      serial/essai.sh
  2. 9
    0
      serial/funcs.c
  3. 2
    0
      serial/serial.h
  4. 3
    2
      serial/t.c
  5. 1
    1
      simulator/rdtemp/rdtemp.ino

+ 1
- 1
serial/essai.sh View File

@@ -5,7 +5,7 @@ DATAFILE="foo.dat"
5 5
 TMPFILE="/tmp/dd2data"
6 6
 
7 7
 IMAGE="graphe.png"
8
-NB_READ=50
8
+NB_READ=160
9 9
 
10 10
 ./t -v -n ${NB_READ} -d ${DEVICE} | tee -a ${DATAFILE}
11 11
 

+ 9
- 0
serial/funcs.c View File

@@ -35,6 +35,15 @@ for (foo=0; foo<4; foo++) {
35 35
 return value;
36 36
 }
37 37
 /* ---------------------------------------------------------------- */
38
+int values2temps(float array[4])
39
+{
40
+int	foo;
41
+for (foo=0; foo<4; foo++) {
42
+ 	array[foo] *= (5.0 / 1023.0 * 100.0);
43
+	}
44
+return 0;
45
+}
46
+/* ---------------------------------------------------------------- */
38 47
 int parse4values(char *line, char cflag, float array[4])
39 48
 {
40 49
 float		ftmp[4];

+ 2
- 0
serial/serial.h View File

@@ -17,6 +17,8 @@ int getline_to(int fd, char *where, int szm, int to_ms);
17 17
 /* auxiliary and test functions */
18 18
 
19 19
 int parseXvalue(char *asciidatas, char id);
20
+int values2temps(float array[4]);
21
+
20 22
 int parse4values(char *line, char cflag, float array[4]);
21 23
 
22 24
 

+ 3
- 2
serial/t.c View File

@@ -29,7 +29,7 @@ float		datas[4];
29 29
 for (count=0; count<iters; count++) {
30 30
 	foo = getline_to(sfd, ligne, 100, 0);
31 31
 	//
32
-	if (verbosity) {
32
+	if (verbosity > 1) {
33 33
 		fprintf(stderr, "getline #%d -> %d\n", count, foo);
34 34
 		fprintf(stderr, "%s\n", ligne);
35 35
 		}
@@ -37,6 +37,7 @@ for (count=0; count<iters; count++) {
37 37
 	// 
38 38
 	if (foo >= 0) {
39 39
 		temps = time(NULL);
40
+		values2temps(datas);
40 41
 		printf("%ld %f %f %f %f\n", temps,
41 42
 				datas[0], datas[1], datas[2], datas[3]);
42 43
 		fflush(stdout);
@@ -44,7 +45,7 @@ for (count=0; count<iters; count++) {
44 45
 	else	{
45 46
 		fprintf(stderr, "%s: parse -> %d\n", __func__, foo);
46 47
 		}
47
-	if (verbosity) fprintf(stderr, "\n");
48
+	if (verbosity > 1) fprintf(stderr, "\n");
48 49
 	}
49 50
 return 0;
50 51
 }

+ 1
- 1
simulator/rdtemp/rdtemp.ino View File

@@ -4,7 +4,7 @@
4 4
 /* -------------------------------------------------- */
5 5
 
6 6
 #define NBVAL   4
7
-#define DELAI   5000
7
+#define DELAI   10000
8 8
 
9 9
 int   values[NBVAL];
10 10
 

Loading…
Cancel
Save