Giter Site home page Giter Site logo

riologiuseppe / crc-full Goto Github PK

View Code? Open in Web Editor NEW
23.0 2.0 9.0 20 KB

The crc-full module is used to calculate any kind of CRC setting parameters such as length, polynomial and others. It's completely written in typescript for node js.

TypeScript 100.00%
crc crc-calculation crc-16 crc-32 crc-8 crc-nodejs crc-ts crc-js crc-polinomial crc-custom

crc-full's People

Contributors

riologiuseppe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

crc-full's Issues

[CRC32_C] Compute result is negative value

For example:

// for (0-100 hex)
let data = '0102030405060708090A0B0C0D0E0F101112131415161718191A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132333435363738393A3B3C3D3E3F404142434445464748494A4B4C4D4E4F505152535455565758595A5B5C5D5E5F6061626364';
let buf = Buffer.from(data, 'hex'); 
let crc = CRC.default("CRC32_C");
let computed_crc = crc.compute(source);
// output is: -5DA0519C

But for correct value should be 0xA25FAE64, you can test in website 'http://crccalc.com/' with the same data and 'hex' option selected.

Pls help to check it.

Match CRC from C code to crc-full

Hello,

I have to send a message from typescript to our device and at the device side, it validates the message using a CRC16.

Here is how the device validates it:

#define CRC_MASK 0x1021 /* x^16 + x^12 + x^5 + x^0 */

UINT16 CRC_Calc (unsigned char *pbData, int iLength)
{
    UINT16 wData, wCRC = 0;
    int i;

    for ( ;iLength > 0; iLength--, pbData++) {
        wData = (UINT16) (((UINT16) *pbData) << 8);
        for (i = 0; i < 8; i++, wData <<= 1) {
            if ((wCRC ^ wData) & 0x8000)
                wCRC = (UINT16) ((wCRC << 1) ^ CRC_MASK);
            else
                wCRC <<= 1;
        }
    }
    return wCRC;
}

The input data would be "OPN\x17" (where \x17 is an ETB control character). The output must be A8A9.

Given that input data, the C sample code, can you provide me a sample code using your package to achieve the same result?

Thank you! I appreciate any help.

Best regards,
Gutemberg

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.