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

parce que je le vaux bien...
This commit is contained in:
Tonton Th 2019-05-20 18:55:02 +02:00
commit 3b1d756cad
6 changed files with 52 additions and 39 deletions

View File

@ -5,18 +5,18 @@
CC = gcc
CCOPT = -Wall -g
CLIB = core/libdd2m-core.a viz/libdd2m-viz.a
OBJS = essai.o terminal.o
all: essai
# -------------------------------------------------------
OSERIAL = serial/serial.o serial/funcs.o
OSERIAL = serial/serial.o serial/funcs.o ui/terminal.o
essai.o: essai.c Makefile
$(CC) ${CCOPT} $< -c
essai: ${OBJS} Makefile $(CLIB) ${OSERIAL}
$(CC) ${CCOPT} $< $(CLIB) ${OSERIAL} -lncurses -o $@
essai: essai.o Makefile $(CLIB) ${OSERIAL}
$(CC) ${CCOPT} $< ${OSERIAL} $(CLIB) -lncurses -o $@
fake-values: fake-values.c Makefile $(CLIB)
$(CC) ${CCOPT} $< $(CLIB) -o $@

View File

@ -6,13 +6,47 @@
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <sys/time.h>
#include "utils.h"
extern int verbosity;
/* --------------------------------------------------------------- */
/* maybe not a really goof initialisation... */
int special_dumper(FILE *fp, unsigned char octet)
{
static int idx = 0;
static unsigned char buffer[16];
int foo, c;
#if DEBUG_LEVEL > 1
fprintf(stderr, "%s $%x %c\n", __func__, octet, octet);
#endif
buffer[idx++] = octet;
if (idx==16) {
fprintf(fp, "dmp : ");
for (foo=0; foo<16; foo++) {
fprintf(fp, "%02x ", buffer[foo]);
if (7==foo) fprintf(fp, " ");
}
fprintf(fp, " - |");
for (foo=0; foo<16; foo++) {
c = buffer[foo];
fprintf(fp, "%c", isprint(c) ? c : ' ');
}
fprintf(fp, "|\n"); fflush(fp);
idx = 0;
}
return 0;
}
/* ---------------------------------------------------------------- */
/* maybe not a really good initialisation... */
int seed_my_rand(int foo)
{
long v1, v2;

View File

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

12
essai.c
View File

@ -15,8 +15,10 @@
#include "serial/serial.h"
#include "viz/curses/ecran.h"
int verbosity;
int run_the_terminal(int fd_serial, char *title, WINDOW *win); /* XXX */
int verbosity;
/* --------------------------------------------------------------- */
int traite_les_messages(int sfd, int nbloops)
@ -38,7 +40,7 @@ if (NULL==fp) {
for (idx=0; idx<nbloops; idx++) {
if (kbhit()) {
static char valid_k[] = "+-";
static char valid_k[] = "+-01";
key = getch();
/* if it is a valid key, send it to the Arduino */
@ -47,6 +49,12 @@ for (idx=0; idx<nbloops; idx++) {
fprintf(stderr, "put byte %02X -> %d\n",
key, foo);
}
else if (0x14==key) { /* request for terminal */
foo = run_the_terminal(sfd, " terminal ", 0);
sprintf(ligne, "retour terminal = %d", foo);
aff_message(ligne); sleep(1);
}
else {
sprintf(ligne, "Key 0x%02X invalid ", key);
fprintf(stderr, "%s\n", ligne);

31
ui/t.c
View File

@ -13,37 +13,6 @@
int verbosity;
/* ---------------------------------------------------------------- */
int special_dumper(FILE *fp, unsigned char octet)
{
static int idx = 0;
static unsigned char buffer[16];
int foo, c;
#if DEBUG_LEVEL > 1
fprintf(stderr, "%s $%x %c\n", __func__, octet, octet);
#endif
buffer[idx++] = octet;
if (idx==16) {
fprintf(fp, "dmp : ");
for (foo=0; foo<16; foo++) {
fprintf(fp, "%02x ", buffer[foo]);
if (7==foo) fprintf(fp, " ");
}
fprintf(fp, " - |");
for (foo=0; foo<16; foo++) {
c = buffer[foo];
fprintf(fp, "%c", isprint(c) ? c : ' ');
}
fprintf(fp, "|\n"); fflush(fp);
idx = 0;
}
return 0;
}
/* ---------------------------------------------------------------- */
void help(int k)

View File

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