serial : a small test main()
This commit is contained in:
12
serial/t.c
12
serial/t.c
@@ -7,14 +7,20 @@
|
||||
int main (int argc, char *argv[])
|
||||
{
|
||||
int serial_in;
|
||||
int byte, foo;
|
||||
int byte, foo, to;
|
||||
|
||||
serial_in = prepare_UART("/dev/ttyS0", 9600);
|
||||
fprintf(stderr, "prepare uart -> %d\n", serial_in);
|
||||
|
||||
for (foo=0; foo<20; foo++) {
|
||||
byte = getbyte(serial_in);
|
||||
printf("%6d %02x\n", foo, byte);
|
||||
to = (foo+1) * 666;
|
||||
byte = getbyte_to(serial_in, to);
|
||||
if (byte < 0) {
|
||||
fprintf(stderr, "get byte : err is %d\n", byte);
|
||||
}
|
||||
else {
|
||||
printf("%6d %6d %02x\n", foo, to, byte);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user