ethercrab-rs / ethercrab

EtherCAT master written in pure Rust
258 stars 24 forks source link

Fix FMMU and SM reset #241

Closed david-boles closed 1 month ago

david-boles commented 1 month ago

It appears that clearing all SMs and FMMUs on the Kistler 5074B with a single block write doesn't work: In the 6th and 8th packets in the attached "fails" capture you can see that the working counter is zero after attempting to write to Ado 0x600 and 0x800.

I noticed because it results in an incorrect FMMU length being configured, which then causes the subdevice to clobber the PDI with garbage: https://github.com/ethercrab-rs/ethercrab/blob/4ca739010d5a2899e38c4bf793df262d3d4e528b/src/subdevice/configuration.rs#L459-L460

I believe the lengths of the memory regions to blank were also wrong/off by one (16*16=256=0x100 for FMMUs, 16*8=128=0x80 for SMs).

Instead, I tried blanking each individually, and in the "succeeds" capture you can see that the first 8 SMs and 8 FMMUs are cleared successfully (working counter of 1); presumably the number of each that this device has. sm_and_fmmu_reset.zip