CanOpenNodeOptions Class¶
Runtime configuration for a CanOpenNode. All values are captured at construction time and treated as immutable for the node's lifetime; use With(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<int>, Nullable<int>, Nullable<int>, Nullable<byte>, Nullable<bool>, Nullable<int>, Nullable<bool>, Nullable<bool>) to derive a modified template for tests.
Inheritance Object → CanOpenNodeOptions
Remarks¶
The SDO client timeout defaults to one second, which matches the widely-used CANopen master libraries (canopen.py, CANopenNode host tools). The heartbeat and SYNC producers are off by default — enable them explicitly through the node's public API when needed.
Properties¶
CanOpenNodeOptions.DefaultTpdoEventTimerInterval Property¶
Interval used by the built-in TPDO event-timer scheduler for TPDOs configured
with TpdoTransmission.EventTimer. May be overridden per-PDO at configuration time.
Property Value¶
CanOpenNodeOptions.EnableChangeOfStateTpdo Property¶
When true (default), a local application write to an OD entry that is mapped in an
event-driven TPDO (EventDriven) automatically emits
that TPDO — change-of-state triggering per FR-CO-006 / CiA 301 §7.3.6, without the
application having to call TriggerTpdoAsync manually. Only application-originated
writes count: bus-originated writes (SDO server download commit, RPDO unpack) run on the
node's actor thread and never re-trigger TPDOs, so no bus echo loops can form. Set to
false to restore the pure manual-trigger behavior.
Property Value¶
CanOpenNodeOptions.EventQueueCapacity Property¶
Bounded capacity of the outbound event dispatch queue that feeds CanOpenNode.HeartbeatReceived / CanOpenNode.HeartbeatTimeout / CanOpenNode.EmcyReceived / CanOpenNode.SyncReceived / CanOpenNode.RpdoReceived / CanOpenNode.NmtCommandReceived subscribers. The node uses a bounded System.Threading.Channels.Channel<> with drop-oldest semantics: when a subscriber cannot keep up, the queue silently discards the oldest pending events so it never grows past this bound and the actor loop is never blocked by a slow handler. Defaults to 64. CanOpenNode.BackgroundExceptionOccurred is dispatched synchronously and is not subject to this bound — it is a low-frequency diagnostic signal that must not be silently dropped by queue backpressure.
Property Value¶
CanOpenNodeOptions.MaxSdoTransferBytes Property¶
Upper bound (in bytes) on the total payload of a single segmented SDO transfer, applied
both to server-side segmented downloads (initiator's declared 32-bit length) and to
client-side segmented upload responses (server's declared 32-bit length). Bounds a
hostile / buggy peer's ability to drive us into an unbounded new byte[declaredLen]
allocation: any initiate declaring more than this many bytes is aborted with the CiA 301
"out of memory" SDO abort code (0x05040005) rather than being honored. Fixed-width OD
entries are additionally capped to their declared size at the type-check layer above;
this limit only matters for Domain payloads (and for the
client's upload path where the OD type is not yet known). Defaults to 1 MiB, which is
well above any realistic CiA-301 profile payload but small enough to reject an accidental
or malicious 4 GiB initiate outright.
Property Value¶
CanOpenNodeOptions.RespondToNodeGuardingRtr Property¶
When true this node answers a Node-Guarding RTR (COB-ID 0x700 + own node-id)
with a one-byte data frame carrying the current NMT state (bits 0..6) and an alternating
toggle bit (bit 7), per CiA 301 §7.2.8.3.3. Ignored when the heartbeat producer is active
(CiA 301 §7.2.8.3 makes heartbeat and node-guarding mutually exclusive on the same node).
Defaults to true so slaves are answered out of the box.
Property Value¶
CanOpenNodeOptions.SdoBlockCrcSupported Property¶
When true this node advertises CRC-16/XMODEM support on block-transfer initiates
(cc / sc bit) and both computes and validates the CRC on the end-of-block frame. The peer
must also set its CRC bit for the CRC to be exchanged (per CiA 301 §7.2.4.3.15 the CRC is
only carried when both endpoints advertise support). Defaults to true.
Property Value¶
CanOpenNodeOptions.SdoBlockMaxRetransmissions Property¶
Maximum number of sub-block retransmissions per block transfer before the node aborts
(CiA 301 §7.2.4.3.15): on a partial sub-block ACK (ackseq < segments sent) the sender
rewinds to the first unconfirmed segment and resends, up to this many times per transfer
— a bound against peers that never confirm progress. Applies to the download client and
the upload server alike. 0 restores the previous MVP behavior (abort on the first
partial ACK). Defaults to 3.
Property Value¶
CanOpenNodeOptions.SdoBlockSize Property¶
Preferred block size (segments per sub-block, 1..127) that this node advertises when it acts as a block-transfer receiver (server for download, client for upload). CiA 301 §7.2.4.3.15 permits the receiver to choose any value in [1,127]; peers with a smaller window will re-negotiate downward via their own initiate. Defaults to 127.
Property Value¶
CanOpenNodeOptions.SdoBlockThresholdBytes Property¶
Auto-select threshold (bytes) at or above which the SDO client uses block transfer (FR-CO-004 / CiA 301 §7.2.4.3.15) for an Auto download instead of the segmented protocol. Below the threshold the payload length picks the codec: expedited for 1..4 bytes, segmented above that. Uploads never auto-switch to block because the length is unknown until the server replies; callers can bypass the threshold in either direction by explicitly passing Block. Defaults to 128 bytes.
Property Value¶
CanOpenNodeOptions.SdoServerTimeout Property¶
Server-side SDO session timeout: how long an open segmented server transfer (download or upload) may idle without the peer sending the next segment / segment-ack before the session is torn down and an SDO abort (SdoProtocolTimedOut) is emitted. Prevents a client that starts a segmented transfer and then goes silent from pinning the server's single session slot forever (the block-transfer server side already had this guard; CiA 301 leaves the concrete value to the implementation). Deliberately longer than SdoTimeout so a well-behaved client always times out first. Defaults to 5 s.
Property Value¶
CanOpenNodeOptions.SdoTimeout Property¶
Client-side SDO transfer timeout, applied to every request (initiate as well as each segment ack). CiA 301 does not specify a fixed value; one second matches common production tooling and is aggressive enough for tests on a virtual bus.
Property Value¶
Methods¶
CanOpenNodeOptions.With(Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<TimeSpan>, Nullable<int>, Nullable<int>, Nullable<int>, Nullable<byte>, Nullable<bool>, Nullable<int>, Nullable<bool>, Nullable<bool>) Method¶
Returns a copy of this options record with the provided overrides.
public CanKit.Pro.CANopen.CanOpenNodeOptions With(System.Nullable<System.TimeSpan> sdoTimeout=null, System.Nullable<System.TimeSpan> sdoServerTimeout=null, System.Nullable<System.TimeSpan> defaultTpdoEventTimerInterval=null, System.Nullable<int> eventQueueCapacity=null, System.Nullable<int> maxSdoTransferBytes=null, System.Nullable<int> sdoBlockThresholdBytes=null, System.Nullable<byte> sdoBlockSize=null, System.Nullable<bool> sdoBlockCrcSupported=null, System.Nullable<int> sdoBlockMaxRetransmissions=null, System.Nullable<bool> respondToNodeGuardingRtr=null, System.Nullable<bool> enableChangeOfStateTpdo=null);
Parameters¶
sdoServerTimeout Nullable<TimeSpan>
defaultTpdoEventTimerInterval Nullable<TimeSpan>
eventQueueCapacity Nullable<Int32>
maxSdoTransferBytes Nullable<Int32>
sdoBlockThresholdBytes Nullable<Int32>
sdoBlockCrcSupported Nullable<Boolean>
sdoBlockMaxRetransmissions Nullable<Int32>
respondToNodeGuardingRtr Nullable<Boolean>
enableChangeOfStateTpdo Nullable<Boolean>