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

CRC adding #101

Open
vandammeLPC opened this issue Jan 10, 2025 · 2 comments
Open

CRC adding #101

vandammeLPC opened this issue Jan 10, 2025 · 2 comments

Comments

@vandammeLPC
Copy link

Hello,

I am a beginner in this type of approach and I don't know if I am making my request in the right place.
Please excuse me if this is not the case.

I would like to know if it would be possible for you to add a CRC calculation method to the official Streamdevice distribution.
This calculation method is used in serial communication with Spellmann MPS HV supplies.

My checksum calculation function:

// Checksum used by Spellman High Voltage Supplies MPS
static uint32_t hv_mps(const uint8_t* data, size_t len, uint32_t sum)
{
    long int xsum;
    while (len--)
        {
        sum += *data++;
        }
    xsum = -(sum %256);
    sum = xsum & 0x7F;
    sum |= 0x40;
    return sum;
}
...
static checksum checksumMap[] =
..
    {"hv_mps",  hv_mps,           0x00,       0x00,       1}  // 0x63
..

Thank you in advance

@dirk-zimoch
Copy link
Member

Looks straight forward enough. Unless I find an unexpected problem with it, I will add it to the next release. I may change some implementation details, like: -(sum %256) & 0x7F | 0x40 = -(sum & 0xFF) & 0x7F | 0x40 = (-sum) & 0x7F | 0x40
Actually, the documentation asks for (-sum) & 0xFF & 0x7F | 0x40 = (-sum) & 0x7F | 0x40.

@vandammeLPC
Copy link
Author

Ok no worries for your implementation, as long as it works.
I have been using this method for several years now.
Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants