summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/eeprom_main.c20
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);