Hallo Zusammen,
für die Steuerung eines DSPs über eine serielle Schnittstelle muss ich Checksummen kalkulieren. Die Dokumentation sagt das folgende:
CCIT checksum
The CCIT checksum is an 8 bit CRC byte used to validate the Header and Payload. This byte can be calculated by initializing the checksum byte to 0xFF and passing each byte though the following calculation. The Network_CCITT_8_Table is included in the Appendix.UCHAR update_bcc(UCHAR current_bcc, UCHAR new_byte)
{
return Network_CCITT_8_Table[current_bcc ^ new_byte];
}The checksum is calculated on all bytes in the Frame, Header, and Payload. See Section 4 for detailed information concerning Checksum calculations.
sowie weiter unten etwas genauer:
How to calculate a checksum using code for the dBX ZonePRO:
//shown in AMX Netlinx syntax
//$ = hex
CHAR CCIT = {$5E,$BC,$E2,$61,$3F,$DD,$83,$C2,$9C,$7E,$20,$A3,$FD,$1F,$41,
$9D,$C3,$21,$7F,$FC,$A2,$40,$1E,$5F,$01,$E3,$BD,$3E,$60,$82,$DC,
$23,$7D,$9F,$C1,$42,$1C,$FE,$A0,$E1,$BF,$5D,$03,$80,$DE,$3C,$62,
$BE,$E0,$02,$5C,$DF,$81,$63,$3D,$7C,$22,$C0,$9E,$1D,$43,$A1,$FF,
$46,$18,$FA,$A4,$27,$79,$9B,$C5,$84,$DA,$38,$66,$E5,$BB,$59,$07,
$DB,$85,$67,$39,$BA,$E4,$06,$58,$19,$47,$A5,$FB,$78,$26,$C4,$9A,
$65,$3B,$D9,$87,$04,$5A,$B8,$E6,$A7,$F9,$1B,$45,$C6,$98,$7A,$24,
$F8,$A6,$44,$1A,$99,$C7,$25,$7B,$3A,$64,$86,$D8,$5B,$05,$E7,$B9,
$8C,$D2,$30,$6E,$ED,$B3,$51,$0F,$4E,$10,$F2,$AC,$2F,$71,$93,$CD,
$11,$4F,$AD,$F3,$70,$2E,$CC,$92,$D3,$8D,$6F,$31,$B2,$EC,$0E,$50,
$AF,$F1,$13,$4D,$CE,$90,$72,$2C,$6D,$33,$D1,$8F,$0C,$52,$B0,$EE,
$32,$6C,$8E,$D0,$53,$0D,$EF,$B1,$F0,$AE,$4C,$12,$91,$CF,$2D,$73,
$CA,$94,$76,$28,$AB,$F5,$17,$49,$08,$56,$B4,$EA,$69,$37,$D5,$8B,
$57,$09,$EB,$B5,$36,$68,$8A,$D4,$95,$CB,$29,$77,$F4,$AA,$48,$16,
$E9,$B7,$55,$0B,$88,$D6,$34,$6A,$2B,$75,$97,$C9,$4A,$14,$F6,$A8,
$74,$2A,$C8,$96,$15,$4B,$A9,$F7,$B6,$E8,$0A,$54,$D7,$89,$6B,$35};//COMMAND COPIED FROM NETWORK TRACE WINDOW
CHAR DBX = {$64,$00,$1,$0,$0,$0,$1B,$00,$33,$1,$5,$0,$1E,$0,$20,$1,$5,$0,$1E,$1,$0,$5,$0,$0,$1,$0,$0,$1,$1};BUTTON_EVENT[dvTP,65]
{
PUSH:
{
LOCAL_VAR CHAR BCC; //CHECKSUM
LOCAL_VAR INTEGER I; //LOOP COUNTERBCC = $FF; //INITIALIZE CHECKSUM FOR (I = 1; I<= LENGTH_ARRAY(DBX);I++)
{
BCC = CCIT[(BCC BXOR DBX[i])]; //bitwise XOR each element of command
}
}}
Checksum (BCC) is $08 for the DBX command stated in the example;
Ich stehe da leider etwas auf dem Schlauch, kann mir jemand auf die Sprünge helfen wie genau sich die Checksumme nun berechnet, bzw. wie ich diese Beispielberechnung in PHP abbilden kann?
Gruß