Skip to content

SrdoCrc Class

The safety configuration checksum of object 13FFh (CiA DSP 304 V1.0 §8.4.2.2; EN 50325-5:2010 §6.4.1.5, Table 9). Both texts give the generator polynomial x^16 + x^12 + x^5 + 1 and the order of the fields; EN 50325-5 adds the seed 0000h, and its formula (2) lists a multi-byte field low byte first (b7..0, then b15..8), each byte from its bit 7 down. This implementation uses CRC-16/XMODEM (initial value 0000h, no reflection, no final XOR — the algorithm CiA 301 §7.2.4.3.16 prescribes for the SDO block transfer) and feeds multi-byte fields little-endian, the CANopen byte image, as CANopenNode's CO_SRDOcalcCrc does (#289).

public static class SrdoCrc

Inheritance Object → SrdoCrc

Methods

SrdoCrc.Compute(SrdoCommunicationParameter, SrdoMapping) Method

The checksum the device compares at the transition to Operational and the tool writes to 13FFh:n (§8.3.1 step D, §9.2). The times go in as whole milliseconds, rounded half to even (Math.Round(Double)), and must fit their fields after rounding: the refresh time or SCT 0..65535 ms (UNSIGNED16), the SRVT 0..255 ms (UNSIGNED8). 0 is accepted — the device path checksums what its dictionary holds, and the dictionary refuses 0 itself.

public static ushort Compute(in CanKit.Pro.CANopen.Safety.SrdoCommunicationParameter parameter, CanKit.Pro.CANopen.Safety.SrdoMapping mapping);

Parameters

parameter SrdoCommunicationParameter

mapping SrdoMapping

Returns

UInt16

Exceptions

ArgumentOutOfRangeException
A time is negative or does not fit its field after rounding, or the direction is above 2 (§8.4.2.2).

ArgumentNullException
mapping is null.

SrdoCrc.Crc16Xmodem(ReadOnlySpan<byte>) Method

CRC-16/XMODEM: poly 1021h, init 0000h, no reflection, no xor-out. Check value of "123456789" is 31C3h.

public static ushort Crc16Xmodem(System.ReadOnlySpan<byte> data);

Parameters

data ReadOnlySpan<Byte>

Returns

UInt16