fix single device inputs/outputs overruning segment size#907
fix single device inputs/outputs overruning segment size#907nakarlsson merged 5 commits intoOpenEtherCATsociety:masterfrom
Conversation
|
I believe this also fixes #243 |
|
I sent in my contributors agreement on April 11th, what else do I need to do to have this reviewed? |
|
Can you provide the config to trigger this? A slaveinfo output would do |
|
Output from slave device with output larger than one segment. Device has modular profile that can be quite large. |
|
I just noticed that with this large config the actual wkc returned is 4 instead of 3. The expected wkc is still calculated as 3. Looking through spec docs now to see if there is any mention about what should happen in this case. |
ETG1000.4 indicates that the wkc is associated with each ECAT PDU. Since adding additional segments is adding more PDUs for the process data the WKC should be updated accordingly. For the slave config I have posted above the correct WKC should be 4. I pushed the changes accordingly. |
|
Have you checked/verified the overlapped API also? |
|
I don't know enough to know how to test that. If I try calling config_overlap_map then the device I have seems to not report data correctly. EDIT: Using send_overlap_processdata with config_overlap_map the system works as expected. This is a test with only a single device on the ecat network. |
Sounds good, I assume first try using config_overlap_map was done using send_processdata? |
Yes, exactly. Once I changed both over it worked as expected. |
|
Let me know anything else you want to test/try before getting this merged. |
soem/ethercatconfig.c
Outdated
| currentsegment++; | ||
| segmentsize = diff; | ||
| } | ||
| while (diff > (EC_MAXLRWDATA - EC_FIRSTDCDATAGRAM) && currentsegment < (EC_MAXIOSEGMENTS - 1)) |
There was a problem hiding this comment.
I wonder if there are a clever way to split a "big" segment? I did a sample slave with 4B Out/1540B In.
The logic will create 3 frames when 2 frames easily is enough, but sometimes the clever logic comes with a cost in complexity to maintain and test.
When running overlapped the DC frame is sent alone in first segment.
Also, EC_MAXLRWDATA - EC_FIRSTDCDATAGRAM , EC_FIRSTDCDATAGRAM is only relevant for first frame.
Any idea?
There was a problem hiding this comment.
Also, EC_MAXLRWDATA - EC_FIRSTDCDATAGRAM , EC_FIRSTDCDATAGRAM is only relevant for first frame.
The code before was/is taking EC_FIRSTDCDATAGRAM into account on all segments, I can refactor and change that if you're confident it doesn't need this.
I wonder if there are a clever way to split a "big" segment? I did a sample slave with 4B Out/1540B In.
The logic will create 3 frames when 2 frames easily is enough, but sometimes the clever logic comes with a cost in complexity to maintain and test.
The code right now will pack a segment with as many slaves as will fit, it should be easy to extend that for this use case.
There was a problem hiding this comment.
Also, EC_MAXLRWDATA - EC_FIRSTDCDATAGRAM , EC_FIRSTDCDATAGRAM is only relevant for first frame.
The code before was/is taking EC_FIRSTDCDATAGRAM into account on all segments, I can refactor and change that if you're confident it doesn't need this.
I wonder if there are a clever way to split a "big" segment? I did a sample slave with 4B Out/1540B In.
The logic will create 3 frames when 2 frames easily is enough, but sometimes the clever logic comes with a cost in complexity to maintain and test.The code right now will pack a segment with as many slaves as will fit, it should be easy to extend that for this use case.
We can keep EC_FIRSTDCDATAGRAM to keep it simple, how would you otherwise be able to calculate an adjustment of WKC correctly? You don't know what segment it will belong to.
The logic should avoid splitting slave data between segments when possible.
There was a problem hiding this comment.
The code is refactored so the wkc is cleared an incremented all within the config mapping functions rather than spread across separate functions as before. It will also pack large slave data into the current segment to potentially avoid using additional segments.
The logic should avoid splitting slave data between segments when possible.
I set it up this way and I'll agree this is just a preference for what "feels right". For what it's worth, the code can be shorter (and network traffic optimized) by always packing as tightly as possible and I can't find any spec that says a slave must be handled in a single PDU. The downside being that wireshark dumps might be harder to decipher with more optimized packing.
a cost in complexity to maintain and test
You mentioned maintenance and testing yesterday, how do you test this code? Is there a way to use SOES and run some sort of automated testing?
There was a problem hiding this comment.
The code is refactored so the wkc is cleared an incremented all within the config mapping functions rather than spread across separate functions as before. It will also pack large slave data into the current segment to potentially avoid using additional segments.
The logic should avoid splitting slave data between segments when possible.
I set it up this way and I'll agree this is just a preference for what "feels right". For what it's worth, the code can be shorter (and network traffic optimized) by always packing as tightly as possible and I can't find any spec that says a slave must be handled in a single PDU. The downside being that wireshark dumps might be harder to decipher with more optimized packing.
The rationale is to make Wireshark dumps as easy to dissect as possible.
a cost in complexity to maintain and test
You mentioned maintenance and testing yesterday, how do you test this code? Is there a way to use SOES and run some sort of automated testing?
I've created two SOES slaves on XMC48 that is 4B Out/1540B In and 1540B Out/4B In. I run manual tests.
There was a problem hiding this comment.
Thank you for the info, let me know if there is anything else you want me to do.
There was a problem hiding this comment.
It looks good! Nice work.
I'd like to do some more regression testing on bigger networks but I'll be out of office until next Monday, thank you for understanding it'll take a few more days before merge.
…WDATA bytes. Move wkc calcs into relevant config map functions.
…Tsociety#907) * Fix single device inputs/outputs overruning segment size * Refactor to pack segments tightly. * Allow segments 2-64 to be EC_MAXLRWDATA bytes. * Move wkc calcs into relevant config map functions. * Only split slave data between segments when it is larger than one segment * Only update wkc when we include data for the current device
certain modular devices can have process data that exceeds a segment size. Add code to allow multiple segments within a single device.