Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW FEATURE] CRC_IBM #360

Open
Salem-Tho opened this issue Sep 7, 2022 · 0 comments
Open

[NEW FEATURE] CRC_IBM #360

Salem-Tho opened this issue Sep 7, 2022 · 0 comments
Assignees
Labels
advanced Advanced skills are needed for this subject

Comments

@Salem-Tho
Copy link
Member

Salem-Tho commented Sep 7, 2022

A CRC calculation on Luos can be change to correspond to standard CRC-16 ANSI / IBM

Actual Luos CRC

  • Width = 16 bits
  • Truncated polynomial = 0x0007
  • Initial value = 0xFFFF
  • Input data is NOT reflected
  • Output CRC is NOT reflected
  • No XOR is performed on the output CRC

CRC-16 ANSI / IBM

  • Width = 16 bits
  • Truncated polynomial = 0x8005
  • Initial value = 0x0000
  • Input data is reflected
  • Output CRC is reflected
  • No XOR is performed on the output CRC

code example:

`uint16_t crc16_ibm(char* data, unsigned int data_len)
{
uint16_t crc = 0;

if (data_len == 0)
    return 0;

for (unsigned int i = 0; i < data_len; ++i) {
    uint16_t dbyte = bit_reflect(data[i], 8);
    crc ^= dbyte << 8;
    
    for (unsigned char j = 0; j < 8; ++j) {
        uint16_t mix = crc & 0x8000;
        crc = (crc << 1);
        if (mix)
            crc = crc ^ 0x8005;
    }
}

return bit_reflect(crc, 16);

}`

@Salem-Tho Salem-Tho added the advanced Advanced skills are needed for this subject label Sep 7, 2022
@Salem-Tho Salem-Tho self-assigned this Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
advanced Advanced skills are needed for this subject
Projects
None yet
Development

No branches or pull requests

1 participant