# HG changeset patch # User Mychaela Falconia # Date 1511026226 0 # Node ID 77d561735b075a5ef227b5be7409e286e7b041f6 # Parent 79434b9de159619b9f3cc1a9d039de9d255fd7c2 c1xx-calextr: preparations for both ASCII and binary output diff -r 79434b9de159 -r 77d561735b07 ffstools/caltools/c1xx-calextr.c --- a/ffstools/caltools/c1xx-calextr.c Sat Nov 18 17:15:54 2017 +0000 +++ b/ffstools/caltools/c1xx-calextr.c Sat Nov 18 17:30:26 2017 +0000 @@ -2,8 +2,9 @@ * This program parses Compal's proprietary data structure that contains * the factory RF calibration values among other data, locates those RF * calibration records, extracts their essential content (Rx GMagic and - * Tx APC values) and writes this calibration out in the form of FreeCalypso - * ASCII RF tables. + * Tx APC values), converts this distilled content into TCS211 RF calibration + * tables (Rx agcparams and Tx levels) and writes these tables out in either + * FreeCalypso ASCII or FFS binary format. */ #include @@ -19,6 +20,7 @@ u_char sector[COMPAL_SECTOR_LENGTH]; u_char endmarker[8] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; u_char record_magic[4] = {0xAA, 0x00, 0x00, 0x00}; +char *ascii_output_dir, *bin_output_dir; struct band { char *name; @@ -86,8 +88,7 @@ return(0); } -main(argc, argv) - char **argv; +process_sector_data() { unsigned offset, next_offset; u_char *header; @@ -95,11 +96,6 @@ struct band *band; int i; - if (argc != 3) { - fprintf(stderr, "usage: %s binfile offset\n", argv[0]); - exit(1); - } - read_binfile(argv[1], argv[2]); for (offset = 0; ; offset = next_offset) { if (offset > COMPAL_SECTOR_LENGTH - 12) break; @@ -148,5 +144,37 @@ } process_band_record(band, offset); } +} + +main(argc, argv) + char **argv; +{ + int c; + extern char *optarg; + extern int optind; + + while ((c = getopt(argc, argv, "a:b:")) != EOF) + switch (c) { + case 'a': + ascii_output_dir = optarg; + continue; + case 'b': + bin_output_dir = optarg; + continue; + case '?': + default: +usage: fprintf(stderr, + "usage: %s [-a ascii_outdir] [-b bin_outdir] c1xx-binfile offset\n", + argv[0]); + exit(1); + } + if (argc - optind != 2) + goto usage; + read_binfile(argv[optind], argv[optind+1]); + if (ascii_output_dir) + mkdir_existok(ascii_output_dir); + if (bin_output_dir) + mkdir_existok(bin_output_dir); + process_sector_data(); exit(0); }