Hi,
zur Verifiktion, dass das Flashen auch richtig funktioniert hat, möchte
ich intern<->extern eine Prüfsumme vergleichen.
Extern, d.h. auf dem PC, wandele ich die Daten eines S19-Files in binäre
Daten, um die Prüfsumme zu errechnen.
Das klappt auch :-), allerdings bekomme ich die Prüfsumme der einzelnen
S19-Zeilem der S19-Datei nicht hin (...und wofür gibt es die nun mal?)
Es gibt diverse Quellen im Netz zum S19-Format, z,B.:
...
checksum A char[2] field. These characters when paired and
interpreted as a hexadecimal value display the
least significant byte of the ones complement of
the sum of the byte values represented by the
pairs of characters making up the count, the
address, and the data fields.
...
Code sagt mehr als tausend Worte, hier für ein S1-Record (die Roh-Daten
sind wie gesagt korrekt):
1 | unsigned char S19_CalcChkSum(unsigned char nBytes, unsigned int Adress, unsigned char *pData) {
|
2 | unsigned char c, chksum, i;
|
3 | // Anzahl Bytes
|
4 | chksum=nBytes;
|
5 | // Adresse
|
6 | c=(Adress>>8) & 0xFF;
|
7 | chksum+=c;
|
8 | c=(Adress>>0) & 0xFF;
|
9 | chksum+=c;
|
10 | // Daten
|
11 | for (i=0; i<nBytes; i++) {
|
12 | c=pData[i];
|
13 | chksum+=c;
|
14 | }
|
15 | return ~chksum;
|
16 | }
|
Hat jemand einen Tipp, wie's richig geht?