Autor Beitrag
oOXTCOo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 141

Windows XP Prof. 3
Delphi 7
BeitragVerfasst: Do 28.05.09 15:28 
hallo!

ich müsste einige hexwerte wie: $01 $E1 $00 usw... auf odd oder even prüfen weil
ich nachher alle geraden xoren und dann alle ungeraden xoren muss.

ich habe das hier geschrieben, bin mir aber nicht sicher ob es richtig ist:

ausblenden Quelltext
1:
2:
 if Odd($01) then memo1.lines.add(s + ': ' + 'odd')
 else memo1.lines.add(s + ': ' + 'even');



oder muss ich den hex wert zuerst nach interger convertieren?


danke.
hari
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 28.05.09 15:34 
Das ist so schon richtig. Es gibt keine Hexadezimalwerte, das ist nur eine Darstellung eines Zahlenwertes. Ob die Darstellung hexadezimal oder dezimal oder binär (kennt Delphi allerdings nicht) ist, ändert ja am Wert nichts.
oOXTCOo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 141

Windows XP Prof. 3
Delphi 7
BeitragVerfasst: Do 28.05.09 16:05 
danke, dann versuche ichs nochmals...

denn es kommt immer eine flasche checksumme raus...

naja mal sehen... danke nochmals...

---Moderiert von user profile iconNarses: Beiträge zusammengefasst---

das stimmt was nicht...

ich habe diesen text gefunden:
Zitat:
calculate checksums and add them to the frame there are two checksums for FBUS. The first is an exclusive or (XOR) of the characters in every odd position in the frame and the second is an exclusive or (XOR) of the characters in every even position in the frame (eg if a frame was 1E 0C 00 7F 00 02 02 03, the odd checksum value would be: 1E XOR 00 XOR 00 XOR 02 which results in a value of 1C and the even checksum byte would be: 0C XOR 7F XOR 02 XOR 03 which results in a value of 72 note all values shown above are in hex

das ist genau das was ich brauche...

laut diesem text sollte zb. 1E ODD sein... aber mit meinem code zeigt er mir EVEN an...

Moderiert von user profile iconNarses: Quote-Tags hinzugefügt.
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 28.05.09 16:47 
Äh, Moment...
Das gerade oder ungerade bezieht sich auf die Position an der Stelle... (odd position, even position)

Die Positionen 1, 3, 5 ... sind ungerade, die anderen gerade. Das hat mit den Werten rein gar nichts zu tun.

// EDIT:
Du musst also das gar nicht prüfen, sondern kannst eine normale for-Schleife nehmen und zwei Werte mitführen.
oOXTCOo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 141

Windows XP Prof. 3
Delphi 7
BeitragVerfasst: Do 28.05.09 16:53 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Äh, Moment...
Das gerade oder ungerade bezieht sich auf die Position an der Stelle... (odd position, even position)

Die Positionen 1, 3, 5 ... sind ungerade, die anderen gerade. Das hat mit den Werten rein gar nichts zu tun.

// EDIT:
Du musst also das gar nicht prüfen, sondern kannst eine normale for-Schleife nehmen und zwei Werte mitführen.


achsoo, also für odd nehme ich angefangen von der ersten position immer jeden zweiten wert
und für die even checksumme nehme ich jeden zweiten wert gezählt von der zweiten stelle?
jaenicke
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 19341
Erhaltene Danke: 1752

W11 x64 (Chrome, Edge)
Delphi 12 Pro, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
BeitragVerfasst: Do 28.05.09 16:55 
Richtig. Also eine einfache Schleife, die bei jedem Durchlauf zwei Werte berechnet. Dann hast du danach direkt beide Prüfsummen.
oOXTCOo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 141

Windows XP Prof. 3
Delphi 7
BeitragVerfasst: Do 28.05.09 16:57 
user profile iconjaenicke hat folgendes geschrieben Zum zitierten Posting springen:
Richtig. Also eine einfache Schleife, die bei jedem Durchlauf zwei Werte berechnet. Dann hast du danach direkt beide Prüfsummen.



danke stimmt!


hier ist das ergebnis:

1E 00 0C 7F 00 02 D2 01 CHECKSUM: C0 7C
ODD CHECKSUM = C0
EVEN CHECKSUM = 7C


danke dir! (warum denn einfach wenns auch schwer geht?) ;)