annotate rvinterf/asyncshell/poweroff.c @ 889:1b1683cda154

fc-shell: implemented poweroff and tgtreset commands
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sun, 28 Jun 2015 16:52:06 +0000
parents
children bd873572ef2c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
889
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
1 /*
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
2 * fc-shell poweroff and tgtreset commands
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
3 */
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
4
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
5 #include <sys/types.h>
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
6 #include <stdio.h>
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
7 #include <stdlib.h>
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
8 #include "pktmux.h"
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
9 #include "etm.h"
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
10
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
11 void
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
12 send_etm_cmd(buf, len)
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
13 u_char *buf;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
14 {
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
15 int i, c;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
16
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
17 buf[0] = RVT_TM_HEADER;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
18 c = 0;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
19 for (i = 1; i <= len; i++)
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
20 c ^= buf[i];
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
21 buf[i] = c;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
22 send_pkt_to_target(buf, len + 2);
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
23 }
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
24
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
25 void
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
26 cmd_poweroff()
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
27 {
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
28 u_char cmdpkt[7];
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
29
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
30 cmdpkt[1] = ETM_CORE;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
31 cmdpkt[2] = TMCORE_OPC_CODEC_WR;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
32 cmdpkt[3] = 30; /* VRPCDEV */
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
33 cmdpkt[4] = 0x01; /* low 8 bits */
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
34 cmdpkt[5] = 0; /* high 2 bits */
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
35 send_etm_cmd(cmdpkt, 5);
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
36 }
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
37
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
38 void
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
39 cmd_tgtreset()
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
40 {
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
41 u_char cmdpkt[4];
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
42
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
43 cmdpkt[1] = ETM_CORE;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
44 cmdpkt[2] = TMCORE_OPC_RESET;
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
45 send_etm_cmd(cmdpkt, 2);
1b1683cda154 fc-shell: implemented poweroff and tgtreset commands
Space Falcon <falcon@ivan.Harhan.ORG>
parents:
diff changeset
46 }