FreeCalypso > hg > freecalypso-tools
annotate rvinterf/etmsync/l1tmops.c @ 673:f67e5ad30324
fc-loadtool: flash e-program-bin implemented
| author | Mychaela Falconia <falcon@freecalypso.org> | 
|---|---|
| date | Sun, 08 Mar 2020 04:16:31 +0000 | 
| parents | 4469d73bbc60 | 
| children | 4694c7686ccd | 
| 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]); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 30 return(ERROR_TARGET); | 
| 270 
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"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 34 return(ERROR_TARGET); | 
| 270 
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 | 
| 271 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 39 do_rfpr(index, retp) | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 40 u_short *retp; | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 41 { | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 42 u_char cmdpkt[5]; | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 43 | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 44 cmdpkt[1] = RF_PARAM_READ; | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 45 cmdpkt[2] = index; | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 46 cmdpkt[3] = index >> 8; | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 47 etm_pkt_exch(cmdpkt, 3); | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 48 if (rvi_msg[3]) { | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 49 fprintf(stderr, "target error %u in response to rfpr\n", | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 50 rvi_msg[3]); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 51 return(ERROR_TARGET); | 
| 271 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 52 } | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 53 if (rvi_msg_len != 8) { | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 54 fprintf(stderr, "target error: rfpr response wrong length\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 55 return(ERROR_TARGET); | 
| 271 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 56 } | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 57 if (rvi_msg[4] != index) { | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 58 fprintf(stderr, "target error: rfpr response wrong index\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 59 return(ERROR_TARGET); | 
| 271 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 60 } | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 61 *retp = rvi_msg[5] | (rvi_msg[6] << 8); | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 62 return(0); | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 63 } | 
| 
dc9dbb2f74e7
etmsync l1tmops module: rfpr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
270diff
changeset | 64 | 
| 270 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 65 do_rfpw(index, value) | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 66 { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 67 u_char cmdpkt[7]; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 68 | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 69 cmdpkt[1] = RF_PARAM_WRITE; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 70 cmdpkt[2] = index; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 71 cmdpkt[3] = index >> 8; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 72 cmdpkt[4] = value; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 73 cmdpkt[5] = value >> 8; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 74 etm_pkt_exch(cmdpkt, 5); | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 75 if (rvi_msg[3]) { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 76 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 | 77 rvi_msg[3]); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 78 return(ERROR_TARGET); | 
| 270 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 79 } | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 80 if (rvi_msg_len != 6) { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 81 fprintf(stderr, "target error: rfpw response wrong length\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 82 return(ERROR_TARGET); | 
| 270 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 83 } | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 84 if (rvi_msg[4] != index) { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 85 fprintf(stderr, "target error: rfpw response wrong index\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 86 return(ERROR_TARGET); | 
| 270 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 87 } | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 88 return(0); | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 89 } | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 90 | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 91 do_rftr(index, table, size) | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 92 u_char *table; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 93 { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 94 u_char cmdpkt[4]; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 95 | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 96 cmdpkt[1] = RF_TABLE_READ; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 97 cmdpkt[2] = index; | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 98 etm_pkt_exch(cmdpkt, 2); | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 99 if (rvi_msg[3]) { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 100 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 | 101 rvi_msg[3]); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 102 return(ERROR_TARGET); | 
| 270 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 103 } | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 104 if (rvi_msg_len < size + 6) { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 105 fprintf(stderr, "target error: rftr response too short\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 106 return(ERROR_TARGET); | 
| 270 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 107 } | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 108 if (rvi_msg[4] != index) { | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 109 fprintf(stderr, "target error: rftr response wrong index\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 110 return(ERROR_TARGET); | 
| 270 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 111 } | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 112 bcopy(rvi_msg + 5, table, size); | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 113 return(0); | 
| 
095ffce023d4
etmsync: l1tmops module compiles and links into fc-tmsync
 Mychaela Falconia <falcon@freecalypso.org> parents: diff
changeset | 114 } | 
| 272 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 115 | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 116 do_ttr(index, buf) | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 117 u_char *buf; | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 118 { | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 119 u_char cmdpkt[4]; | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 120 | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 121 cmdpkt[1] = TX_TEMPLATE_READ; | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 122 cmdpkt[2] = index; | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 123 etm_pkt_exch(cmdpkt, 2); | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 124 if (rvi_msg[3]) { | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 125 fprintf(stderr, "target error %u in response to ttr\n", | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 126 rvi_msg[3]); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 127 return(ERROR_TARGET); | 
| 272 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 128 } | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 129 if (rvi_msg_len != 38) { | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 130 fprintf(stderr, "target error: ttr response wrong length\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 131 return(ERROR_TARGET); | 
| 272 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 132 } | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 133 if (rvi_msg[4] != index) { | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 134 fprintf(stderr, "target error: ttr response wrong index\n"); | 
| 277 
4469d73bbc60
etmsync l1tmops module: need to return on errors, not exit
 Mychaela Falconia <falcon@freecalypso.org> parents: 
272diff
changeset | 135 return(ERROR_TARGET); | 
| 272 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 136 } | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 137 bcopy(rvi_msg + 5, buf, 32); | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 138 return(0); | 
| 
3e272b956ef4
etmsync l1tmops module: ttr implemented
 Mychaela Falconia <falcon@freecalypso.org> parents: 
271diff
changeset | 139 } | 
