FreeCalypso > hg > freecalypso-tools
view rvinterf/tmsh/l1resp.c @ 185:3eb53be9e667
fc-vcxo-param: use M_PI constant instead of acos(-1.0)
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 13 Apr 2017 05:13:45 +0000 |
parents | f5a797c291be |
children |
line wrap: on
line source
/* * Handling of TM3 responses from L1TM */ #include <sys/types.h> #include <stdio.h> #include <string.h> #include <strings.h> #include "l1tm.h" extern u_char rvi_msg[]; extern int rvi_msg_len; unsigned rftr_table_index, rftr_table_size; u_char rftr_table_data[MAX_RF_TABLE_SIZE]; u_char ttr_ramp_data[32]; void l1tm_response_nodata(op) char *op; { char buf[80]; if (rvi_msg_len != 5) { sprintf(buf, "%s response wrong length", op); print_etm_pkt_raw(buf); return; } if (rvi_msg[3]) sprintf(buf, "%s error %u (0x%02X)", op, rvi_msg[3], rvi_msg[3]); else sprintf(buf, "%s OK", op); async_msg_output(buf); } void l1tm_response_index(op) char *op; { char buf[80]; if (rvi_msg[3]) { if (rvi_msg_len == 5) { sprintf(buf, "%s error %u (0x%02X)", op, rvi_msg[3], rvi_msg[3]); async_msg_output(buf); } else { sprintf(buf, "%s long error response", op); print_etm_pkt_raw(buf); } return; } if (rvi_msg_len != 6) { sprintf(buf, "%s response wrong length", op); print_etm_pkt_raw(buf); return; } sprintf(buf, "%s index %u (0x%02X) OK", op, rvi_msg[4], rvi_msg[4]); async_msg_output(buf); } void l1tm_response_index_val(op) char *op; { char buf[80]; unsigned val; if (rvi_msg[3]) { if (rvi_msg_len == 5) { sprintf(buf, "%s error %u (0x%02X)", op, rvi_msg[3], rvi_msg[3]); async_msg_output(buf); } else { sprintf(buf, "%s long error response", op); print_etm_pkt_raw(buf); } return; } if (rvi_msg_len != 8) { sprintf(buf, "%s response wrong length", op); print_etm_pkt_raw(buf); return; } val = rvi_msg[5] | (rvi_msg[6] << 8); if (val >= 0x8000) sprintf(buf, "%s index %u (0x%02X): 0x%04X (%u or %d)", op, rvi_msg[4], rvi_msg[4], val, val, (int)val - 65536); else sprintf(buf, "%s index %u (0x%02X): 0x%04X (%u)", op, rvi_msg[4], rvi_msg[4], val, val); async_msg_output(buf); } void l1tm_rfe_response() { char buf[80]; if (rvi_msg_len < 5 || rvi_msg_len > 6) { print_etm_pkt_raw("RF_ENABLE response wrong length"); return; } switch (rvi_msg[3]) { case 0: async_msg_output("rfe OK"); return; case 1: async_msg_output("RF operation finished"); return; default: sprintf(buf, "rfe error %u (0x%02X)", rvi_msg[3], rvi_msg[3]); async_msg_output(buf); return; } } void l1tm_stats_response() { char buf[80]; unsigned type, bitmask, val, offset; int expect_len; if (rvi_msg_len < 5) { wrong_len: print_etm_pkt_raw("STATS_READ response wrong length"); return; } if (rvi_msg[3]) { if (rvi_msg_len != 5) goto wrong_len; sprintf(buf, "sr error %u (0x%02X)", rvi_msg[3], rvi_msg[3]); async_msg_output(buf); return; } if (rvi_msg_len < 9) goto wrong_len; type = rvi_msg[4] | (rvi_msg[5] << 8); bitmask = rvi_msg[6] | (rvi_msg[7] << 8); if (type < 1 || type > 2 || (bitmask & 0x0300)) { print_etm_pkt_raw("STATS_READ response unable to parse"); return; } 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) goto wrong_len; sprintf(buf, "Stats type %u bitmask %04X:", type, bitmask); async_msg_output(buf); offset = 8; if (bitmask & RSSI) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8); offset += 2; sprintf(buf, "RSSI: %u (0x%04X)", val, val); async_msg_output(buf); } if (bitmask & DSP_PM) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8); offset += 2; sprintf(buf, "DSP_PM: %u (0x%04X)", val, val); async_msg_output(buf); } if (bitmask & ANGLE_MEAN) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "ANGLE_MEAN: %d (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & ANGLE_VAR) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "ANGLE_VAR: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & ANGLE_MIN) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "ANGLE_MIN: %d (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & ANGLE_MAX) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "ANGLE_MAX: %d (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & SNR_MEAN) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "SNR_MEAN: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & SNR_VAR) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "SNR_VAR: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & TOA_MEAN) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "TOA_MEAN: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & TOA_VAR) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "TOA_VAR: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & FRAME_NUMBER) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "FRAME_NUMBER: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & RUNS) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "RUNS: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & SUCCESSES) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8) | (rvi_msg[offset+2] << 16) | (rvi_msg[offset+3] << 24); offset += 4; sprintf(buf, "SUCCESSES: %u (0x%08X)", val, val); async_msg_output(buf); } if (bitmask & BSIC) { val = rvi_msg[offset] | (rvi_msg[offset+1] << 8); offset += 2; sprintf(buf, "BSIC: %u (0x%04X)", val, val); async_msg_output(buf); } } void l1tm_rftr_response() { char buf[80], *dp; unsigned i, j, l; if (rvi_msg[3]) { if (rvi_msg_len == 5) { sprintf(buf, "rftr error %u (0x%02X)", rvi_msg[3], rvi_msg[3]); async_msg_output(buf); } else print_etm_pkt_raw("rftr long error response"); return; } if (rvi_msg_len < 7 || rvi_msg_len > MAX_RF_TABLE_SIZE + 6) { print_etm_pkt_raw("rftr response wrong length"); return; } rftr_table_index = rvi_msg[4]; rftr_table_size = rvi_msg_len - 6; bcopy(rvi_msg + 5, rftr_table_data, rftr_table_size); sprintf(buf, "rftr index %u (0x%02X): %u bytes", rftr_table_index, rftr_table_index, rftr_table_size); async_msg_output(buf); for (i = 0; i < rftr_table_size; ) { l = rftr_table_size - i; if (l > 16) l = 16; sprintf(buf, "offset %02X:", i); dp = index(buf, '\0'); for (j = 0; j < l; j++) { if (j == 0 || j == 8) *dp++ = ' '; sprintf(dp, " %02X", rftr_table_data[i++]); dp += 3; } async_msg_output(buf); } } void l1tm_ttw_response() { char buf[80]; if (rvi_msg[3]) { if (rvi_msg_len == 5) { sprintf(buf, "ttw error %u (0x%02X)", rvi_msg[3], rvi_msg[3]); async_msg_output(buf); } else print_etm_pkt_raw("ttw long error response"); return; } if (rvi_msg_len < 5 || rvi_msg_len > 6) { print_etm_pkt_raw("ttw response wrong length"); return; } async_msg_output("ttw OK"); } void l1tm_ttr_response() { char buf[80], *dp; unsigned i; if (rvi_msg[3]) { if (rvi_msg_len == 5) { sprintf(buf, "ttr error %u (0x%02X)", rvi_msg[3], rvi_msg[3]); async_msg_output(buf); } else print_etm_pkt_raw("ttr long error response"); return; } if (rvi_msg_len != 38) { print_etm_pkt_raw("ttr response wrong length"); return; } sprintf(buf, "ttr index %u:", rvi_msg[4]); async_msg_output(buf); bcopy(rvi_msg + 5, ttr_ramp_data, 32); strcpy(buf, "ramp-up "); dp = buf + 9; for (i = 0; i < 16; i++) { sprintf(dp, "%4u", ttr_ramp_data[i]); dp += 4; } async_msg_output(buf); strcpy(buf, "ramp-down"); dp = buf + 9; for (i = 0; i < 16; i++) { sprintf(dp, "%4u", ttr_ramp_data[i+16]); dp += 4; } async_msg_output(buf); }