FreeCalypso > hg > freecalypso-tools
changeset 273:18a8fb3d845b
fc-tmsync: user command wrappers implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Thu, 16 Nov 2017 23:33:50 +0000 |
parents | 3e272b956ef4 |
children | f22874b351b7 |
files | rvinterf/etmsync/Makefile rvinterf/etmsync/l1tmcmd.c |
diffstat | 2 files changed, 236 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile Thu Nov 16 19:26:24 2017 +0000 +++ b/rvinterf/etmsync/Makefile Thu Nov 16 23:33:50 2017 +0000 @@ -14,8 +14,9 @@ MEMDUMP_OBJS= connect.o interf.o launchrvif.o memdump.o memops.o -TMSYNC_OBJS= cl_des.o connect.o dispatch.o interf.o l1tmops.o launchrvif.o \ - memcmd.o memops.o pirimei.o tmscmdtab.o tmsmain.o +TMSYNC_OBJS= cl_des.o connect.o dispatch.o interf.o l1tmcmd.o l1tmops.o \ + launchrvif.o memcmd.o memops.o pirimei.o rftablewr.o \ + tmscmdtab.o tmsmain.o all: ${PROGS} @@ -31,6 +32,9 @@ fc-tmsync: ${TMSYNC_OBJS} ${CC} ${CFLAGS} -o $@ ${TMSYNC_OBJS} +rftablewr.o: ../tmsh/rftablewr.c + ${CC} ${CFLAGS} -c -o $@ $< + install: ${PROGS} mkdir -p ${INSTBIN} install -c ${PROGS} ${INSTBIN}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etmsync/l1tmcmd.c Thu Nov 16 23:33:50 2017 +0000 @@ -0,0 +1,230 @@ +/* + * This module contains the user command wrappers around the functions + * in the l1tmops.c module. + */ + +#include <sys/types.h> +#include <ctype.h> +#include <stdio.h> +#include <string.h> +#include <strings.h> +#include <stdlib.h> +#include "pktmux.h" +#include "limits.h" +#include "localtypes.h" +#include "tm3.h" +#include "l1tm.h" +#include "exitcodes.h" + +extern void write_afcparams_table(); +extern void write_agcwords_table(); +extern void write_agcglobals_table(); +extern void write_il2agc_table(); +extern void write_tx_levels_table(); +extern void write_tx_calchan_table(); +extern void write_tx_caltemp_table(); +extern void write_rx_calchan_table(); +extern void write_rx_caltemp_table(); +extern void write_rx_agcparams_table(); + +cmd_tms(argc, argv) + char **argv; +{ + u16 arg; + + arg = strtoul(argv[1], 0, 0); + return do_tms(arg); +} + +static +is_num_string(argstr) + char *argstr; +{ + char *cp = argstr; + + if (!isdigit(*cp++)) + return(0); + while (*cp) { + if (!isdigit(*cp++)) + return(0); + } + return(1); +} + +struct kwtab { + char *kw; + int val; +}; + +static +keyword_or_num(argstr, kwtab, valp) + char *argstr; + struct kwtab *kwtab; + u16 *valp; +{ + struct kwtab *tp; + + if (is_num_string(argstr)) { + *valp = atoi(argstr); + return(0); + } + for (tp = kwtab; tp->kw; tp++) { + if (!strcmp(tp->kw, argstr)) { + *valp = tp->val; + return(0); + } + } + printf("error: non-numeric argument not understood\n"); + return(ERROR_USAGE); +} + +static struct kwtab rf_param_arg[] = { + {"bcch-arfcn", BCCH_ARFCN}, + {"tch-arfcn", TCH_ARFCN}, + {"mon-arfcn", MON_ARFCN}, + {"pdtch-arfcn", PDTCH_ARFCN}, + {"std-band", STD_BAND_FLAG}, + {"afc-enable", AFC_ENA_FLAG}, + {"afc-dac-val", AFC_DAC_VALUE}, + {"init-afc-dac", INITIAL_AFC_DAC}, + {"multislot-class", MULTISLOT_CLASS}, + {0, 0} +}; + +cmd_rfpw2(argc, argv) + char **argv; +{ + u16 index, value; + + if (keyword_or_num(argv[1], rf_param_arg, &index)) + return(ERROR_USAGE); + value = strtol(argv[2], 0, 0); + return do_rfpw(index, value); +} + +cmd_rfpw3(argc, argv) + char **argv; +{ + u16 index; + u8 val1, val2; + + if (keyword_or_num(argv[1], rf_param_arg, &index)) + return(ERROR_USAGE); + val1 = strtoul(argv[2], 0, 0); + val2 = strtoul(argv[3], 0, 0); + return do_rfpw(index, (val2 << 8) | val1); +} + +cmd_rfpw(argc, argv) + char **argv; +{ + switch (argc) { + case 3: + return cmd_rfpw2(argc, argv); + case 4: + return cmd_rfpw3(argc, argv); + default: + fprintf(stderr, "BUG: wrong argc in cmd_rfpw()\n"); + return(ERROR_BUG); + } +} + +cmd_rfpr(argc, argv) + char **argv; +{ + u16 index, val; + int rc; + + if (keyword_or_num(argv[1], rf_param_arg, &index)) + return(ERROR_USAGE); + rc = do_rfpr(index, &val); + if (rc) + return(rc); + if (val >= 0x8000) + printf("read value: 0x%04X (%u or %d)", val, val, + (int)val - 65536); + else + printf("read value: 0x%04X (%u)", val, val); + return(0); +} + +static struct kwtab rf_table_arg[] = { + {"rx-agc-table", RX_AGC_TABLE}, + {"afcparams", AFC_PARAMS}, + {"rx-agc-global-params", RX_AGC_GLOBAL_PARAMS}, + {"rx-il2agc-max", RX_IL_2_AGC_MAX}, + {"rx-il2agc-pwr", RX_IL_2_AGC_PWR}, + {"rx-il2agc-av", RX_IL_2_AGC_AV}, + {"tx-levels", TX_LEVELS}, + {"tx-calchan", TX_CAL_CHAN}, + {"tx-caltemp", TX_CAL_TEMP}, + {"rx-calchan", RX_CAL_CHAN}, + {"rx-caltemp", RX_CAL_TEMP}, + {"rx-agcparams", RX_AGC_PARAMS}, + {0, 0} +}; + +static struct table_map { + int index; + int size; + void (*func)(); +} table_map[] = { + {RX_AGC_TABLE, 40, write_agcwords_table}, + {AFC_PARAMS, 24, write_afcparams_table}, + {RX_AGC_GLOBAL_PARAMS, 8, write_agcglobals_table}, + {RX_IL_2_AGC_MAX, 121, write_il2agc_table}, + {RX_IL_2_AGC_PWR, 121, write_il2agc_table}, + {RX_IL_2_AGC_AV, 121, write_il2agc_table}, + {TX_LEVELS, 128, write_tx_levels_table}, + {TX_CAL_CHAN, 128, write_tx_calchan_table}, + {TX_CAL_TEMP, 40, write_tx_caltemp_table}, + {RX_CAL_CHAN, 40, write_rx_calchan_table}, + {RX_CAL_TEMP, 44, write_rx_caltemp_table}, + {RX_AGC_PARAMS, 8, write_rx_agcparams_table}, + {0, 0, 0} +}; + +cmd_rftr(argc, argv) + char **argv; +{ + u16 index; + struct table_map *tp; + u_char table_data[MAX_RF_TABLE_SIZE]; + int rc; + + if (keyword_or_num(argv[1], rf_table_arg, &index)) + return(ERROR_USAGE); + for (tp = table_map; tp->index; tp++) { + if (tp->index == index) + break; + } + if (!tp->index) { + printf("error: table index %u not supported, use fc-tmsh\n", + index); + return(ERROR_USAGE); + } + rc = do_rftr(index, table_data, tp->size); + if (rc) + return(rc); + tp->func(table_data, stdout); + return(0); +} + +cmd_ttr(argc, argv) + char **argv; +{ + unsigned index; + u_char ramp_data[32]; + int rc; + + index = strtoul(argv[1], 0, 0); + if (index >= 16) { + printf("error: index out of range\n"); + return(ERROR_USAGE); + } + rc = do_ttr(index, ramp_data); + if (rc) + return(rc); + write_tx_ramp(ramp_data, stdout); + return(0); +}