diff options
author | John Klug <john.klug@multitech.com> | 2017-01-04 16:53:26 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2017-01-04 16:53:26 -0600 |
commit | 0a85499b790e3c79a004d53fdb2ff7f58ee10990 (patch) | |
tree | 311a5ec4bf07c78f842ffef6cac6153757f8333e /src | |
parent | 75f073fe2cab473309e09c2e3c5e18601e781806 (diff) | |
download | mts-id-eeprom-0a85499b790e3c79a004d53fdb2ff7f58ee10990.tar.gz mts-id-eeprom-0a85499b790e3c79a004d53fdb2ff7f58ee10990.tar.bz2 mts-id-eeprom-0a85499b790e3c79a004d53fdb2ff7f58ee10990.zip |
Add ability to write arbitrary hex strings for GPS PROM
Diffstat (limited to 'src')
-rw-r--r-- | src/eeprom_main.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/eeprom_main.c b/src/eeprom_main.c index bdbace9..297c7d8 100644 --- a/src/eeprom_main.c +++ b/src/eeprom_main.c @@ -403,6 +403,7 @@ static void usage(FILE *out) { fprintf(out, " --capa-bluetooth |\n"); fprintf(out, " --capa-lora |\n"); fprintf(out, " --capa-clear (clears all flags) |\n"); + fprintf(out, " --hex-to-bin | \n"); fprintf(out, " --out-format { bin | yaml (default) } |\n"); fprintf(out, " --update |\n"); fprintf(out, " --accessory-card\n"); @@ -439,6 +440,7 @@ enum { CMD_OPT_VERSION, CMD_OPT_HELP, + CMD_OPT_HEX_TO_BIN, }; static char *short_options = "f:"; @@ -465,6 +467,7 @@ static struct option long_options[] = { {"capa-bluetooth", 0, NULL, CMD_OPT_CAPA_BLUETOOTH}, {"capa-lora", 0, NULL, CMD_OPT_CAPA_LORA}, {"capa-clear", 0, NULL, CMD_OPT_CAPA_CLEAR}, + {"hex-to-bin", 0, NULL, CMD_OPT_HEX_TO_BIN}, {"out-format", 1, NULL, CMD_OPT_OUT_FORMAT}, {"update", 0, NULL, CMD_OPT_UPDATE}, {"accessory-card", 0, NULL, CMD_OPT_ACCESSORY_CARD}, @@ -713,7 +716,22 @@ int main(int argc, char *argv[]) { out_format = optarg; break; - + case CMD_OPT_HEX_TO_BIN: + { + char buf[1025]; + char outbuf[1024]; + size_t sz, len; + while((sz=read(0,buf,sizeof buf)) > 0) { + buf[sz] = 0; + sz = asciiHexToBin(buf,outbuf); + len = write(1,outbuf,sz); + if(len != sz) { + log_error("failure to write to stdout: %s",strerror(errno)); + exit(1); + } + } + exit(0); + } default: usage(stderr); exit(1); |