Delphi-PRAXiS
Seite 2 von 2     12   

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Probleme mit CRC CCITT Prüfsumme (https://www.delphipraxis.net/160938-probleme-mit-crc-ccitt-pruefsumme.html)

Deep-Sea 9. Jun 2011 10:17

AW: Probleme mit CRC CCITT Prüfsumme
 
Zitat:

Zitat von willyxv (Beitrag 1105426)
Denke schon, im Programm wird die Prüfsumme auch aus dem Namen der zu bestimmenden Werte gebildet.

Und die Stings sind auch ganz sicher ASCII und nicht vlt. als UTF-16 codiert?!


Zitat:

Zitat von willyxv (Beitrag 1105426)
Wo finde bzw setzte ich hier den Start_Val aus dem C programm?

Na bei
Delphi-Quellcode:
Result := High(Result);

Man kann natürlich auch
Delphi-Quellcode:
Result := Word(-1);
schreiben, wenn es einem mehr gefällt :-D

willyxv 9. Jun 2011 10:22

AW: Probleme mit CRC CCITT Prüfsumme
 
Hmm jetzt weiß ich auch nicht mehr weiter, werd mich mal direkt an die firma richten, danke für die Hilfe.

Zitat:

Zitat von Deep-Sea (Beitrag 1105431)
Zitat:

Zitat von willyxv (Beitrag 1105426)
Denke schon, im Programm wird die Prüfsumme auch aus dem Namen der zu bestimmenden Werte gebildet.

Und die Stings sind auch ganz sicher ASCII und nicht vlt. als UTF-16 codiert?!

Aus der Anleitung:
"Within the name, parameters, only ASCII characters (ASCII 32 to 126) are allowed, i. e. ä, ü and µ are invalid characters and will cause a failure."

gammatester 9. Jun 2011 10:43

AW: Probleme mit CRC CCITT Prüfsumme
 
Mit dem zweiten Datensatz (Beispiel 2: Wert: "385183474" Prüfsumme: "45942") liefert mein Pascal-Code den richtigen Wert, hier die komplette Funktion:
Delphi-Quellcode:
function GenerateCRC16(const s: ansistring): word;
var
  crc16: word;
  i: integer;
begin
  crc16 := $FFFF;
  for i:=1 to length(s) do begin
    crc16 := ((ord(s[i]) and $ff) xor ((crc16 and $ff) shl 8)) xor Crc16Tab[crc16 shr 8];
  end;
  result := crc16;
end;
Den ersten Datensatz solltest Du halt noch mal kontrollieren.

willyxv 9. Jun 2011 10:54

AW: Probleme mit CRC CCITT Prüfsumme
 
Hi,

danke es funktioniert jetzt, der Erste Datensatz steht zwar so in der Anleitung, aber die Maschiene tut.

Vielen Dank


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:56 Uhr.
Seite 2 von 2     12   

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz