Mercurial > avr_jtag
annotate src/cmd_proto.c @ 2:abf221bf3ce4
AVR JTAG server.
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Sat, 21 Feb 2009 23:06:50 +0800 |
parents | f7c60e525801 |
children | e410832c3280 |
rev | line source |
---|---|
1
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
1 #include <stdio.h> |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
2 #include <stdlib.h> |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
3 #include <string.h> |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
4 #include "cmd_proto.h" |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
5 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
6 enum { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
7 ST_WAIT_MAGIC0, |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
8 ST_WAIT_MAGIC1, |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
9 ST_WAIT_SEQ, |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
10 ST_WAIT_LEN, |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
11 ST_WAIT_DATA, |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
12 ST_WAIT_CSUM |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
13 }; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
14 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
15 cmd_proto_t *cmd_proto_new(void) { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
16 cmd_proto_t *cp; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
17 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
18 cp = (cmd_proto_t *)malloc(sizeof(cmd_proto_t) + 512); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
19 if(cp == NULL) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
20 return NULL; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
21 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
22 memset(cp, 0, sizeof(cmd_proto_t)); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
23 cp->bufs[0] = ((char *)cp) + sizeof(cmd_proto_t); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
24 cp->bufs[1] = ((char *)cp) + sizeof(cmd_proto_t) + 256; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
25 cp->cmds[0].data = cp->bufs[0] + 1; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
26 cp->cmds[1].data = cp->bufs[1] + 1; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
27 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
28 return cp; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
29 } |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
30 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
31 void cmd_proto_free(cmd_proto_t *cp) { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
32 free(cp); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
33 } |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
34 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
35 cp_cmd_t BAD_CMD; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
36 cp_cmd_t CSUM_ERR_CMD; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
37 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
38 static |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
39 cp_cmd_t *make_cmd(cmd_proto_t *cp) { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
40 char *buf = cp->bufs[cp->receiving]; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
41 cp_cmd_t *cmd; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
42 int i; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
43 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
44 if(buf[0] <= 0 || buf[0] >= CPCMD_MAX) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
45 return &BAD_CMD; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
46 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
47 cmd = cp->cmds + cp->receiving; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
48 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
49 cmd->seq = cp->seq; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
50 cmd->code = buf[0]; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
51 cmd->data_sz = cp->len - 1; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
52 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
53 cp->receiving ^= 1; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
54 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
55 return cmd; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
56 } |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
57 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
58 #define CSUM_ADD(csum, c) \ |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
59 do { \ |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
60 csum = ((((csum) << 3) | ((csum) >> 5)) ^ (c)) & 0xff; \ |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
61 } while(0) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
62 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
63 cp_cmd_t *cmd_proto_rcv(cmd_proto_t *cp, int c) { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
64 int i, csum; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
65 char *buf; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
66 cp_cmd_t *cmd = NULL; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
67 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
68 switch(cp->status) { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
69 case ST_WAIT_MAGIC0: |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
70 if(c == CP_MAGIC[0]) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
71 cp->status = ST_WAIT_MAGIC1; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
72 break; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
73 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
74 case ST_WAIT_MAGIC1: |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
75 if(c == CP_MAGIC[1]) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
76 cp->status = ST_WAIT_SEQ; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
77 else if(c != CP_MAGIC[0]) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
78 cp->status = ST_WAIT_MAGIC0; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
79 break; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
80 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
81 case ST_WAIT_SEQ: |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
82 cp->seq = c; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
83 cp->status = ST_WAIT_LEN; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
84 break; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
85 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
86 case ST_WAIT_LEN: |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
87 cp->len = c; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
88 if(c > 0) { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
89 cp->status = ST_WAIT_DATA; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
90 cp->cnt = 0; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
91 } else |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
92 cp->status = ST_WAIT_CSUM; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
93 break; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
94 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
95 case ST_WAIT_DATA: |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
96 cp->bufs[cp->receiving][cp->cnt++] = c; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
97 if(cp->cnt >= cp->len) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
98 cp->status = ST_WAIT_CSUM; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
99 break; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
100 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
101 case ST_WAIT_CSUM: |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
102 csum = 0; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
103 buf = cp->bufs[cp->receiving]; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
104 for(i = 0; i < cp->len; i++) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
105 CSUM_ADD(csum, buf[i]); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
106 CSUM_ADD(csum, c); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
107 cp->status = ST_WAIT_MAGIC0; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
108 if(csum == 0) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
109 cmd = make_cmd(cp); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
110 else |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
111 cmd = &CSUM_ERR_CMD; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
112 break; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
113 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
114 default: |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
115 cp->status = ST_WAIT_MAGIC0; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
116 } |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
117 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
118 return cmd; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
119 } |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
120 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
121 int cmd_proto_cmd_fill(char *buf, int seq, cp_ccode_t code, int data_sz) { |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
122 int i, last = data_sz + CP_CMD_HEAD_SZ; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
123 int csum = 0; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
124 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
125 buf[0] = CP_MAGIC[0]; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
126 buf[1] = CP_MAGIC[1]; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
127 buf[2] = seq; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
128 buf[3] = data_sz + 1; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
129 buf[4] = code; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
130 for(i = CP_CMD_HEAD_SZ - 1; i < last; i++) |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
131 CSUM_ADD(csum, buf[i]); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
132 CSUM_ADD(csum, 0); |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
133 buf[i] = csum; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
134 |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
135 return data_sz + CP_CMD_OVERHEAD; |
f7c60e525801
cptest and cp_ping.py to test cmd_proto.c.
Thinker K.F. Li <thinker@branda.to>
parents:
diff
changeset
|
136 } |