Network

class ingenialink.eoe.network.EoECommand(value)[source]

EoE command enum.

class ingenialink.eoe.network.EoENetwork(ifname: str, connection_timeout: float = 1)[source]

Network for EoE (Ethernet over EtherCAT) communication.

Parameters:
  • ifname – Network interface name.

  • connection_timeout – Time in seconds of the connection timeout to the EoE service.

static close_socket(sock: socket) None

Closes the established network socket.

connect_to_slave(slave_id: int, ip_address: str, dictionary: str, port: int = 1061, connection_timeout: float = 1, servo_status_listener: bool = False, net_status_listener: bool = False, disconnect_callback: Callable[[Servo], None] | None = None) EthernetServo[source]

Connects to a slave through the given network settings.

Parameters:
  • slave_id – EtherCAT slave ID.

  • ip_address – IP address to be assigned to the slave.

  • dictionary – Path to the target dictionary file.

  • port – Port to connect to the slave.

  • connection_timeout – Time in seconds of the connection timeout.

  • 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:

ValueError – ip_address must be a subnetwork of 192.168.3.0/24.

Returns:

Instance of the servo connected.

Return type:

EthernetServo

disconnect_from_slave(servo: EthernetServo) None[source]

Disconnects the slave from the network.

Parameters:

servo – Instance of the servo connected.

get_servo_state(servo_id: int | str) NetState

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 IP address.

Raises:

ValueError – if the servo ID is not a string.

Returns:

The servo’s state.

scan_slaves() list[int][source]

Scan slaves connected to the network adapter.

Returns:

List containing the ids of the connected slaves.

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

Scans for drives in the network.

Returns:

Detected drives with their information.

start_status_listener() None

Start monitoring network events (CONNECTION/DISCONNECTION).

stop_status_listener() None

Stops the NetStatusListener from listening to the drive.

subscribe_to_status(ip: str, callback: Callable[[NetDevEvt], Any]) None

Subscribe to network state changes.

Parameters:
  • ip – IP of the drive to subscribe.

  • callback – Callback function.

unsubscribe_from_status(ip: str, callback: Callable[[NetDevEvt], Any]) None

Unsubscribe from network state changes.

Parameters:
  • ip – IP of the drive to unsubscribe.

  • callback – Callback function.

property protocol: NetProt

Obtain network protocol.

servos: list[Any]

List of the connected servos in the network.