EmcyMessage Class¶
A structured CANopen Emergency (EMCY) message, per CiA 301 §7.2.7.3.
Inheritance Object → EmcyMessage
Remarks¶
The wire encoding is fixed at 8 bytes:
- Bytes 0..1 — ErrorCode (little-endian).
- Byte 2 — ErrorRegister, mirror of OD 0x1001.
- Bytes 3..7 — manufacturer-specific error field (5 bytes).
The special error code 0x0000 is the "error reset / no error" indicator described in
CiA 301 §7.2.7.3.1 — clients should treat it as an EMCY event just like non-zero codes and
let higher layers decide how to react.
Constructors¶
EmcyMessage(byte, ushort, byte, ReadOnlySpan<byte>) Constructor¶
Constructs a new EMCY message. manufacturerSpecific must be zero to five bytes long; missing bytes are treated as zero.
public EmcyMessage(byte producerNodeId, ushort errorCode, byte errorRegister, System.ReadOnlySpan<byte> manufacturerSpecific=default(System.ReadOnlySpan<byte>));
Parameters¶
producerNodeId Byte
errorCode UInt16
errorRegister Byte
manufacturerSpecific ReadOnlySpan<Byte>
Fields¶
EmcyMessage.ManufacturerFieldLength Field¶
Length of the manufacturer-specific field.
Field Value¶
EmcyMessage.WireSize Field¶
Fixed on-wire size of an EMCY frame.
Field Value¶
Properties¶
EmcyMessage.ErrorCode Property¶
Standardized error code (CiA 301 §7.2.7.3.1 Table 26).
Property Value¶
EmcyMessage.ErrorRegister Property¶
Content of the error register at the moment the EMCY was raised (mirror of OD
0x1001).
Property Value¶
EmcyMessage.ManufacturerSpecific Property¶
Manufacturer-specific 5-byte error field (may be shorter for tests; padded on encode).
Property Value¶
EmcyMessage.ProducerNodeId Property¶
Node-id of the emergency producer (derived from COB-ID 0x080 + node-id).
Zero when the frame does not carry a node association (i.e. anonymous EMCY on a bus
scanner).
Property Value¶
Methods¶
EmcyMessage.Decode(byte, ReadOnlySpan<byte>) Method¶
Decodes an EMCY frame's payload. producerNodeId is derived
from the COB-ID by the caller (cob-id - 0x080).
public static CanKit.Pro.CANopen.Emcy.EmcyMessage Decode(byte producerNodeId, System.ReadOnlySpan<byte> data);
Parameters¶
producerNodeId Byte
data ReadOnlySpan<Byte>
Returns¶
EmcyMessage.Encode() Method¶
Encodes the message into an 8-byte wire frame; the manufacturer-specific field is zero-padded to 5 bytes.