FreeCalypso > hg > freecalypso-tools
annotate rvinterf/etmsync/l1tmops.c @ 270:095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 16 Nov 2017 19:00:05 +0000 |
parents | |
children | dc9dbb2f74e7 |
rev | line source |
---|---|
270
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
1 /* |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
2 * In this module we implement the functions that access the L1TM operations |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
3 * which we are going to use in fc-tmsync and fc-readcal. |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
4 */ |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
5 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
6 #include <sys/types.h> |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
7 #include <stdio.h> |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
8 #include <stdlib.h> |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
9 #include <string.h> |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
10 #include <strings.h> |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
11 #include "pktmux.h" |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
12 #include "tm3.h" |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
13 #include "l1tm.h" |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
14 #include "exitcodes.h" |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
15 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
16 extern u_char rvi_msg[]; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
17 extern int rvi_msg_len; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
18 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
19 do_tms(arg) |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
20 { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
21 u_char cmdpkt[5]; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
22 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
23 cmdpkt[1] = TM_MODE_SET; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
24 cmdpkt[2] = arg; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
25 cmdpkt[3] = arg >> 8; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
26 etm_pkt_exch(cmdpkt, 3); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
27 if (rvi_msg[3]) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
28 fprintf(stderr, "target error %u in response to tms\n", |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
29 rvi_msg[3]); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
30 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
31 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
32 if (rvi_msg_len != 5) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
33 fprintf(stderr, "target error: tms response wrong length\n"); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
34 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
35 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
36 return(0); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
37 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
38 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
39 do_rfpw(index, value) |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
40 { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
41 u_char cmdpkt[7]; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
42 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
43 cmdpkt[1] = RF_PARAM_WRITE; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
44 cmdpkt[2] = index; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
45 cmdpkt[3] = index >> 8; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
46 cmdpkt[4] = value; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
47 cmdpkt[5] = value >> 8; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
48 etm_pkt_exch(cmdpkt, 5); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
49 if (rvi_msg[3]) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
50 fprintf(stderr, "target error %u in response to rfpw\n", |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
51 rvi_msg[3]); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
52 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
53 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
54 if (rvi_msg_len != 6) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
55 fprintf(stderr, "target error: rfpw response wrong length\n"); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
56 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
57 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
58 if (rvi_msg[4] != index) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
59 fprintf(stderr, "target error: rfpw response wrong index\n"); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
60 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
61 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
62 return(0); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
63 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
64 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
65 do_rftr(index, table, size) |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
66 u_char *table; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
67 { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
68 u_char cmdpkt[4]; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
69 |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
70 cmdpkt[1] = RF_TABLE_READ; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
71 cmdpkt[2] = index; |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
72 etm_pkt_exch(cmdpkt, 2); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
73 if (rvi_msg[3]) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
74 fprintf(stderr, "target error %u in response to rftr\n", |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
75 rvi_msg[3]); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
76 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
77 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
78 if (rvi_msg_len < size + 6) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
79 fprintf(stderr, "target error: rftr response too short\n"); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
80 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
81 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
82 if (rvi_msg[4] != index) { |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
83 fprintf(stderr, "target error: rftr response wrong index\n"); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
84 exit(ERROR_TARGET); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
85 } |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
86 bcopy(rvi_msg + 5, table, size); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
87 return(0); |
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
Mychaela Falconia <falcon@freecalypso.org>
parents:
diff
changeset
|
88 } |