FreeCalypso > hg > freecalypso-tools
changeset 307:67d57375e3ad
fc-fsio upload-rf-table implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 21 Nov 2017 06:48:44 +0000 |
parents | 8136fb5eb292 |
children | 6a254cc6a7f3 |
files | rvinterf/etmsync/Makefile rvinterf/etmsync/fscmdtab.c rvinterf/etmsync/fsuploadrf.c |
diffstat | 3 files changed, 78 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/rvinterf/etmsync/Makefile Tue Nov 21 06:09:35 2017 +0000 +++ b/rvinterf/etmsync/Makefile Tue Nov 21 06:48:44 2017 +0000 @@ -11,9 +11,9 @@ FSIO_OBJS= cl_des.o connect.o dispatch.o fdcmd.o fileio.o fsbasics.o \ fscmdtab.o fserr.o fsiomain.o fsmisc.o fspath.o fsread.o \ - fsupload.o fswrite.o help.o hostmkdir.o interf.o launchrvif.o \ - memcmd.o memops.o pirimei.o pirmagnetite.o rfcap.o stddirs.o \ - symlink.o + fsupload.o fsuploadrf.o fswrite.o help.o hostmkdir.o interf.o \ + launchrvif.o memcmd.o memops.o pirimei.o pirmagnetite.o rfcap.o\ + stddirs.o symlink.o ${LIBRFTAB} MEMDUMP_OBJS= connect.o interf.o launchrvif.o memdump.o memops.o
--- a/rvinterf/etmsync/fscmdtab.c Tue Nov 21 06:09:35 2017 +0000 +++ b/rvinterf/etmsync/fscmdtab.c Tue Nov 21 06:48:44 2017 +0000 @@ -30,6 +30,7 @@ extern int cmd_symlink(); extern int cmd_uploadfs(); extern int cmd_upload_file(); +extern int cmd_upload_rf_table(); extern int cmd_upload_subtree(); extern int create_std_dirs(); @@ -67,6 +68,7 @@ {"symlink", 2, 2, cmd_symlink}, {"upload-file", 2, 2, cmd_upload_file}, {"upload-fs", 1, 1, cmd_uploadfs}, + {"upload-rf-table", 1, 2, cmd_upload_rf_table}, {"upload-subtree", 2, 2, cmd_upload_subtree}, {0, 0, 0, 0} };
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rvinterf/etmsync/fsuploadrf.c Tue Nov 21 06:48:44 2017 +0000 @@ -0,0 +1,73 @@ +/* + * upload-rf-table implementation + */ + +#include <sys/types.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <strings.h> +#include "etm.h" +#include "ffs.h" +#include "tmffs2.h" +#include "limits.h" +#include "exitcodes.h" + +static struct map { + char *format; + char *pathname; + int need_band; +} map_table[] = { + {"afcparams", "/gsm/rf/afcparams", 0}, + {"agc-global-params", "/gsm/rf/rx/agcglobals", 0}, + {"agc-table", "/gsm/rf/rx/agcwords", 0}, + {"tx-ramps", "/gsm/rf/tx/ramps.%s", 1}, + {"tx-levels", "/gsm/rf/tx/levels.%s", 1}, + {"tx-calchan", "/gsm/rf/tx/calchan.%s", 1}, + {"tx-caltemp", "/gsm/rf/tx/caltemp.%s", 1}, + {"rx-calchan", "/gsm/rf/rx/calchan.%s", 1}, + {"rx-caltemp", "/gsm/rf/rx/caltemp.%s", 1}, + {"rx-agc-params", "/gsm/rf/rx/agcparams.%s", 1}, + {0, 0, 0} +}; + +cmd_upload_rf_table(argc, argv) + char **argv; +{ + u_char buf[512]; + char *format, pathname[32]; + struct map *map; + unsigned size; + int rc; + + rc = read_rf_table_ext(argv[1], buf, 1, &format, &size); + if (rc) + return(rc); + for (map = map_table; map->format; map++) + if (!strcmp(map->format, format)) + break; + if (!map->format) { + printf("error: %s tables cannot be uploaded\n", format); + return(ERROR_USAGE); + } + if (map->need_band) { + if (!argv[2]) { + printf("error: band not specified for %s table\n", + format); + return(ERROR_USAGE); + } + if (strlen(argv[2]) > 7) { + printf("error: band name argument is too long\n"); + return(ERROR_USAGE); + } + sprintf(pathname, map->pathname, argv[2]); + } else { + if (argv[2]) { + printf("error: band not applicable for %s table\n", + format); + return(ERROR_USAGE); + } + strcpy(pathname, map->pathname); + } + return write_buf_to_file(pathname, buf, size); +}