Network

class ingenialink.canopen.network.CanBaudrate(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.CanDevice(value)[source]

CAN Device.

class ingenialink.canopen.network.CanopenNetwork(device: CanDevice, channel: int = 0, baudrate: CanBaudrate = CanBaudrate.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: CanBaudrate, 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.

Raises:
  • ValueError – if the CAN connection has not been established yet.

  • ILError – if there is an error switching lss to selective state.

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.

Raises:
  • ValueError – if the CAN connection has not been established yet.

  • ILError – if there is an error switching lss to selective state.

connect_to_slave(target: int, dictionary: str, servo_status_listener: bool = False, net_status_listener: bool = False, disconnect_callback: Callable[[Servo], None] | None = None) 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_callback – Callback function to be called when the servo is disconnected. If not specified, no callback will be called.

Raises:
  • ILError – if there aren’t nodes in the network.

  • ILError – if the connection is not established.

  • ILError – if the connection fails.

  • ILError – if the node id is not found in the network.

Returns:

canopen servo.

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) NetState[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.

Raises:

ValueError – it the servo id is not an integer.

Returns:

The servo’s state.

is_listener_started() bool[source]

Check if the listener has been started.

Returns:

true if the listener has been started, False otherwise.

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:

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

scan_slaves() list[int][source]

Scans for nodes in the network.

Raises:

ILError – if the transceiver is not detected.

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[[NetDevEvt], 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[[NetDevEvt], 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: NetProt

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]

Check the network status.

stop() None[source]

Stop the listener.