Add bit-aligned / sub-byte PDO entry support to the emulator#375
Add bit-aligned / sub-byte PDO entry support to the emulator#375leducp wants to merge 2 commits into
Conversation
|
ping @phamnhatha090805 this PR should enable bit support for the emulator and the stack in general |
|
!!! Need proper testing before merge !!! |
|
Minimum allowed coverage is Generated by 🐒 cobertura-action against f55d29f |
|
I have tested this on my side. However, there's still same Invalid SM cfg error. Also, if I simulate the official Beckhoff EL1002 which is only 2 inputs (each is 1 BIT), and the thing works without any errors. |
Thanks for the feedback! I'll do a pass to try to understand why :) |
|
OK so I may have found the bug: I didn't handle the padding properly (that's the difference I saw between EL1002 and EL1004). Can you give it a shot? If it fail again, I propose that you give me the setup that fail and the setup that works so I can try to test on my side properly (even if I don't have TwinCAT) |
|
ping @phamnhatha090805 can you test again please. Thank you for your help and contributions, your insights are super helpful |
I run the test again and now the custom EtherCAT device got stuck in SAFEOP. Also, I enable the |
You can play with theses options:
Enabling all of theses should give us a better understanding of what's happening :) |
Lets the emulator host slaves that declare sub-byte PDO entries (e.g.
4 BOOL GPIOs at <BitLen>1</BitLen>):
- EmulatedESC honors FMMU logical/physical bit offsets via a per-bit
slow path; byte-aligned mappings keep the memcpy fast path.
FMMUs targeting addresses < 0x1000 (e.g. mailbox-status) now work.
- CoE::Entry gains data_bit_offset; addEntry/EsiParser allocate
(bitlen+7)/8 bytes (was 0 for BOOL/BIT2..7). New copyBits /
read/writeEntryBits helpers.
- SDO upload/download/complete-access switched to bit-accurate
payload positioning. Sub-byte entries travel as 1 octet per
ETG1000.5 §5.3.1; CA packs entries by bitoff per ETG2000.
- EsiParser: match Object/Info/SubItem to DataType/SubItem by Name
(ETG2000 4807). For ARRAY types, DataType elements have no per-item
Name, so Info/SubItem/Name is "SubIndex NNN" — fall back to parsing
the trailing subindex.
- PDO and SDO: null-guard entry->data. Missing <DefaultData> is legal (ETG2000 4797)
|
@phamnhatha090805 can you redo a try with the last version? I managed to reproduce something similar with the emulator (stuck in safeop). I introduced a regression in the ESI parser for the ARRAY type by fixing the RECORD type (I though they were handled the same but it is not). |
|
I don't know why but my thing still stuck in the SAFEOP. But anyway, I want to finish the ESI improvement first and make pull request before diving into this bit_support |
|
@leducp what do we do with this PR? Wait for the esi parser rework? or this is functional and we merge? |
|
I think it is better to properly rework the ESI parser first, then address bit support in the stack. Switch it to draft |
Lets the emulator host slaves that declare sub-byte PDO entries (e.g.
4 BOOL GPIOs at 1):