FreeCalypso > hg > fc-rfcal-tools
changeset 48:201f27bd8dca
autocal/l1meas.c: implemented reading of auto-stats
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sat, 27 May 2017 07:03:08 +0000 |
parents | e86779d5445c |
children | 1a0dbc746d57 |
files | autocal/l1meas.c |
diffstat | 1 files changed, 135 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/autocal/l1meas.c Sat May 27 06:46:17 2017 +0000 +++ b/autocal/l1meas.c Sat May 27 07:03:08 2017 +0000 @@ -10,6 +10,7 @@ #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; @@ -39,3 +40,137 @@ } 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); +}