fprintf(stderr, "Corrupt line %d in intel hex file\n", i);
errors++;
return errors;
+ case HEX_FILE_UNKNOWN_TYPE:
+ fprintf(stderr, "Unknown file type at line %d in intel hex file\n", i);
+ errors++;
+ break;
case HEX_FILE_END_OF_FILE:
if(progress)fputc('\n', stderr);
return errors;
do {
checksum1 = 0;
- if(feof(fd)) {
- return HEX_FILE_END_OF_FILE;
- }
if(fscanf(fd, ":%2x%2x%2x%2x", &length, &addr1, &addr2, &type) < 3) {
return HEX_FILE_CORRUPT_LINE;
}
- } while(type == 1 || type == 2);
+ } while(type == 2);
+
+ if(type == 0x01) return HEX_FILE_END_OF_FILE;
+
+ if(type != 0x00) {
+ return HEX_FILE_UNKNOWN_TYPE;
+ }
checksum1+=length;
checksum1+=type;
#define HEX_FILE_ERR_CHECKSUM -1 /* Invalid checksum */
#define HEX_FILE_CORRUPT_LINE -2 /* Corrupt line, no data read */
#define HEX_FILE_END_OF_FILE -3 /* End of line */
+#define HEX_FILE_UNKNOWN_TYPE -4 /* Unknown type */
#endif /* __HEXFILE_H__ */