FreeCalypso > hg > freecalypso-tools
comparison rvinterf/etmsync/fsuploadrf.c @ 307:67d57375e3ad
fc-fsio upload-rf-table implemented
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Tue, 21 Nov 2017 06:48:44 +0000 |
parents | |
children | 7f30f92a6e35 |
comparison
equal
deleted
inserted
replaced
306:8136fb5eb292 | 307:67d57375e3ad |
---|---|
1 /* | |
2 * upload-rf-table implementation | |
3 */ | |
4 | |
5 #include <sys/types.h> | |
6 #include <stdio.h> | |
7 #include <stdlib.h> | |
8 #include <string.h> | |
9 #include <strings.h> | |
10 #include "etm.h" | |
11 #include "ffs.h" | |
12 #include "tmffs2.h" | |
13 #include "limits.h" | |
14 #include "exitcodes.h" | |
15 | |
16 static struct map { | |
17 char *format; | |
18 char *pathname; | |
19 int need_band; | |
20 } map_table[] = { | |
21 {"afcparams", "/gsm/rf/afcparams", 0}, | |
22 {"agc-global-params", "/gsm/rf/rx/agcglobals", 0}, | |
23 {"agc-table", "/gsm/rf/rx/agcwords", 0}, | |
24 {"tx-ramps", "/gsm/rf/tx/ramps.%s", 1}, | |
25 {"tx-levels", "/gsm/rf/tx/levels.%s", 1}, | |
26 {"tx-calchan", "/gsm/rf/tx/calchan.%s", 1}, | |
27 {"tx-caltemp", "/gsm/rf/tx/caltemp.%s", 1}, | |
28 {"rx-calchan", "/gsm/rf/rx/calchan.%s", 1}, | |
29 {"rx-caltemp", "/gsm/rf/rx/caltemp.%s", 1}, | |
30 {"rx-agc-params", "/gsm/rf/rx/agcparams.%s", 1}, | |
31 {0, 0, 0} | |
32 }; | |
33 | |
34 cmd_upload_rf_table(argc, argv) | |
35 char **argv; | |
36 { | |
37 u_char buf[512]; | |
38 char *format, pathname[32]; | |
39 struct map *map; | |
40 unsigned size; | |
41 int rc; | |
42 | |
43 rc = read_rf_table_ext(argv[1], buf, 1, &format, &size); | |
44 if (rc) | |
45 return(rc); | |
46 for (map = map_table; map->format; map++) | |
47 if (!strcmp(map->format, format)) | |
48 break; | |
49 if (!map->format) { | |
50 printf("error: %s tables cannot be uploaded\n", format); | |
51 return(ERROR_USAGE); | |
52 } | |
53 if (map->need_band) { | |
54 if (!argv[2]) { | |
55 printf("error: band not specified for %s table\n", | |
56 format); | |
57 return(ERROR_USAGE); | |
58 } | |
59 if (strlen(argv[2]) > 7) { | |
60 printf("error: band name argument is too long\n"); | |
61 return(ERROR_USAGE); | |
62 } | |
63 sprintf(pathname, map->pathname, argv[2]); | |
64 } else { | |
65 if (argv[2]) { | |
66 printf("error: band not applicable for %s table\n", | |
67 format); | |
68 return(ERROR_USAGE); | |
69 } | |
70 strcpy(pathname, map->pathname); | |
71 } | |
72 return write_buf_to_file(pathname, buf, size); | |
73 } |