2019-05-16 21:28:47 +11:00
|
|
|
/*
|
|
|
|
* essais de gadgets UI
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include <ncurses.h>
|
|
|
|
|
|
|
|
#include "../serial/serial.h"
|
|
|
|
#include "terminal.h"
|
|
|
|
|
|
|
|
int verbosity;
|
|
|
|
|
2019-05-20 23:49:31 +11:00
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|
2019-05-16 21:28:47 +11:00
|
|
|
void help(int k)
|
|
|
|
{
|
|
|
|
puts("options : ");
|
|
|
|
puts("\t-d\tserial device to read.");
|
|
|
|
puts("\t-K\tset the K parameter.");
|
|
|
|
puts("\t-v\tincrease verbosity.");
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
int main(int argc, char *argv[])
|
|
|
|
{
|
|
|
|
int opt, foo;
|
|
|
|
int serial_in;
|
|
|
|
char *device = "/dev/ttyS0";
|
|
|
|
int K = 0;
|
2019-05-20 23:49:31 +11:00
|
|
|
// char ligne[100];
|
2019-05-16 21:28:47 +11:00
|
|
|
|
2019-05-22 20:30:56 +11:00
|
|
|
while ((opt = getopt(argc, argv, "d:hKv")) != -1) {
|
2019-05-16 21:28:47 +11:00
|
|
|
switch (opt) {
|
|
|
|
case 'd': device = optarg; break;
|
|
|
|
case 'h': help(0); break;
|
|
|
|
case 'K': K = atoi(optarg); break;
|
|
|
|
case 'v': verbosity++; break;
|
|
|
|
default: break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-20 23:49:31 +11:00
|
|
|
printf("\n*** compiled %s %s\n", __DATE__, __TIME__);
|
2019-05-16 21:28:47 +11:00
|
|
|
printf("*** device: %s\n", device);
|
|
|
|
|
|
|
|
serial_in = prepare_UART(device, 9600);
|
|
|
|
if (serial_in < 0) {
|
2019-05-20 23:49:31 +11:00
|
|
|
fprintf(stderr, "err open %s : %d\n", device, serial_in);
|
2019-05-16 21:28:47 +11:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
sleep(1);
|
|
|
|
|
|
|
|
foo = essai_terminal(serial_in, device, K);
|
2019-05-19 02:58:44 +11:00
|
|
|
fprintf(stderr, "essai terminal -> %d\n", foo);
|
2019-05-16 21:28:47 +11:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* ---------------------------------------------------------------- */
|
|
|
|
|