FreeCalypso > hg > fc-rfcal-tools
view autocal/l1tmops.c @ 113:01bae2629ffd
doc/Test-system-interface: txpwr-cal-channel addition documented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 13 Feb 2018 04:39:33 +0000 |
parents | 81e8f7e99d89 |
children |
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 <string.h> #include <strings.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); l1tm_resp_sanity_check(outbuf[1]); return(0); } l1tm_resp_sanity_check(cid) { int i, c; 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] != cid) { 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); } do_rftw(index, table, size) u_char *table; { u_char cmdpkt[MAX_RF_TABLE_SIZE + 4]; cmdpkt[1] = RF_TABLE_WRITE; cmdpkt[2] = index; bcopy(table, cmdpkt + 3, size); l1tm_pkt_exch(cmdpkt, size + 2); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in response to rftw\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len != 6) { fprintf(stderr, "DUT error: rftw response wrong length\n"); exit(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "DUT error: rftw response wrong index\n"); exit(ERROR_TARGET); } return(0); } do_rftr(index, table, size) u_char *table; { u_char cmdpkt[4]; cmdpkt[1] = RF_TABLE_READ; cmdpkt[2] = index; l1tm_pkt_exch(cmdpkt, 2); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in response to rftr\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len < size + 6) { fprintf(stderr, "DUT error: rftr response too short\n"); exit(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "DUT error: rftr response wrong index\n"); exit(ERROR_TARGET); } bcopy(rvi_msg + 5, table, size); return(0); } misc_enable(arg) { u_char cmdpkt[5]; cmdpkt[1] = MISC_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 me\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len != 6) { fprintf(stderr, "DUT error: me response wrong length\n"); exit(ERROR_TARGET); } if (rvi_msg[4] != arg) { fprintf(stderr, "DUT error: me response wrong index\n"); exit(ERROR_TARGET); } return(0); }