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: CAN_DEVICE, channel: int = 0, baudrate: CAN_BAUDRATE = CAN_BAUDRATE.Baudrate_1M)[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: 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) 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: CanopenServo) None[source]

Disconnects the slave from the network.

Parameters:

servo – Instance of the servo connected.

get_available_devices() List[Tuple[str, str | int]][source]

Get the available CAN devices and their channels

Returns:

List of tuples with device name and channel

get_servo_state(servo_id: int | str) NET_STATE[source]

Get the state of a servo that’s a part of network. The state indicates if the servo is connected or disconnected.

Parameters:

servo_id – The servo’s node ID.

Returns:

The servo’s state.

load_firmware(target: int, fw_file: str, callback_status_msg: Callable[[str], None] | None = None, callback_progress: Callable[[int], None] | None = None, callback_errors_enabled: Callable[[bool], None] | 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.

scan_slaves_info() OrderedDict[int, SlaveInfo][source]

Scans for nodes in the network and return an ordered dict with the slave information.

Returns:

Ordered dict with the slave information.

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[[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[[NET_DEV_EVT], Any]) None[source]

Unsubscribe from network state changes.

Parameters:
  • node_id – Drive’s node ID.

  • callback – Callback function.

property baudrate: int

Current baudrate of the network.

property channel: int | str

Current channel of the network.

property device: str

Current device of the network.

property network: Network

Returns the instance of the CANopen Network.

property protocol: NET_PROT

Obtain network protocol.

servos: List[CanopenServo]

List of the connected servos in the network.

class ingenialink.canopen.network.NetStatusListener(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.