added the K parameter
This commit is contained in:
parent
946616e55a
commit
dcc394a088
6
essai.c
6
essai.c
@ -7,7 +7,7 @@
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <curses.h>
|
||||
#include <ncurses.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "core/utils.h"
|
||||
@ -17,6 +17,7 @@
|
||||
|
||||
int verbosity;
|
||||
|
||||
|
||||
/* --------------------------------------------------------------- */
|
||||
int traite_les_messages(int sfd, int nbloops)
|
||||
{
|
||||
@ -115,6 +116,7 @@ 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);
|
||||
}
|
||||
@ -125,12 +127,14 @@ int main(int argc, char *argv[])
|
||||
int opt;
|
||||
int serial_in;
|
||||
char *device = "/dev/ttyACM0";
|
||||
int K = 0;
|
||||
char ligne[100];
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hv")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd': device = optarg; break;
|
||||
case 'h': help(0); break;
|
||||
case 'K': K = atoi(optarg); break;
|
||||
case 'v': verbosity++; break;
|
||||
default: break;
|
||||
}
|
||||
|
24
serial/t.c
24
serial/t.c
@ -108,24 +108,30 @@ void help(int k)
|
||||
{
|
||||
puts("options : ");
|
||||
puts("\t-d\tserial device to read.");
|
||||
puts("\t-K\tset the K parameter.");
|
||||
puts("\t-n\tnumber of records to grab.");
|
||||
puts("\t-t\tselect the function");
|
||||
puts("\t-v\tincrease verbosity.");
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int serial_in;
|
||||
char *device = "/dev/ttyACM0";
|
||||
int nbre, speed, opt;
|
||||
char *device = "/dev/ttyS0";
|
||||
int nbre, speed, opt, K=0;
|
||||
int param, retv;
|
||||
|
||||
/* set some default values */
|
||||
verbosity = 0;
|
||||
nbre = 25;
|
||||
speed = 9600;
|
||||
param = 1;
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:n:vh")) != -1) {
|
||||
switch (opt) {
|
||||
case 'p': param = atoi(optarg); break;
|
||||
case 'v': verbosity++; break;
|
||||
case 'K': K = atoi(optarg); break;
|
||||
case 'n': nbre = atoi(optarg); break;
|
||||
case 'd': device = optarg; break;
|
||||
case 'h': help(0); exit(0);
|
||||
@ -151,7 +157,19 @@ if (serial_in < 0) {
|
||||
|
||||
fprintf(stderr, "going to listen on %d\n", serial_in);
|
||||
|
||||
(void)loop(serial_in, nbre);
|
||||
switch (param) {
|
||||
case 0:
|
||||
retv = loop(serial_in, nbre);
|
||||
break;
|
||||
case 1:
|
||||
retv = essai_terminal(serial_in, device, 0);
|
||||
break;
|
||||
default:
|
||||
retv = -1;
|
||||
break;
|
||||
}
|
||||
|
||||
fprintf(stderr, "Returned value is %d\n", retv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
65
ui/t.c
Normal file
65
ui/t.c
Normal file
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/* ---------------------------------------------------------------- */
|
||||
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;
|
||||
char ligne[100];
|
||||
|
||||
while ((opt = getopt(argc, argv, "d:hv")) != -1) {
|
||||
switch (opt) {
|
||||
case 'd': device = optarg; break;
|
||||
case 'h': help(0); break;
|
||||
case 'K': K = atoi(optarg); break;
|
||||
case 'v': verbosity++; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
printf("\n*** compiled %s %s ***\n", __DATE__, __TIME__);
|
||||
printf("*** device: %s\n", device);
|
||||
|
||||
sleep(1);
|
||||
|
||||
serial_in = prepare_UART(device, 9600);
|
||||
if (serial_in < 0) {
|
||||
fprintf(stderr, "\n%s : open device : error %d on %s\n",
|
||||
argv[0], serial_in, device);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
sleep(1);
|
||||
|
||||
foo = essai_terminal(serial_in, device, K);
|
||||
|
||||
return 0;
|
||||
}
|
||||
/* ---------------------------------------------------------------- */
|
||||
|
Loading…
Reference in New Issue
Block a user