OpenEtherCATsociety / SOEM

Simple Open Source EtherCAT Master
Other
1.36k stars 688 forks source link

SyncManager of slave not activated by data from EEPROM #246

Closed EKEyeC closed 5 years ago

EKEyeC commented 5 years ago

Hi SOEM devs,

I've got a slave here which does not change from PREOP to SAFEOP in the slave_info program. Actually, it is the device which was mentioned with the same issue in #94 already.

I've tracked the problem down to the following: the SII EEPROM of the slave contains this information for the SyncManagers:

SM0 A:1000 L: 512 F:00010026 Type:1
SM1 A:1400 L: 512 F:00010022 Type:2
SM2 A:1800 L:   0 F:00000064 Type:3
SM3 A:2400 L:   0 F:00000020 Type:4

For SM2 and SM3, the length is zero and the "Activate" flag is false. The length becomes calculated by SOEM in function ecx_readPDOmap/ecx_readPDOmapCA. If I also set the EC_SMENABLEMASK flag bit in these two functions where the length is set, the slave also changes to SAFEOP in slave_info (and OP in simple_test).

Now my question is whether this is a fault of the slave (i.e. should the "Activate" flag for these SMs be set in the EEPROM, even though the length is zero because it's impossible to write a proper length into the EEPROM because that depends on the number of attached modular devices) or if SOEM should activate SM2 and SM3 by default when it determines it's length? In the latter case, is this something which can be done for all slaves which have SM2 and SM3 or should this rather be done by a custom PO2SOconfig hook just for this slave device?

Thanks for your input on this issue! If I should provide any more information, please let me know.

ArthurKetels commented 5 years ago

There could be a long argument if the data provided by the slave is valid according to the EtherCAT SII specifications but I guess that is kind of pointless. A trivial fix is merged in SOEM that sets the enable bit of a SM when the length is non zero. Please pull and try.

EKEyeC commented 5 years ago

Thanks for your answer. Fix works as expected!