Browse Source

Merge branch 'master' of ssh://tetalab.org:2213/tTh/DD2-monitor

parce que je le vaux bien...
tth 6 months ago
parent
commit
3b1d756cad
6 changed files with 52 additions and 39 deletions
  1. 4
    4
      Makefile
  2. 35
    1
      core/utils.c
  3. 2
    0
      core/utils.h
  4. 10
    2
      essai.c
  5. 0
    31
      ui/t.c
  6. 1
    1
      ui/terminal.c

+ 4
- 4
Makefile View File

@@ -5,18 +5,18 @@
5 5
 CC	= gcc
6 6
 CCOPT	= -Wall -g 
7 7
 CLIB	= core/libdd2m-core.a viz/libdd2m-viz.a
8
-OBJS	= essai.o terminal.o
8
+
9 9
 all:	essai 
10 10
 
11 11
 # -------------------------------------------------------
12 12
 
13
-OSERIAL	= serial/serial.o serial/funcs.o
13
+OSERIAL	= serial/serial.o serial/funcs.o ui/terminal.o
14 14
 
15 15
 essai.o:	essai.c  Makefile 
16 16
 	$(CC) ${CCOPT} $< -c 
17 17
 
18
-essai:	${OBJS} Makefile $(CLIB) ${OSERIAL}
19
-	$(CC) ${CCOPT} $< $(CLIB) ${OSERIAL} -lncurses -o $@
18
+essai:	essai.o Makefile $(CLIB) ${OSERIAL}
19
+	$(CC) ${CCOPT} $< ${OSERIAL} $(CLIB) -lncurses -o $@
20 20
 
21 21
 fake-values:	fake-values.c  Makefile $(CLIB)
22 22
 	$(CC) ${CCOPT} $< $(CLIB)  -o $@

+ 35
- 1
core/utils.c View File

@@ -6,13 +6,47 @@
6 6
 #include <unistd.h>
7 7
 #include  <stdlib.h>
8 8
 #include  <string.h>
9
+#include  <ctype.h>
9 10
 #include  <time.h>
10 11
 #include  <sys/time.h>
11 12
 
13
+#include  "utils.h"
14
+
12 15
 extern int verbosity;
13 16
 
14 17
 /* --------------------------------------------------------------- */
15
-/* maybe not a really goof initialisation... */
18
+int special_dumper(FILE *fp, unsigned char octet)
19
+{
20
+static int		idx = 0;
21
+static unsigned char	buffer[16];
22
+
23
+int			foo, c;
24
+
25
+#if DEBUG_LEVEL > 1
26
+fprintf(stderr, "%s $%x %c\n", __func__, octet, octet);
27
+#endif
28
+
29
+buffer[idx++] = octet;
30
+
31
+if (idx==16) {
32
+	fprintf(fp, "dmp : ");
33
+	for (foo=0; foo<16; foo++) {
34
+		fprintf(fp, "%02x ", buffer[foo]);
35
+		if (7==foo)	fprintf(fp, " ");
36
+		}
37
+	fprintf(fp, "  -   |");
38
+	for (foo=0; foo<16; foo++) {
39
+		c = buffer[foo];
40
+		fprintf(fp, "%c", isprint(c) ? c : ' ');
41
+		}
42
+	fprintf(fp, "|\n");	fflush(fp);
43
+	idx = 0;
44
+	}
45
+
46
+return 0;
47
+}
48
+/* ---------------------------------------------------------------- */
49
+/* maybe not a really good initialisation... */
16 50
 int seed_my_rand(int foo)
17 51
 {
18 52
 long	v1, v2;

+ 2
- 0
core/utils.h View File

@@ -2,6 +2,8 @@
2 2
  *		core/utils.h
3 3
  */
4 4
 
5
+int special_dumper(FILE *fp, unsigned char octet);
6
+
5 7
 int	seed_my_rand(int foo);
6 8
 int	random1000(int type);
7 9
 

+ 10
- 2
essai.c View File

@@ -15,8 +15,10 @@
15 15
 #include	"serial/serial.h"
16 16
 #include	"viz/curses/ecran.h"
17 17
 
18
-int	verbosity;
19 18
 
19
+int run_the_terminal(int fd_serial, char *title, WINDOW *win);	/* XXX */
20
+
21
+int	verbosity;
20 22
 
21 23
 /* --------------------------------------------------------------- */
22 24
 int traite_les_messages(int sfd, int nbloops)
@@ -38,7 +40,7 @@ if (NULL==fp) {
38 40
 for (idx=0; idx<nbloops; idx++) {
39 41
 
40 42
 	if (kbhit()) {
41
-		static char valid_k[] = "+-";
43
+		static char valid_k[] = "+-01";
42 44
 		key = getch();
43 45
 
44 46
 		/* if it is a valid key, send it to the Arduino */
@@ -47,6 +49,12 @@ for (idx=0; idx<nbloops; idx++) {
47 49
 			fprintf(stderr, "put byte %02X -> %d\n",
48 50
 						key, foo);
49 51
 			}
52
+		else if (0x14==key) {		/* request for terminal */
53
+
54
+			foo = run_the_terminal(sfd, " terminal ", 0);
55
+			sprintf(ligne, "retour terminal = %d", foo);
56
+			aff_message(ligne);	sleep(1);
57
+			}
50 58
 		else	{
51 59
 			sprintf(ligne, "Key 0x%02X invalid ", key);
52 60
 			fprintf(stderr, "%s\n", ligne);

+ 0
- 31
ui/t.c View File

@@ -13,37 +13,6 @@
13 13
 
14 14
 int	verbosity;
15 15
 
16
-/* ---------------------------------------------------------------- */
17
-int special_dumper(FILE *fp, unsigned char octet)
18
-{
19
-static int		idx = 0;
20
-static unsigned char	buffer[16];
21
-
22
-int			foo, c;
23
-
24
-#if DEBUG_LEVEL > 1
25
-fprintf(stderr, "%s $%x %c\n", __func__, octet, octet);
26
-#endif
27
-
28
-buffer[idx++] = octet;
29
-
30
-if (idx==16) {
31
-	fprintf(fp, "dmp : ");
32
-	for (foo=0; foo<16; foo++) {
33
-		fprintf(fp, "%02x ", buffer[foo]);
34
-		if (7==foo)	fprintf(fp, " ");
35
-		}
36
-	fprintf(fp, "  -   |");
37
-	for (foo=0; foo<16; foo++) {
38
-		c = buffer[foo];
39
-		fprintf(fp, "%c", isprint(c) ? c : ' ');
40
-		}
41
-	fprintf(fp, "|\n");	fflush(fp);
42
-	idx = 0;
43
-	}
44
-
45
-return 0;
46
-}
47 16
 /* ---------------------------------------------------------------- */
48 17
 
49 18
 void help(int k)

+ 1
- 1
ui/terminal.c View File

@@ -90,7 +90,7 @@ do	{
90 90
 	if (FD_ISSET(fd_local, &rfds)) {
91 91
 		received = getch();
92 92
 
93
-#if DEBUG_LEVEL
93
+#if DEBUG_LEVEL > 1
94 94
 		sprintf(ligne, " got $%X\n", received); 
95 95
 		waddstr(glass, ligne); wrefresh(glass);
96 96
 #endif

Loading…
Cancel
Save