integration du terminal dans le machin
This commit is contained in:
parent
7e17ba80e5
commit
e0dcbebd30
8
Makefile
8
Makefile
@ -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 $@
|
||||
|
36
core/utils.c
36
core/utils.c
@ -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;
|
||||
|
@ -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
12
essai.c
@ -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
31
ui/t.c
@ -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)
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user