FreeCalypso > hg > fc-sim-tools
annotate serial/baud_parse.c @ 99:97ba63d9361a
scripts/fcsim1-sst: turn off STK & OTA services
In the initial unprogrammed state of the cards from Grcard, SST has
services 25 through 29 set to allocated and activated. However,
these cards appear to not actually support OTA, ENVELOPE commands
do nothing (just return SW 9000), and they were never observed
issuing any proactive SIM commands, even after a feature-generous
TERMINAL PROFILE. Therefore, let's list these STK & OTA services
as allocated, but not activated in our FCSIM1 SST.
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Wed, 05 May 2021 04:26:07 +0000 |
parents | 8f505d413815 |
children |
rev | line source |
---|---|
40
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * This module handles the parsing of the baud rate and speed enhancement |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * command line argument. |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <ctype.h> |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 unsigned baud_base, baud_spenh, spenh_host_max; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 void |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 parse_baud_spenh_arg(arg) |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 char *arg; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 { |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 char *cp; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 if (!isdigit(*arg)) { |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 inv: fprintf(stderr, |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 "error: invalid baud/spenh selection argument \"%s\"\n", |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 arg); |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 exit(1); |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 } |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 baud_base = strtoul(arg, &cp, 10); |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 if (!*cp) |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 return; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (*cp++ != ',') |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 goto inv; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 if (!isdigit(*cp)) |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 goto inv; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 baud_spenh = strtoul(cp, &cp, 10); |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if (!*cp) { |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 spenh_host_max = 1; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 return; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 if (*cp++ != ',') |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 goto inv; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 if (!isdigit(*cp) || cp[1]) |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 goto inv; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 spenh_host_max = *cp - '0'; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 switch (spenh_host_max) { |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 case 1: |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 case 2: |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 case 4: |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 case 8: |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 break; |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 default: |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 fprintf(stderr, |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 "error: speed enhancement multiplier can only be 1, 2, 4 or 8\n"); |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 exit(1); |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 } |
8f505d413815
serial: full baud/spenh argument parsing implemented
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 } |