MCPcopy Create free account
hub / github.com/kiibohd/controller / read_intel_hex

Function read_intel_hex

LoadFile/teensy_loader_cli.c:644–678  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

642static int parse_hex_line(char *line);
643
644int read_intel_hex(const char *filename)
645{
646 FILE *fp;
647 int i, lineno=0;
648 char buf[1024];
649
650 byte_count = 0;
651 end_record_seen = 0;
652 for (i=0; i<MAX_MEMORY_SIZE; i++) {
653 firmware_image[i] = 0xFF;
654 firmware_mask[i] = 0;
655 }
656 extended_addr = 0;
657
658 fp = fopen(filename, "r");
659 if (fp == NULL) {
660 //printf("Unable to read file %s\n", filename);
661 return -1;
662 }
663 while (!feof(fp)) {
664 *buf = '\0';
665 if (!fgets(buf, sizeof(buf), fp)) break;
666 lineno++;
667 if (*buf) {
668 if (parse_hex_line(buf) == 0) {
669 printf("Warning, HEX parse error line %d\n", lineno);
670 return -2;
671 }
672 }
673 if (end_record_seen) break;
674 if (feof(stdin)) break;
675 }
676 fclose(fp);
677 return byte_count;
678}
679
680
681/* from ihex.c, at http://www.pjrc.com/tech/8051/pm2_docs/intel-hex.html */

Callers 1

mainFunction · 0.85

Calls 1

parse_hex_lineFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…