La función de ReadLine, llena un buffer línea a línea del contenido del HEX, y va traduciendo la lectura según esta conformada la linea. La explicación es sencilla, y se basa en el formato Hex de Intel
Código:
Intel Hex is a common format to store binaries to be loaded into EPROM for
CPU's. It is a readable textformat that is line oriented. A line is built as
':', rec len, address, rec type, [data], checksum
whereas :
':' is start of record = 0x3A
reclen is the number of databytes as 2 digit hex
address is 4 digit hex, where the data starts
rec type is '00' for normal data, '01' end of file, '02' extended adress
[data] is a data packet encoded as hex
checksum is the 2's complement of the sum over the record excl the ':' modulo 256 as hex
Donde deja un ejemplo claro
Código:
:1005AA00000102030405060708090A0B0C0D0E0F88
rec len = 0x10 = 16
address = 0x05AA
data = 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
checksum = 0x88 = 256 -sum(0x00+..+0x0F)= 256- 0x78
Y a tomar encuenta el mapeo según el tipo de Eprom
Código:
There are extended formats, and there is the chance that the EPROM
is not located at 0x0000, but at 0xF0000 or similar.
Al encontrarse con un dato no válido, la función retorna el código de error #integer, sino devueve 0=OK.
Saludos