아래가 정확하게 맞는건진 모르겠지만..

비슷하면서도 초기값과 xor 값 그리고 비트 시프트 하는 것이 전혀 다르다.

 

uint16_t crc16_ccitt_false(char* pData, int length)
{
    int i;
    uint16_t wCrc = 0xffff;
    while (length--) {
        wCrc ^= *(unsigned char *)pData++ << 8;
        for (i=0; i < 8; i++)
            wCrc = wCrc & 0x8000 ? (wCrc << 1) ^ 0x1021 : wCrc << 1;
    }
    return wCrc;
}

uint16_t crc16_x25(char* pData, int length)
{
    int i;
    uint16_t wCrc = 0xffff;
    while (length--) {
        wCrc ^= *(unsigned char *)pData++ << 0;
        for (i=0; i < 8; i++)
            wCrc = wCrc & 0x0001 ? (wCrc >> 1) ^ 0x8408 : wCrc >> 1;
    }
    return wCrc ^ 0xffff;
}

[링크 : https://stackoverflow.com/.../58768018/what-is-the-difference-between-crc-16-ccitt-false-and-crc-16-x-25]

'이론 관련 > 네트워크 관련' 카테고리의 다른 글

nrz encoding/decoding  (0) 2022.08.24
광 케이블 DAC, AOC  (0) 2022.06.30
RS485 오실로스코프 파형  (0) 2021.11.04
EtherCAT - Ethernet for Control Automation Technology  (0) 2021.11.01
WiFi 프로토콜, cipher  (0) 2021.09.27
Posted by 구차니