Skip to content

Commit cef25bd

Browse files
Add a trap in the PDO update to ensure that if an object that is PDo mapped gets changed this is caught and not used to generate bad PDO data for export.
See bug #56 I am not declaring this a total fix as it should be able to sort itself out. However to do this is requiring more and more "fudging" this is because the PDO generation code needs removing from the GUI and placing in libedssharp where it can look after itself. So i'm adding this trap in the GUI to warn the user there is an issue. To fix the issue from a user perspective, just click on the drop down PDO mapping combo on the TX/RX pdo tab and it will force a rebuild of the PDO mapping.
1 parent f2ac5b0 commit cef25bd

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

‎EDSTest/DevicePDOView.cs‎

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,28 @@ void updatePDOTXslot(ODentry od , int row)
230230
UInt16 pdoindex = (UInt16)((data >> 16) & 0x0000FFFF);
231231
byte pdosub = (byte)((data >> 8) & 0x000000FF);
232232

233+
//sanity check the real OD against the mapping parameters section
234+
235+
bool mappingfail = true;
236+
if(eds.ods.ContainsKey(pdoindex) && (pdosub==0 || eds.ods[pdoindex].containssubindex(pdosub)))
237+
{
238+
ODentry maptarget;
239+
if (pdosub == 0)
240+
maptarget = eds.ods[pdoindex];
241+
else
242+
maptarget = eds.ods[pdoindex].getsubobject(pdosub);
243+
244+
if (maptarget.Disabled == false && datasize == (8*maptarget.sizeofdatatype()))
245+
{
246+
mappingfail = false;
247+
}
248+
249+
if (mappingfail == true)
250+
{
251+
MessageBox.Show(String.Format("PDO mapping failed for object 0x{0:x4}/{1:x2}\nplease manaully check the PDO mapping in the TX and RX PDO tabs\n as it does not agree with the mapping paramater 0x{2:x4}/{3:x2}\nThis can occur if you edit objects that are already mapped",pdoindex,pdosub, idx,sub.subindex));
252+
}
253+
}
254+
233255
String target = "";
234256
int PDOdatasize = 0;
235257

0 commit comments

Comments
 (0)