Skip to content

Commit 4017078

Browse files
committed
Check if the sub index for PDO mapping is still valid (might be deleted)
Prevent crash if a mapped sub was deleted from OD.
1 parent 884f022 commit 4017078

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

libEDSsharp/PDOHelper.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -366,8 +366,13 @@ void build_PDOlist(UInt16 startIdx, List<PDOSlot> slots)
366366
}
367367
else
368368
maptarget.entry = eds.ods[pdoindex].Getsubobject(pdosub);
369-
370-
if ((maptarget.entry.prop.CO_disabled == false) &&
369+
// Check if mapped sub index was found in OD
370+
if (maptarget.entry == null)
371+
{
372+
Console.WriteLine("MAPPING FAILED, OBJEKT NOT FOUND");
373+
continue;
374+
}
375+
else if ((maptarget.entry.prop.CO_disabled == false) &&
371376
(datasize <= maptarget.entry.Sizeofdatatype()) &&
372377
(datasize > 0))
373378
{

0 commit comments

Comments
 (0)