diff --git a/serial/Makefile b/serial/Makefile index 8ceb6ee..c8fb1c1 100644 --- a/serial/Makefile +++ b/serial/Makefile @@ -1,3 +1,5 @@ +# --------------------------------------------------- +# May be we have to put those objs in a .a ? OPT = -Wall -DDEBUG_LEVEL=0 OBJS = serial.o funcs.o diff --git a/serial/serial.c b/serial/serial.c index 34c79f5..c4d52e3 100644 --- a/serial/serial.c +++ b/serial/serial.c @@ -122,13 +122,26 @@ byte = 0; foo = read(fd, &byte, 1); if (1 != foo) { - fprintf(stderr, "byte %d rd %d errno %d\n", - byte, foo, errno); + fprintf(stderr, "%s : byte %d rd %d errno %d\n", + __func__, byte, foo, errno); return -1; } return (int)byte; } +/* -------------------------------------------------------------------- */ +int putbyte(int fd, unsigned char byte) +{ +int foo = -1; +foo = write(fd, &byte, 1); +if (1 != foo) + { + fprintf(stderr, "%s : %d -> %d errno %d\n", + __func__, byte, foo, errno); + } + +return foo; +} /* -------------------------------------------------------------------- */ /* timeout is in milliseconds */ int getbyte_to (int fd, int to_ms) diff --git a/serial/serial.h b/serial/serial.h index 2e68924..ba934c7 100644 --- a/serial/serial.h +++ b/serial/serial.h @@ -6,8 +6,8 @@ int prepare_UART(char *port, int bauds); -int getbyte(int fd); /* really brotched func */ - +int getbyte(int fd); /* really brotched func */ +int putbyte(int fd, unsigned char byte); /* timeout is exprimed in milliseconds. */ int getbyte_to (int fd, int to_ms);