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