5/10/2024 0 Comments Read ihex file![]() If the function was got data, it will return true. The hex file we want to parse (file), the buffer we hold the line data in, the int array which will serve to hold the address of this line of data, a variable to hold the number of bytes in this line. 33: We pass read_line_from_hex() our variables we wish to fill.We loop until the we have read through all the lines we counted. 23: We count the number of lines in the file we wish to extract data.45: I read the checksum, but I don't do anything with it.Therefore, we pass it back to hex_file_to_array(). 42: We have to keep track of how many bytes are on each line, to complete our address of the data.37: Let's get all the data found on this line and put it into the array we provided the function.34: Combine the two 8-bit address bytes into one 16-bit address.32: If the record type is not data, we don't want it.The other types are explained well at the ole' Wiki article: Intel HEX record types. 29: Get the byte (red) identifying the type of information found on this line.26: Take the second byte of the data address (purple).If there are zero data, we return false.23: Take the first byte of the data address (purple). 20: We check if there was any data on this line.Meaning, there should be 16 bytes of data found on this line. Note, 10 is not a decimal number, it's hexadecimal. The "10" is how many bytes of data (blue) found on this line. This should be the ':' character, but remember our clear_special_char() should skip this and read the next two bytes '1' and '0' (green). The above code parses exactly one line of hex data from the file pointer. 26: We increment two ASCII characters read from the file pointer. ![]() 18: We combine the string of nibbles into a byte.(I will cover the Ascii2Hex function below.)The above steps are repeated for nibble B. ![]()
0 Comments
Leave a Reply. |