From 7657f0291bf72fc783e92f704641fcd89db07bb5 Mon Sep 17 00:00:00 2001 From: Alexander Hansen Date: Thu, 19 Dec 2024 06:35:49 +0100 Subject: [PATCH] Ignore non-record chars in .ihex files [1] -> Format -> Record Structure -> 1 describes that each line contains a record. The record starts with ':' and "All characters preceding this symbol in a record should be ignored". Search for that char in the line and continue to the next line if it is not found. resolves #64 References: [1] https://en.wikipedia.org/wiki/Intel_HEX --- engine/src/reader/format/ihex.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/engine/src/reader/format/ihex.c b/engine/src/reader/format/ihex.c index 8e77839..f479707 100644 --- a/engine/src/reader/format/ihex.c +++ b/engine/src/reader/format/ihex.c @@ -5,6 +5,7 @@ #include #include #include +#include // Project Headers (engine, readers) #include "engine/include/reader/format/ihex.h" @@ -97,11 +98,19 @@ static int32_t read_ihex_file(const char *hex_file, vmcu_binary_buffer_t *bb, ui FILE *f = NULL; size_t len; char *line = NULL; + ssize_t nread; if((f = fopen(hex_file, "r")) == NULL) return -1; - while(getline(&line, &len, f) != -1) { + while((nread = getline(&line, &len, f)) != -1) { + + size_t i = 0; + while(i < nread && (line[i++] != ':')){} + + if (i == nread){ + continue; + } if(read_ihex_line(line, bb, size) < 0) {