Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Crc16 ccitt

Empfohlene Antworten

Veröffentlicht

Hi Leute,

ich sitze gerade dabei eine CRC (CRC16 CCITT) Implementierung umzusetzen. Ich habe allerdings eine Verständnisfrage:

Grundsätzlich ist es mir recht klar, wie das Ganze abläuft. Nur ein Punkt will mir nicht in den Schädel,

und zwar die Generierung der Lookup Tabelle. Wenn ich das richtig verstehe, enthält die Lookup Tabelle

für jedes möglicherweise im Datenframe enthaltene Byte den entsprechenden CRC-Wert, was eine Byteweise statt einer

Bitweisen ermöglicht und ist dadurch dann entsprechend Schneller

Der Code sieht wie folgt aus: und ist zum Teil geklaut ;) (Quelle)


Private Sub GenerateLookupTable()

        Dim temp As UShort

        Dim value As UShort

[COLOR="#008000"]'Die Größe der Tabelle entspricht hier der Anzahl der im 

        'Datenframe möglichen Zeichen[/COLOR]      

        _lookupTable = New UShort(255) {}


     [COLOR="#008000"]'Für jedes mögliche Byte im Datenstream?[/COLOR]       

      For i As Integer = 0 To _lookupTable.Length - 1


          [COLOR="#008000"]'temp stellt mit 0 initialisiertes 2 Byte Feld dar, korrekt? 

            'hier wird der CRC Wert von i berechnet?[/COLOR]   

           temp = 0


          [COLOR="#008000"]'Hier wird i einmal ganz nach links verschoben, wäre i also 255

            'Dann würde value so aussehen (1111111100000000)?[/COLOR]   

           value = CUShort(i << 8)


         [COLOR="#008000"]'Könnte jemand klügeres als ich ab hier mal für mich verständlich kommentieren? (idiotensicher )[/COLOR]      

         For j As Integer = 0 To 7               

         [COLOR="#FF0000"]                If ((temp Xor value) And &H8000) <> 0 Then

                    temp = CUShort((temp << 1) Xor GENERATORPOLYNOM)

                Else

                    temp <<= 1

                End If

                value <<= 1

            Next

            _lookupTable(i) = temp

        Next[/COLOR]


    End Sub

[/code]

Danke für eure Hilfe,

LG Jimbo

Bearbeitet von Jimbo0915

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.