Master
- class pysoem.Master
Representing a logical EtherCAT master device.
For each network interface you can have a Master instance.
- slaves
Gets a list of the slaves found during config_init. The slave instances are of type
CdefSlave.
- sdo_read_timeout
timeout for SDO read access for all slaves connected
- sdo_write_timeout
timeout for SDO write access for all slaves connected
- always_release_gil
true to always release the GIL
- check_release_gil(release_gil)
Checks if the GIL should be released.
- Parameters:
release_gil (boolean) – True if the GIL should be released, False otherwise.
- close()
Close the network interface.
Signals that no new operations should start and waits for any in-flight operations to complete before closing. Uses a timeout of 5 seconds; logs a warning if timeout occurs.
- config_dc()
Locate DC slaves, measure propagation delays.
- Returns:
if slaves are found with DC
- Return type:
- config_init(usetable=False, *, release_gil=None)
Enumerate and init all slaves.
- Parameters:
- Returns:
Working counter of slave discover datagram = number of slaves found, -1 when no slave is connected
- Return type:
- config_map()
Map all slaves PDOs in IO map.
- Returns:
IO map size (sum of all PDO in an out data)
- Return type:
- config_overlap_map()
Map all slaves PDOs to overlapping IO map.
- Returns:
IO map size (sum of all PDO in an out data)
- Return type:
- property dc_time
DC time in ns required to synchronize the EtherCAT cycle with SYNC0 cycles.
Note EtherCAT cycle here means the call of send_processdata and receive_processdata.
- property expected_wkc
Calculates the expected Working Counter
- open(ifname, ifname_red=None)
Initialize and open network interface.
On Linux the name of the interface is the same as usd by the system, e.g.
eth0, and as displayed byip addr.On Windows the names of the interfaces look like
\Device\NPF_{1D123456-1E12-1C12-12F1-1234E123453B}. Finding the kind of name that SOEM expects is not straightforward. The most practical way is to use thefind_adapters()method to find your available interfaces.- Parameters:
- Raises:
ConnectionError – When the specified interface dose not exist or you have no permission to open the interface
- receive_processdata(timeout=2000, *, release_gil=None)
Receive processdata from slaves.
Second part from send_processdata(). Received datagrams are recombined with the processdata with help from the stack. If a datagram contains input processdata it copies it to the processdata structure.
- Parameters:
- Returns
int: Working Counter
- send_overlap_processdata(*, release_gil=None)
Transmit overlap processdata to slaves.
- Returns:
>0 if processdata is transmitted, might only by 0 if config map is not configured properly
- Return type:
- send_processdata(*, release_gil=None)
Transmit processdata to slaves.
Uses LRW, or LRD/LWR if LRW is not allowed (blockLRW). Both the input and output processdata are transmitted. The outputs with the actual data, the inputs have a placeholder. The inputs are gathered with the receive processdata function. In contrast to the base LRW function this function is non-blocking. If the processdata does not fit in one datagram, multiple are used. In order to recombine the slave response, a stack is used.
- property state
Can be used to check if all slaves are in Operational state, or to request a new state for all slaves.
Make sure to call write_state(), once a new state for all slaves was set.
- state_check(expected_state, timeout=50000)
Check actual slave state.
This is a blocking function. To refresh the state of all slaves read_state() should be called