CdefSlave
- class pysoem.CdefSlave
Represents a slave device
Do not use this class in application code. Instances are created by a Master instance on a successful config_init(). They then can be obtained by slaves list
- add_emergency_callback(callback)
Get notified on EMCY messages from this slave.
- Parameters:
callback – Callable which must take one argument of an
Emergencyinstance.
- amend_mbx(mailbox, start_address, size)
Change the start address and size of a mailbox.
Note that the slave must me in INIT state to do that.
- Parameters:
Added in version 1.0.6.
- property config_func
Slaves callback function that is called during config_map.
When the state changes from Pre-Operational state to Operational state.
- dc_sync(act, sync0_cycle_time, sync0_shift_time=0, sync1_cycle_time=None)
Activate or deactivate SYNC pulses at the slave.
- Parameters:
act (bool) – True = active, False = deactivate
sync0_cycle_time (int) – Cycltime SYNC0 in ns
sync0_shift_time (int) – Optional SYNC0 shift time in ns
sync1_cycle_time (int) – Optional cycltime for SYNC1 in ns. This time is a delta time in relation to SYNC0. If CylcTime1 = 0 then SYNC1 fires at the same time as SYNC0.
- eeprom_read(word_address, timeout=20000)
Read 4 byte from EEPROM
Default timeout: 20000 us
- eeprom_write(word_address, data, timeout=20000)
Write 2 byte (1 word) to EEPROM
Default timeout: 20000 us
- Parameters:
- Raises:
EepromError – if write fails
AttributeError – if data size is not 2
- foe_read(filename, password, size, timeout=200000, *, release_gil=None)
Read given filename from device using FoE
- foe_write(filename, password, data, timeout=200000, *, release_gil=None)
Write given data to device using FoE
- get_max_watchdog_time()
Get the maximum watchdog timeout.
- Returns:
The maximum watchdog timeout in ms.
- Return type:
- get_watchdog(wd_type)
Get the watchdog time of the PDI or Process Data watchdog.
- property id
Product Code of the slave, read out from the slaves SII during config_init.
- property man
Vendor ID of the slave, read out from the slaves SII during config_init.
- mbx_receive()
Read out the slaves out mailbox - to check for emergency messages.
Added in version 1.0.4.
- Returns:
Work counter
- Return type:
- Raises:
Emergency – if an emergency message was received
- property name
Name of the slave, read out from the slaves SII during config_init.
- reconfig(timeout=500)
Reconfigure slave.
- Parameters:
timeout – local timeout
- Returns:
Slave state
- Return type:
- recover(timeout=500)
Recover slave.
- Parameters:
timeout – local timeout
- Returns:
>0 if successful
- Return type:
- property rev
Revision Number of the slave, read out from the slaves SII during config_init.
- sdo_read(index, subindex, size=0, ca=False, *, release_gil=None)
Read a CoE object.
When leaving out the size parameter, objects up to 256 bytes can be read. If the size of the object is expected to be bigger, increase the size parameter.
- Parameters:
- Returns:
The content of the sdo object.
- Return type:
- Raises:
SdoError – if write fails, the exception includes the SDO abort code
MailboxError – on errors in the mailbox protocol
PacketError – on packet level error
WkcError – if working counter is not higher than 0, the exception includes the working counter
- sdo_write(index, subindex, data, ca=False, *, release_gil=None)
Write to a CoE object.
- Parameters:
- Raises:
SdoError – if write fails, the exception includes the SDO abort code
MailboxError – on errors in the mailbox protocol
PacketError – on packet level error
WkcError – if working counter is not higher than 0, the exception includes the working counter
- set_watchdog(wd_type, wd_time_ms)
Change the watchdog time of the PDI or Process Data watchdog.
Warning
This is experimental.
- Parameters:
At the default watchdog time divider the precision is 0.1 ms.
Added in version 1.0.6.
- property setup_func
Alternative callback function that is called during config_map.
More precisely the function is called during the transition from Pre-Operational to Safe-Operational state. Use this instead of the config_func. The difference is that the callbacks signature is fn(CdefSlave: slave).
Added in version 1.1.0.
- property state
Request a new state.
After a new state has been set, write_state must be called.
- state_check(expected_state, timeout=2000)
Wait for the slave to reach the state that was requested.
- write_state()
Write slave state.
Note: The function does not check if the actual state is changed.