FreeCalypso > hg > freecalypso-sw
annotate rvinterf/old/g23sh/sendsp.c @ 972:6de5661d1fe1
gsm-fw/services/etm/etm_api.c: same fix in etm_pkt_send() as in tcs211-c139
author | Mychaela Falconia <falcon@ivan.Harhan.ORG> |
---|---|
date | Fri, 13 Nov 2015 19:29:16 +0000 |
parents | 373af5f74e39 |
children |
rev | line source |
---|---|
328
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
1 /* |
336
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
2 * g23sh system primitive sending command |
328
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
3 */ |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
4 |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
5 #include <sys/types.h> |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
6 #include <stdio.h> |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
7 #include <string.h> |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
8 #include <strings.h> |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
9 #include <stdlib.h> |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
10 #include "pktmux.h" |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
11 #include "limits.h" |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
12 |
336
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
13 void |
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
14 cmd_sendsp(argc, argv) |
328
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
15 char **argv; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
16 { |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
17 char *stackdest, *primarg; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
18 unsigned intlen; |
336
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
19 u_char sendpkt[MAX_PKT_TO_TARGET+1]; |
328
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
20 unsigned pktlen; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
21 |
336
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
22 stackdest = argv[1]; |
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
23 primarg = argv[2]; |
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
24 if (strlen(stackdest) > 4) { |
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
25 printf( |
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
26 "error: stack destination arg may not exceed 4 characters\n"); |
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
27 return; |
328
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
28 } |
336
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
29 intlen = 12 + strlen(primarg); |
328
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
30 pktlen = intlen + 4; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
31 if (pktlen > MAX_PKT_TO_TARGET) { |
336
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
32 printf("error: max pkt to target limit exceeded\n"); |
922efdd65dce
g23sh written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
328
diff
changeset
|
33 return; |
328
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
34 } |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
35 /* fill out the packet */ |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
36 sendpkt[0] = RVT_L23_HEADER; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
37 sendpkt[1] = 0xB7; /* system prim */ |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
38 sendpkt[2] = intlen; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
39 sendpkt[3] = intlen >> 8; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
40 /* send zeros for the timestamp */ |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
41 sendpkt[4] = 0; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
42 sendpkt[5] = 0; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
43 sendpkt[6] = 0; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
44 sendpkt[7] = 0; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
45 /* as far as TI's sw is concerned, we are PCO */ |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
46 sendpkt[8] = 'P'; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
47 sendpkt[9] = 'C'; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
48 sendpkt[10] = 'O'; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
49 sendpkt[11] = ' '; |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
50 sprintf(sendpkt + 12, "%-4s%s", stackdest, primarg); |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
51 /* send it! */ |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
52 send_pkt_to_target(sendpkt, pktlen); |
5d9001f0c3aa
fc-sendsp: written, compiles
Michael Spacefalcon <msokolov@ivan.Harhan.ORG>
parents:
diff
changeset
|
53 } |