23 #define isatty _isatty
26 static int hex2nib(
char hex);
42 struct termios new, old;
45 new.c_lflag &= ~ICANON;
46 new.c_lf lag &= ~ECHO;
47 tcsetattr(0, TCSANOW, &
new);
49 if (isatty(STDIN_FILENO) || 1)
52 while (fgets(hexbuf,
sizeof hexbuf, stdin))
55 const char *hp;
u8 *bp;
57 for (hp = hexbuf, bp = binbuf+1; *hp !=
'\0'; hp++)
59 if ((tmp = hex2nib(*hp)) == -1)
continue;
60 if (tmp == 0 && *hp !=
'0')
68 u8 byte = 0;
int nibble = 0;
69 for (hp = hexbuf, bp = binbuf+1; *hp !=
'\0'; hp++)
71 if ((tmp = hex2nib(*hp)) == -1)
continue;
84 int len = bp - binbuf+1;
86 memcpy(binbuf+1, (
u16[]){len - 2}, 2);
87 printf(
"prefix_len=%d, len=%i\n", prefix_len, len);
96 printf(
"%zu\n", fread(binbuf+1, 1, 2, stdin));
97 size_t len = (binbuf[1] | (binbuf[2] << 4));
98 printf(
"len%zu\n", len);
99 fread(binbuf+3, 1, len, stdin);
107 static int hex2nib(
char hex)
109 if (
'a' <= hex && hex <=
'f')
110 return hex -
'a' + 0x0a;
111 else if (
'A' <= hex && hex <=
'F')
112 return hex -
'A' + 0x0a;
113 else if (
'0' <= hex && hex <=
'9')
115 else if (isspace(hex) || !isgraph(hex))
int tunnel()
tunnels from stdio to ev3
Error enumerations and decriptions.
#define print_bytes(buf, len)
packed structs for the packets.
contains declarations for ev3 commands
EXTERN int(* ev3_write)(void *, const u8 *, size_t)