FreeCalypso > hg > fc-rfcal-tools
view autocal/l1tmops.c @ 24:0b6881281d86
fc-rfcal-vcxo ready for first test
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Mon, 22 May 2017 22:00:36 +0000 |
parents | 7ac866c3baf6 |
children | d6ef94518117 |
line wrap: on
line source
/* * In this module we are going to implement the functions for executing * various L1TM operations on the DUT. */ #include <sys/types.h> #include <stdio.h> #include <stdlib.h> #include <rvinterf/pktmux.h> #include <rvinterf/tm3.h> #include <rvinterf/l1tm.h> #include <rvinterf/exitcodes.h> extern u_char rvi_msg[]; extern int rvi_msg_len; l1tm_pkt_exch(outbuf, outlen) u_char *outbuf; { int i, c; outbuf[0] = RVT_TM_HEADER; c = 0; for (i = 1; i <= outlen; i++) c ^= outbuf[i]; outbuf[i] = c; target_pkt_exch(outbuf, outlen + 2); if (rvi_msg[1] != RVT_TM_HEADER) { fprintf(stderr, "DUT error: response packet is not on TM channel\n"); exit(ERROR_TARGET); } if (rvi_msg_len < 5) { fprintf(stderr, "DUT error: TM response packet is too short\n"); exit(ERROR_TARGET); } c = 0; for (i = 2; i < rvi_msg_len; i++) c ^= rvi_msg[i]; if (c) { fprintf(stderr, "DUT error: TM response bad checksum\n"); exit(ERROR_TARGET); } if (rvi_msg[2] != outbuf[1]) { fprintf(stderr, "DUT error: TM response has wrong CID\n"); exit(ERROR_TARGET); } return(0); } do_tms(arg) { u_char cmdpkt[5]; cmdpkt[1] = TM_MODE_SET; cmdpkt[2] = arg; cmdpkt[3] = arg >> 8; l1tm_pkt_exch(cmdpkt, 3); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in response to tms\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len != 5) { fprintf(stderr, "DUT error: tms response wrong length\n"); exit(ERROR_TARGET); } return(0); } do_rfe(arg) { u_char cmdpkt[5]; cmdpkt[1] = RF_ENABLE; cmdpkt[2] = arg; cmdpkt[3] = arg >> 8; l1tm_pkt_exch(cmdpkt, 3); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in response to rfe\n", rvi_msg[3]); exit(ERROR_TARGET); } return(0); } do_rfpw(index, value) { u_char cmdpkt[7]; cmdpkt[1] = RF_PARAM_WRITE; cmdpkt[2] = index; cmdpkt[3] = index >> 8; cmdpkt[4] = value; cmdpkt[5] = value >> 8; l1tm_pkt_exch(cmdpkt, 5); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in response to rfpw\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len != 6) { fprintf(stderr, "DUT error: rfpw response wrong length\n"); exit(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "DUT error: rfpw response wrong index\n"); exit(ERROR_TARGET); } return(0); } do_rxpw(index, value) { u_char cmdpkt[7]; cmdpkt[1] = RX_PARAM_WRITE; cmdpkt[2] = index; cmdpkt[3] = index >> 8; cmdpkt[4] = value; cmdpkt[5] = value >> 8; l1tm_pkt_exch(cmdpkt, 5); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in response to rxpw\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len != 6) { fprintf(stderr, "DUT error: rxpw response wrong length\n"); exit(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "DUT error: rxpw response wrong index\n"); exit(ERROR_TARGET); } return(0); } do_txpw(index, value) { u_char cmdpkt[7]; cmdpkt[1] = TX_PARAM_WRITE; cmdpkt[2] = index; cmdpkt[3] = index >> 8; cmdpkt[4] = value; cmdpkt[5] = value >> 8; l1tm_pkt_exch(cmdpkt, 5); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in response to txpw\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len != 6) { fprintf(stderr, "DUT error: txpw response wrong length\n"); exit(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "DUT error: txpw response wrong index\n"); exit(ERROR_TARGET); } return(0); }