English
Source / code snippets

CRC16-Checksummen-Streamtest

 

p.specht

an expansion the already treated CRC-8 Prüfsummenverfahrens on 16 bit-Words. in the Contrast To others take action becomes not on vorberechnete Polynomtabellen zurückgegriffen, separate it go Shiftbefehle using. Reine demonstration for private tack - it dürften rights Third existieren!
CLS
' DEMO ONLY! NO WARRANTY WHATSOEVER! ALL RIGHTS APPLY TO THEIR RESPECTIVE OWNERS!
def &IBM = $A001' Used by Bisync, Modbus, USB, ANSI X3.28, SIA DC-07, ...
def &CCITT=$8408' Used by X.25, V.41, HDLC FCS, XMODEM, Bluetooth, PACTOR, SD
def &SCSI =$EDD1' Used by SCSI
Def %CRC16POLY &CCITT' $18 would z.B. X^8+X^5+X^4+X^0
Var CRC16_Sp% = 0' CRC16 memory

proc CRC16_berechnen :Parameters crc_data%' Übergabe data

    Var bit_counter% = 16' Schleifendurchlauf
    Var feedback_bit% = 0' bit Return

    while bit_counter% > 0' 8x Durchläufe

        feedback_bit% = Xor(CRC16_Sp%,crc_data%) & $01' XOR on 1 to check on

        if feedback_bit% = $01' if 1, then...

            CRC16_Sp% = Xor(CRC16_Sp%,%CRC16POLY)' XOR with Poly

        EndIf

        CRC16_Sp% = (CRC16_Sp% >> 1) & $7FFF' Invoice values right & 32767  '$7F=247  <<<<<<

        if feedback_bit% = $01' if 1, then...

            CRC16_Sp% = CRC16_Sp% | $8000' 32768    'ODER 128   <<<<<<<<<<<<<<<

        EndIf

        crc_data% = crc_data% >> 1' data Invoice values right
        Dec bit_counter%' Schleifendurchlauf -1

    EndWhile' end Endlosschleife

endproc

Testaufruf:
CRC16_Sp% = 0' Reset CRC8 memory

WhileLoop 0,2^16-1, 7' Chr$(0)+Chr$(0) To Chr$(255)+Chr$(255) go through with Step 7

    CRC16_berechnen(&Loop)' CRC to charge
    Print "Daten="+Str $(&Loop)+"   CRC16="+Str $(CRC16_Sp%),
    ' well then as Binärwert under Connection the Prüfsumme rückprüfen, must then 0 yield:"
    CRC16_berechnen(val("%"+right$("0000000000000000"+be$(&Loop),16)+right$("0000000000000000"+be$(CRC16_Sp%),16)) )
    Print tab(40);"Errorflag: ";Str $(CRC16_Sp%)

EndWhile

waitinput
 
XProfan 11
Computer: Gerät, daß es in Mikrosekunden erlaubt, 50.000 Fehler zu machen, zB 'daß' statt 'das'...
05/19/21  
 



Zum Quelltext


Topictitle, max. 100 characters.
 

Systemprofile:

no Systemprofil laid out. [anlegen]

XProfan:

 Posting  Font  Smilies  ▼ 

Please register circa a Posting To verfassen.
 

Topic-Options

1.344 Views

Untitledvor 0 min.
Axel Berse06/17/24
Member 361000508/04/22
p.specht11/21/21
R.Schneider11/20/21
More...

Themeninformationen

this Topic has 1 subscriber:

p.specht (1x)


Admins  |  AGB  |  Applications  |  Authors  |  Chat  |  Privacy Policy  |  Download  |  Entrance  |  Help  |  Merchantportal  |  Imprint  |  Mart  |  Interfaces  |  SDK  |  Services  |  Games  |  Search  |  Support

One proposition all XProfan, The there's!


My XProfan
Private Messages
Own Storage Forum
Topics-Remember-List
Own Posts
Own Topics
Clipboard
Log off
 Deutsch English Français Español Italia
Translations

Privacy Policy


we use Cookies only as Session-Cookies because of the technical necessity and with us there no Cookies of Drittanbietern.

If you here on our Website click or navigate, stimmst You ours registration of Information in our Cookies on XProfan.Net To.

further Information To our Cookies and moreover, How You The control above keep, find You in ours nachfolgenden Datenschutzerklärung.


all rightDatenschutzerklärung
i want none Cookie