Network

class ingenialink.canopen.network.CAN_BAUDRATE(value)[source]

Baudrates.

Baudrate_100K = 100000

100 Kbit/s

Baudrate_125K = 125000

125 Kbit/s

Baudrate_1M = 1000000

1 Mbit/s

Baudrate_250K = 250000

250 Kbit/s

Baudrate_500K = 500000

500 Kbit/s

Baudrate_50K = 50000

50 Kbit/s

class ingenialink.canopen.network.CAN_DEVICE(value)[source]

CAN Device.

class ingenialink.canopen.network.CanopenNetwork(device: ingenialink.canopen.network.CAN_DEVICE, channel: int = 0, baudrate: ingenialink.canopen.network.CAN_BAUDRATE = <CAN_BAUDRATE.Baudrate_1M: 1000000>)[source]

Network of the CANopen communication.

Parameters
  • device – Targeted device to connect.

  • channel – Targeted channel number of the transceiver.

  • baudrate – Baudrate to communicate through.

change_baudrate(target_node: int, new_target_baudrate: ingenialink.canopen.network.CAN_BAUDRATE, vendor_id: int, product_code: int, rev_number: int, serial_number: int)None[source]

Changes the node ID of a given target node ID.

Note

The servo must be disconnected after this operation in order to make the changes visible and update all the internal data. It is also needed a power cycle of the servo otherwise the changes will not be applied.

Parameters
  • target_node – Node ID of the targeted device.

  • new_target_baudrate – New baudrate for the targeted device.

  • vendor_id – Vendor ID of the targeted device.

  • product_code – Product code of the targeted device.

  • rev_number – Revision number of the targeted device.

  • serial_number – Serial number of the targeted device.

change_node_id(target_node: int, new_target_node: int, vendor_id: int, product_code: int, rev_number: int, serial_number: int)None[source]

Changes the node ID of a given target node ID.

Note

The servo must be disconnected after this operation in order to make the changes visible and update all the internal data.

Parameters
  • target_node – Node ID of the targeted device.

  • new_target_node – New node ID for the targeted device.

  • vendor_id – Vendor ID of the targeted device.

  • product_code – Product code of the targeted device.

  • rev_number – Revision number of the targeted device.

  • serial_number – Serial number of the targeted device.

connect_to_slave(target: int, dictionary: str, servo_status_listener: bool = False, net_status_listener: bool = False)ingenialink.canopen.servo.CanopenServo[source]

Connects to a drive through a given target node ID.

Parameters
  • target – Targeted node ID to be connected.

  • dictionary – Path to the dictionary file.

  • servo_status_listener – Toggle the listener of the servo for its status, errors, faults, etc.

  • net_status_listener – Toggle the listener of the network status, connection and disconnection.

disconnect_from_slave(servo: ingenialink.canopen.servo.CanopenServo)None[source]

Disconnects the slave from the network.

Parameters

servo – Instance of the servo connected.

load_firmware(target: int, fw_file: str, callback_status_msg: Optional[Callable[[str], None]] = None, callback_progress: Optional[Callable[[int], None]] = None, callback_errors_enabled: Optional[Callable[[bool], None]] = None)None[source]

Loads a given firmware file to a target.

Warning

It is needed to disconnect the drive(disconnect_from_slave()) after loading the firmware since the Servo object’s data will become obsolete.

Parameters
  • target – Targeted node ID to be loaded.

  • fw_file – Path to the firmware file.

  • callback_status_msg – Subscribed callback function for the status message when loading a firmware.

  • callback_progress – Subscribed callback function for the live progress when loading a firmware.

  • callback_errors_enabled – Subscribed callback function for knowing when to toggle the error detection when loading firmware.

Raises
  • FileNotFoundError – Firmware file does not exist.

  • ILFirmwareLoadError – The firmware load process fails with an error message.

scan_slaves()List[int][source]

Scans for nodes in the network.

Returns

Containing all the detected node IDs.

start_status_listener()None[source]

Start monitoring network events (CONNECTION/DISCONNECTION).

stop_status_listener()None[source]

Stops the NetStatusListener from listening to the drive.

subscribe_to_status(node_id: int, callback: Callable[[ingenialink.network.NET_DEV_EVT], Any])None[source]

Subscribe to network state changes.

Parameters
  • node_id – Drive’s node ID.

  • callback – Callback function.

unsubscribe_from_status(node_id: int, callback: Callable[[ingenialink.network.NET_DEV_EVT], Any])None[source]

Unsubscribe from network state changes.

Parameters
  • node_id – Drive’s node ID.

  • callback – Callback function.

property baudrate

Current baudrate of the network.

property channel

Current channel of the network.

property device

Current device of the network.

property network

Returns the instance of the CANopen Network.

property protocol

Obtain network protocol.

class ingenialink.canopen.network.NetStatusListener(network: ingenialink.canopen.network.CanopenNetwork)[source]

Network status listener thread to check if the drive is alive.

Parameters

network – Network instance of the CANopen communication.

run()None[source]

Method representing the thread’s activity.

You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.