FreeCalypso > hg > fc-sim-tools
comparison serial/main.c @ 43:be27d1c85861
serial: main function implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 20 Mar 2021 21:49:59 +0000 |
parents | 6cc3eea720cb |
children | fbedb67d234f |
comparison
equal
deleted
inserted
replaced
42:6cc3eea720cb | 43:be27d1c85861 |
---|---|
8 extern unsigned baud_base, baud_spenh; | 8 extern unsigned baud_base, baud_spenh; |
9 | 9 |
10 main(argc, argv) | 10 main(argc, argv) |
11 char **argv; | 11 char **argv; |
12 { | 12 { |
13 char inbuf[576]; | |
14 u_char cmd[260]; | |
13 int rc; | 15 int rc; |
14 | 16 |
15 if (argc != 3) { | 17 if (argc != 3) { |
16 fprintf(stderr, "usage: %s ttyport baud\n", argv[0]); | 18 fprintf(stderr, "usage: %s ttyport baud\n", argv[0]); |
17 exit(1); | 19 exit(1); |
25 if (rc < 0) | 27 if (rc < 0) |
26 exit(1); | 28 exit(1); |
27 print_atr("A"); | 29 print_atr("A"); |
28 if (baud_spenh) | 30 if (baud_spenh) |
29 spenh_logic(); | 31 spenh_logic(); |
32 putchar('\n'); | |
33 fflush(stdout); | |
30 | 34 |
31 /* remaining logic to be implemented */ | 35 for (; fgets(inbuf, sizeof inbuf, stdin); fflush(stdout)) { |
36 rc = parse_hex_input(inbuf, cmd); | |
37 if (rc < 0) | |
38 continue; | |
39 if (rc < 5) { | |
40 printf("error: command APDU is too short\n"); | |
41 continue; | |
42 } | |
43 apdu_exchange(cmd, rc); | |
44 } | |
45 | |
32 exit(0); | 46 exit(0); |
33 } | 47 } |