From 1b635d699fbb36ab8db52f20fb1faad768be45df Mon Sep 17 00:00:00 2001 From: Lars Elgtvedt Susaas <9848846+nimrof@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:17:14 +0100 Subject: [PATCH 1/7] TPDO does no longer have subindex 0x04 (the reserved byte) --- Tests/PDOHelperTests.cs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/Tests/PDOHelperTests.cs b/Tests/PDOHelperTests.cs index 6db83077..b659687b 100644 --- a/Tests/PDOHelperTests.cs +++ b/Tests/PDOHelperTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Xunit; using libEDSsharp; @@ -53,10 +53,10 @@ public void Test_TPDO() throw new Exception("Mapping paramaters not generated"); } - if (comparamOD.subobjects.Count != 7) + if (comparamOD.subobjects.Count != 6) throw new Exception("Wrong number of sub objects generated"); - if(comparamOD.Nosubindexes!=7) + if(comparamOD.Nosubindexes!=6) throw new Exception("Wrong number of sub objects generated"); if (comparamOD.subobjects[1].datatype != DataType.UNSIGNED32) @@ -65,8 +65,6 @@ public void Test_TPDO() throw new Exception("Wrong data type for Transmission type"); if (comparamOD.subobjects[3].datatype != DataType.UNSIGNED16) throw new Exception("Wrong data type for Inhibit time"); - if (comparamOD.subobjects[4].datatype != DataType.UNSIGNED8) - throw new Exception("Wrong data type for Compatibility Entry"); if (comparamOD.subobjects[5].datatype != DataType.UNSIGNED16) throw new Exception("Wrong data type for Event timer"); if (comparamOD.subobjects[6].datatype != DataType.UNSIGNED8) From 2dfbb9182177b8c6b2bd08733f3332e75e20b606 Mon Sep 17 00:00:00 2001 From: Lars Elgtvedt Susaas <9848846+nimrof@users.noreply.github.com> Date: Wed, 13 Mar 2024 16:18:21 +0100 Subject: [PATCH 2/7] fixed test after adding TPDO event timer subindex --- Tests/PDOHelperTests.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Tests/PDOHelperTests.cs b/Tests/PDOHelperTests.cs index b659687b..df940964 100644 --- a/Tests/PDOHelperTests.cs +++ b/Tests/PDOHelperTests.cs @@ -130,22 +130,25 @@ public void Test_RPDO() throw new Exception("Mapping paramaters not generated"); } - if (comparamOD.subobjects.Count != 3) + if (comparamOD.subobjects.Count != 4) throw new Exception("Wrong number of sub objects generated"); - if (comparamOD.Nosubindexes != 3) + if (comparamOD.Nosubindexes != 4) throw new Exception("Wrong number of sub objects generated"); if (comparamOD.subobjects[1].datatype != DataType.UNSIGNED32) throw new Exception("Wrong data type for COB"); if (comparamOD.subobjects[2].datatype != DataType.UNSIGNED8) throw new Exception("Wrong data type for Transmission type"); + if (comparamOD.subobjects[5].datatype != DataType.UNSIGNED16) + throw new Exception("Wrong data type for Transmission type"); if (comparamOD.subobjects[1].defaultvalue != "0x401") //481 hex throw new Exception("TPDO COB wrong"); if (comparamOD.subobjects[2].defaultvalue != "254") throw new Exception("TPDO transmission type wrong"); - + if (comparamOD.subobjects[5].defaultvalue != "20") + throw new Exception("TPDO event timer wrong default value"); } From 08f4088f3e8ad91ce167286c1159260549c62f58 Mon Sep 17 00:00:00 2001 From: Lars Elgtvedt Susaas <9848846+nimrof@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:26:01 +0100 Subject: [PATCH 3/7] Fix test as getflags got a spesial case for index 1003 --- Tests/ExporterTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/ExporterTests.cs b/Tests/ExporterTests.cs index 16f53eeb..2cc37a8a 100644 --- a/Tests/ExporterTests.cs +++ b/Tests/ExporterTests.cs @@ -1,4 +1,4 @@ -using System; +using System; using Xunit; using libEDSsharp; @@ -151,7 +151,7 @@ public void TestArrayNoEntries() od.subobjects.Add(0x03, new ODentry("LINE1", 0x03, DataType.UNSIGNED32, "0x01", EDSsharp.AccessType.ro, PDOMappingType.optional)); test = write_od_line(od); - if (test != "{0x1003, 0x03, 0x06, 0, (void*)&CO_OD_RAM.testArray[0]}," + Environment.NewLine) + if (test != "{0x1003, 0x03, 0x0E, 0, (void*)&CO_OD_RAM.testArray[0]}," + Environment.NewLine) throw (new Exception("TestArrayNoEntries() failed")); From 908c78d10e11ffd9d0ad5b1964a666c80f2f2051 Mon Sep 17 00:00:00 2001 From: Lars Elgtvedt Susaas <9848846+nimrof@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:34:33 +0100 Subject: [PATCH 4/7] fix test as getflags has added code that makes PDOtype change the flag value --- Tests/ExporterTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/ExporterTests.cs b/Tests/ExporterTests.cs index 2cc37a8a..f3fe66de 100644 --- a/Tests/ExporterTests.cs +++ b/Tests/ExporterTests.cs @@ -44,7 +44,7 @@ public void Test_record_objects() subod = new ODentry("Test String 2", 0x01, DataType.VISIBLE_STRING, new string('*', 255), EDSsharp.AccessType.ro, PDOMappingType.optional, od); test = export_one_record_type(subod, ""); - if (test != " {(void*)&CO_OD_RAM.testRecord.testString2, 0x26, 0xFF }," + Environment.NewLine) + if (test != " {(void*)&CO_OD_RAM.testRecord.testString2, 0x36, 0xFF }," + Environment.NewLine) throw (new Exception("export_one_record_type() error test 2")); } From d6bdaf842490f293d51da34b993c42aa61050765 Mon Sep 17 00:00:00 2001 From: Lars Elgtvedt Susaas <9848846+nimrof@users.noreply.github.com> Date: Wed, 13 Mar 2024 19:42:57 +0100 Subject: [PATCH 5/7] Fixed test that i think is wrong, changing from 32 arrays of 4 to 4 arrays of 32 --- Tests/ExporterTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/ExporterTests.cs b/Tests/ExporterTests.cs index f3fe66de..062b2345 100644 --- a/Tests/ExporterTests.cs +++ b/Tests/ExporterTests.cs @@ -78,7 +78,7 @@ public void TestArrays() string test = print_h_entry(od); - if (test != "/*2000 */ VISIBLE_STRING testArray[32][4];" + Environment.NewLine) + if (test != "/*2000 */ VISIBLE_STRING testArray[4][32];" + Environment.NewLine) throw (new Exception("TestArrays() test 1 failed")); From caf97145043003204a77a916adf0b37b92423011 Mon Sep 17 00:00:00 2001 From: Lars Elgtvedt Susaas <9848846+nimrof@users.noreply.github.com> Date: Wed, 13 Mar 2024 21:26:07 +0100 Subject: [PATCH 6/7] Not sure if this is the correct fix --- libEDSsharp/CanOpenXDD.cs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/libEDSsharp/CanOpenXDD.cs b/libEDSsharp/CanOpenXDD.cs index 9b8bf1ee..b13c3834 100644 --- a/libEDSsharp/CanOpenXDD.cs +++ b/libEDSsharp/CanOpenXDD.cs @@ -1,4 +1,4 @@ -/* +/* This file is part of libEDSsharp. libEDSsharp is free software: you can redistribute it and/or modify @@ -639,8 +639,8 @@ public ISO15745ProfileContainer convert(EDSsharp eds) NetworkManagement.CANopenGeneralFeatures.bootUpSlave = eds.di.SimpleBootUpSlave; //NetworkManagment.CANopenGeneralFeatures.dynamicChannels = eds.di.DynamicChannelsSupported; //fix me count of dynamic channels not handled yet eds only has bool NetworkManagement.CANopenGeneralFeatures.granularity = eds.di.Granularity; - NetworkManagement.CANopenGeneralFeatures.groupMessaging = eds.di.GroupMessaging; - + NetworkManagement.CANopenGeneralFeatures.groupMessaging = eds.di.GroupMessaging; + NetworkManagement.CANopenGeneralFeatures.ngMaster = eds.di.NG_Master; NetworkManagement.CANopenGeneralFeatures.ngSlave = eds.di.NG_Slave; NetworkManagement.CANopenGeneralFeatures.NrOfNG_MonitoredNodes = eds.di.NrOfNG_MonitoredNodes; @@ -918,9 +918,9 @@ public EDSsharp convert(ISO15745ProfileContainer container) } eds.di.NG_Master = NetworkManagment.CANopenGeneralFeatures.ngMaster; - eds.di.NG_Slave = NetworkManagment.CANopenGeneralFeatures.ngSlave; - eds.di.NrOfNG_MonitoredNodes = NetworkManagment.CANopenGeneralFeatures.NrOfNG_MonitoredNodes; - + eds.di.NG_Slave = NetworkManagment.CANopenGeneralFeatures.ngSlave; + eds.di.NrOfNG_MonitoredNodes = NetworkManagment.CANopenGeneralFeatures.NrOfNG_MonitoredNodes; + eds.di.NrOfRXPDO = NetworkManagment.CANopenGeneralFeatures.nrOfRxPDO; eds.di.NrOfTXPDO = NetworkManagment.CANopenGeneralFeatures.nrOfTxPDO; @@ -1118,7 +1118,7 @@ public EDSsharp convert(ISO15745ProfileContainer container) subentry.uniqueID = subobj.uniqueIDRef; - entry.subobjects.Add(subobj.subIndex[0], subentry); + entry.subobjects.Add(subobj.subIndex[1], subentry); } } @@ -3832,8 +3832,8 @@ public partial class ProfileBody_CommunicationNetwork_CANopenNetworkManagementCA private ushort nrOfTxPDOField; private bool ngMasterField; - private bool ngSlaveField; - private ushort NrOfNG_MonitoredNodesField; + private bool ngSlaveField; + private ushort NrOfNG_MonitoredNodesField; private bool bootUpSlaveField; private bool layerSettingServiceSlaveField; @@ -4001,18 +4001,18 @@ public bool ngMaster { this.ngMasterField = value; } - } - + } + /// [System.Xml.Serialization.XmlAttributeAttribute()] [System.ComponentModel.DefaultValueAttribute(typeof(ushort), "0")] - public ushort NrOfNG_MonitoredNodes + public ushort NrOfNG_MonitoredNodes { - get + get { return this.NrOfNG_MonitoredNodesField; } - set + set { this.NrOfNG_MonitoredNodesField = value; } From 8c21a1ab5a2b89a571241ca6cf6cd8c92d9c5644 Mon Sep 17 00:00:00 2001 From: Lars Elgtvedt Susaas <9848846+nimrof@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:51:01 +0100 Subject: [PATCH 7/7] impliment hack to make it work with file from issue 29 and test --- libEDSsharp/CanOpenXDD.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libEDSsharp/CanOpenXDD.cs b/libEDSsharp/CanOpenXDD.cs index b13c3834..616b534f 100644 --- a/libEDSsharp/CanOpenXDD.cs +++ b/libEDSsharp/CanOpenXDD.cs @@ -1,4 +1,4 @@ -/* +/* This file is part of libEDSsharp. libEDSsharp is free software: you can redistribute it and/or modify @@ -1118,7 +1118,7 @@ public EDSsharp convert(ISO15745ProfileContainer container) subentry.uniqueID = subobj.uniqueIDRef; - entry.subobjects.Add(subobj.subIndex[1], subentry); + entry.subobjects.Add(subobj.subIndex[subobj.subIndex.Length - 1], subentry); } }