Emergency Object (EMCY)

Emergency messages are triggered by the occurrence of a device internal fatal error situation and are transmitted from the concerned application device to the other devices with high priority. This makes them suitable for interrupt type error alerts. An Emergency Telegram may be sent only once per ‘error event’, i.e. the emergency messages must not be repeated. As long as no new errors occur on a device no further emergency message must be sent. By means of CANopen Communication Profile defined emergency error codes, the error register and device specific additional information are specified in the device profiles.

Examples

To list the currently active emergencies for a particular node, one can use the .active attribute which is a list of canopen.emcy.EmcyError objects:

active_codes = [emcy.code for emcy in node.emcy.active]
all_codes = [emcy.code for emcy in node.emcy.log]

The canopen.emcy.EmcyError objects are actually exceptions so that they can be easily raised if that’s what you want:

if node.emcy.active:
    raise node.emcy.active[-1]

API

class canopen.emcy.EmcyConsumer[source]
active: List[EmcyError]

Only active EMCYs. Will be cleared on Error Reset

add_callback(callback)[source]

Get notified on EMCY messages from this node.

Parameters:

callback (Callable[[EmcyError], None]) – Callable which must take one argument of an EmcyError instance.

log: List[EmcyError]

Log of all received EMCYs for this node

reset()[source]

Reset log and active lists.

wait(emcy_code=None, timeout=10)[source]

Wait for a new EMCY to arrive.

Parameters:
  • emcy_code (Optional[int]) – EMCY code to wait for

  • timeout (float) – Max time in seconds to wait

Return type:

EmcyError

Returns:

The EMCY exception object or None if timeout

exception canopen.emcy.EmcyError(code, register, data, timestamp)[source]

EMCY exception.

code

EMCY code

data

Vendor specific data

register

Error register

timestamp

Timestamp of message