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