FreeCalypso > hg > freecalypso-sw
annotate rvinterf/asyncshell/sendsp.c @ 1022:24440bc7cee8
gsm-fw/configs: gtamodem-gsmtch-{ext,int} configurations added
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Tue, 03 May 2016 13:43:31 +0000 |
parents | bd873572ef2c |
children |
rev | line source |
---|---|
875
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
2 * Functions for sending GPF system primitives to the target |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <ctype.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <string.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <strings.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include <stdlib.h> |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "pktmux.h" |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 #include "limits.h" |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
13 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
14 send_gpf_sysprim(stackdest, primstr) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 char *stackdest, *primstr; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 unsigned intlen; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 u_char sendpkt[MAX_PKT_TO_TARGET+1]; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
19 unsigned pktlen; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 if (strlen(stackdest) > 4) { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
22 printf( |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
23 "error: stack destination arg may not exceed 4 characters\n"); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
24 return(1); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
25 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
26 intlen = 12 + strlen(primstr); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
27 pktlen = intlen + 4; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 if (pktlen > MAX_PKT_TO_TARGET) { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
29 printf("error: max pkt to target limit exceeded\n"); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 return(1); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
32 /* fill out the packet */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
33 sendpkt[0] = RVT_L23_HEADER; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 sendpkt[1] = 0xB7; /* system prim */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 sendpkt[2] = intlen; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 sendpkt[3] = intlen >> 8; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 /* send zeros for the timestamp */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 sendpkt[4] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 sendpkt[5] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 sendpkt[6] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 sendpkt[7] = 0; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 /* as far as TI's sw is concerned, we are PCO */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 sendpkt[8] = 'P'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 sendpkt[9] = 'C'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 sendpkt[10] = 'O'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 sendpkt[11] = ' '; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 sprintf(sendpkt + 12, "%-4s%s", stackdest, primstr); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 /* send it! */ |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 send_pkt_to_target(sendpkt, pktlen); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 return(0); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 void |
965
bd873572ef2c
fc-shell: one-shot command mode implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
875
diff
changeset
|
54 cmd_sp_interactive(args) |
875
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
55 char *args; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
56 { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
57 char *cp, *np; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
58 |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
59 for (cp = args; isspace(*cp); cp++) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
60 ; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
61 if (!*cp) { |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
62 err: printf("error: two arguments required\n"); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
63 return; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
64 } |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
65 for (np = cp; *cp && !isspace(*cp); cp++) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
66 ; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
67 if (!*cp) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
68 goto err; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
69 *cp++ = '\0'; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
70 while (isspace(*cp)) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
71 cp++; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
72 if (!*cp) |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
73 goto err; |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
74 gpf_rx_control(1); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
75 send_gpf_sysprim(np, cp); |
dab341e172de
fc-shell: sysprim sending (sp command) implemented
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff
changeset
|
76 } |
965
bd873572ef2c
fc-shell: one-shot command mode implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
875
diff
changeset
|
77 |
bd873572ef2c
fc-shell: one-shot command mode implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
875
diff
changeset
|
78 cmd_sp_oneshot(argc, argv) |
bd873572ef2c
fc-shell: one-shot command mode implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
875
diff
changeset
|
79 char **argv; |
bd873572ef2c
fc-shell: one-shot command mode implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
875
diff
changeset
|
80 { |
bd873572ef2c
fc-shell: one-shot command mode implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
875
diff
changeset
|
81 return send_gpf_sysprim(argv[1], argv[2]); |
bd873572ef2c
fc-shell: one-shot command mode implemented
Mychaela Falconia <falcon@ivan.Harhan.ORG>
parents:
875
diff
changeset
|
82 } |