[ _deran_ @ 29.10.2005. 19:26 ] @
Ima li neko? |
[ _deran_ @ 29.10.2005. 19:26 ] @
[ reiser @ 31.10.2005. 14:29 ] @
Aj pojasni malo kakav ti kod treba. Za izracunavanje CRC32 cheksuma ili nesto drugo ?
[ _deran_ @ 01.11.2005. 12:49 ] @
Imam neku masinu koja komunicira preko COM porta. Treba da posaljem nekoliko bajtova i naravno na kraju checksum u 2 bajta. Negde sam nasao da ta 2 bajta i nisu checksum nego da je prvi ostatak koji se dobije kada se CRC podeli sa 256 decimalno, a drugi bajt je High Byte. Nasao sam programe za izracunavanje CRC-CCITT ali nikako da nadjem vezu izmedju tih brojeva i mojih.
Primeri: FC 05 40 2B 15 FC 05 50 AA 05 FC 05 11 27 56 FC 05 1B 7D F9 [ reiser @ 01.11.2005. 14:13 ] @
Koliko sam ja shvatio ti treba da u zadnja dva bajta posaljes masini checksum. A kako treba da se izracuna taj checksum, tj sta je prvi a sta drugi bajt, objasni to malo. I ne kontam kakve su ti ove hex vrednosti dole :>
[ _deran_ @ 03.11.2005. 09:31 ] @
FC 05 40 -poruka 2B 15 -CRC (pise da je CCITT sa osnovom 0)
FC =const (1 bajt) 05 =ukupno bajtova koji se salje (od FC do kraja CRC) (1 bajt) 40 =komanda (1 bajt) XX XX XX XX XX =moze biti jos nekih parametara za komande (<250 bajtova) 2B 15 =CRC (2 bajta) To se i ja pitam kako se prave ova dva zadnja bajta :) Citat: The resulting CRC calculation for the character "T" is 0x1B26 or a decimal 6950. If you were going to use this computed CRC to append to a transmission you would divide the number by the Decimal number 256 and assign the result to the High Byte and the remainder to the Low Byte and then transmit the CRC Low Byte first High Byte second. In this case the Exact ASCII representation of the transmission would look like this.... "T&^[" or T&(ESC). The High Byte is an ASCII(27) which is equal to the escape key or ctrl-leftbracket (^[). The Low Byte is an ASCII(38) which is the ampersand (&). -to sam nasao na nekom sajtu, ali kad probam to da primenim na checksum koji su mi izracunali neki sajtovi i programi (skoro svi su dali isto) nikako da dobijem ono sto treba. Za nekoliko komandi imam primere, ali gde treba sa parametrima -fali mi CRC. [ volman @ 27.06.2006. 12:40 ] @
Ovde je koda za kreiranje checksuma u tom primjeru, predpostavljajuci, da imamo na formi Edit box, u kojeg pisemo poruku:
Code: function TForm1.CRC: word; var i,ByteCount:integer; shiftRegister:word; ByteString: array of byte; begin Result:=0; ByteCount:=StrToInt(Copy(Edit1.Text,4,2))-2; SetLength(ByteString,ByteCount); for i:=0 to ByteCount - 1 do begin ByteString[i]:=strtoint('$' + Copy(Edit1.Text,3*i+1,2)); shiftregister:= (Result xor ByteString[i]) and $F; Result:= (Result shr 4) xor (ShiftRegister * $1081); // $1081 is hexadecimal representation of polynomial; change this for different polynom shiftregister:= (Result xor (ByteString[i] shr 4)) and $F; Result := (Result shr 4) xor (shiftregister * $1081); end; [Ovu poruku je menjao volman dana 28.06.2006. u 08:48 GMT+1] Copyright (C) 2001-2025 by www.elitesecurity.org. All rights reserved.
|