comparison rvinterf/asyncshell/sendsp.c @ 875:dab341e172de

fc-shell: sysprim sending (sp command) implemented
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sat, 30 May 2015 07:41:23 +0000
parents
children bd873572ef2c
comparison
equal deleted inserted replaced
874:72d64c172d85 875:dab341e172de
1 /*
2 * Functions for sending GPF system primitives to the target
3 */
4
5 #include <sys/types.h>
6 #include <stdio.h>
7 #include <ctype.h>
8 #include <string.h>
9 #include <strings.h>
10 #include <stdlib.h>
11 #include "pktmux.h"
12 #include "limits.h"
13
14 send_gpf_sysprim(stackdest, primstr)
15 char *stackdest, *primstr;
16 {
17 unsigned intlen;
18 u_char sendpkt[MAX_PKT_TO_TARGET+1];
19 unsigned pktlen;
20
21 if (strlen(stackdest) > 4) {
22 printf(
23 "error: stack destination arg may not exceed 4 characters\n");
24 return(1);
25 }
26 intlen = 12 + strlen(primstr);
27 pktlen = intlen + 4;
28 if (pktlen > MAX_PKT_TO_TARGET) {
29 printf("error: max pkt to target limit exceeded\n");
30 return(1);
31 }
32 /* fill out the packet */
33 sendpkt[0] = RVT_L23_HEADER;
34 sendpkt[1] = 0xB7; /* system prim */
35 sendpkt[2] = intlen;
36 sendpkt[3] = intlen >> 8;
37 /* send zeros for the timestamp */
38 sendpkt[4] = 0;
39 sendpkt[5] = 0;
40 sendpkt[6] = 0;
41 sendpkt[7] = 0;
42 /* as far as TI's sw is concerned, we are PCO */
43 sendpkt[8] = 'P';
44 sendpkt[9] = 'C';
45 sendpkt[10] = 'O';
46 sendpkt[11] = ' ';
47 sprintf(sendpkt + 12, "%-4s%s", stackdest, primstr);
48 /* send it! */
49 send_pkt_to_target(sendpkt, pktlen);
50 return(0);
51 }
52
53 void
54 cmd_sendsp(args)
55 char *args;
56 {
57 char *cp, *np;
58
59 for (cp = args; isspace(*cp); cp++)
60 ;
61 if (!*cp) {
62 err: printf("error: two arguments required\n");
63 return;
64 }
65 for (np = cp; *cp && !isspace(*cp); cp++)
66 ;
67 if (!*cp)
68 goto err;
69 *cp++ = '\0';
70 while (isspace(*cp))
71 cp++;
72 if (!*cp)
73 goto err;
74 gpf_rx_control(1);
75 send_gpf_sysprim(np, cp);
76 }