FreeCalypso > hg > fc-rfcal-tools
view autocal/l1meas.c @ 124:9f09a7c3607a
fc-rfcal-txband: level error tolerance tightened to 0.75 dB
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 12 Jan 2019 20:15:17 +0000 |
parents | 1a0dbc746d57 |
children |
line wrap: on
line source
/* * In this module we are going to implement the functions for making * measurements on the DUT via L1TM. */ #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> #include "l1stats.h" extern u_char rvi_msg[]; extern int rvi_msg_len; do_scw(index, value) { u_char cmdpkt[7]; cmdpkt[1] = STATS_CONFIG_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 scw\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len != 6) { fprintf(stderr, "DUT error: scw response wrong length\n"); exit(ERROR_TARGET); } if (rvi_msg[4] != index) { fprintf(stderr, "DUT error: scw response wrong index\n"); exit(ERROR_TARGET); } return(0); } collect_auto_stats(sb) struct l1stats *sb; { unsigned type, bitmask, offset; int expect_len; collect_extra_pkt_from_target(); l1tm_resp_sanity_check(STATS_READ); if (rvi_msg[3]) { fprintf(stderr, "DUT error %u in auto-stats message\n", rvi_msg[3]); exit(ERROR_TARGET); } if (rvi_msg_len < 9) { fprintf(stderr, "DUT error: auto-stats msg too short\n"); exit(ERROR_TARGET); } type = rvi_msg[4] | (rvi_msg[5] << 8); bitmask = rvi_msg[6] | (rvi_msg[7] << 8); if (type < 1 || type > 2) { fprintf(stderr, "DUT error: invalid type in auto-stats msg\n"); exit(ERROR_TARGET); } if (bitmask & 0x0300) { fprintf(stderr, "DUT error: invalid bitmask in auto-stats msg\n"); exit(ERROR_TARGET); } expect_len = 9; if (bitmask & RSSI) expect_len += 2; if (bitmask & DSP_PM) expect_len += 2; if (bitmask & ANGLE_MEAN) expect_len += 4; if (bitmask & ANGLE_VAR) expect_len += 4; if (bitmask & ANGLE_MIN) expect_len += 4; if (bitmask & ANGLE_MAX) expect_len += 4; if (bitmask & SNR_MEAN) expect_len += 4; if (bitmask & SNR_VAR) expect_len += 4; if (bitmask & TOA_MEAN) expect_len += 4; if (bitmask & TOA_VAR) expect_len += 4; if (bitmask & FRAME_NUMBER) expect_len += 4; if (bitmask & RUNS) expect_len += 4; if (bitmask & SUCCESSES) expect_len += 4; if (bitmask & BSIC) expect_len += 2; if (rvi_msg_len != expect_len) { fprintf(stderr, "DUT error: auto-stats msg wrong length\n"); exit(ERROR_TARGET); } sb->type = type; sb->bitmask = bitmask; offset = 8; if (bitmask & RSSI) { sb->rssi = rvi_msg[offset] | (rvi_msg[offset+1] << 8); offset += 2; } if (bitmask & DSP_PM) { sb->dsp_pm = rvi_msg[offset] | (rvi_msg[offset+1] << 8); offset += 2; } if (bitmask & ANGLE_MEAN) { sb->angle_mean = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & ANGLE_VAR) { sb->angle_var = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & ANGLE_MIN) { sb->angle_min = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & ANGLE_MAX) { sb->angle_max = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & SNR_MEAN) { sb->snr_mean = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & SNR_VAR) { sb->snr_var = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & TOA_MEAN) { sb->toa_mean = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & TOA_VAR) { sb->toa_var = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & FRAME_NUMBER) { sb->frame_number = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & RUNS) { sb->runs = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & SUCCESSES) { sb->successes = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; } if (bitmask & BSIC) { sb->bsic = rvi_msg[offset] | (rvi_msg[offset+1] << 8); offset += 2; } return(0); } collect_rfe_completion() { collect_extra_pkt_from_target(); l1tm_resp_sanity_check(RF_ENABLE); if (rvi_msg[3] != 1) { fprintf(stderr, "DUT error %u in rfe completion message\n", rvi_msg[3]); exit(ERROR_TARGET); } return(0); }