8000 feature request: `update_bit()` · Issue #120 · mrhooray/crc-rs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
feature request: update_bit() #120
Open
@SebKuzminsky

Description

@SebKuzminsky

I need to checksum data that isn't an integer multiple of 8 bits in length.

I'm working on an interface library for a SPI device that uses CRC to validate frames on the SPI bus. The frames are made up of fields that don't start and end on byte boundaries.

Here's a diagram showing what i mean:
Screenshot from 2024-08-27 13-46-12

The microcontroller performs a SPI transfer of 6+n bytes. The first two bytes sent by the micro contain the command (zero-padded on the left). The next two bytes contain a 15-bit checksum of the command, with a 0 in the LSB.

The device receives the command and validates it with the checksum. If that passes it sends n bytes of data, followed by a two byte trailer consisting of 6 bits of "command count" and 10 bits of checksum covering the n payload bytes and the 6 bits of "command count".

As far as i can tell, there's not a way in crc-rs to compute a checksum that doesn't cover an integer number of bytes.

It's easy enough to implement my own amateurish crc code to do this, but it'd be nice if i could just use your awesome library.

I'd be happy to try to implement this in crc-rs if you think it'd be a useful addition.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0