Skip to content

Fix original unittests #82

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Mar 15, 2024
Merged
8 changes: 4 additions & 4 deletions Tests/ExporterTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Xunit;
using libEDSsharp;

Expand Down Expand Up @@ -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"));

}
Expand Down Expand Up @@ -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"));


Expand Down Expand Up @@ -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"));


Expand Down
17 changes: 9 additions & 8 deletions Tests/PDOHelperTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using Xunit;
using libEDSsharp;

Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -132,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");
}


Expand Down
26 changes: 13 additions & 13 deletions libEDSsharp/CanOpenXDD.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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[subobj.subIndex.Length - 1], subentry);

}
}
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -4001,18 +4001,18 @@ public bool ngMaster
{
this.ngMasterField = value;
}
}
}

/// <remarks/>
[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;
}
Expand Down
Loading