Skip to content

Commit 7937b10

Browse files
committed
edssharp: add another extension for the EDS file for CountLabel
The count label is required to compile against the CANopenNode v4 library since the definitions are checked by code like the following in CANopen.c #if OD_CNT_NMT != 1 #error OD_CNT_NMT from OD.h not correct! #endif This problem is exhibited when there is no xpd file that has the custom properties and there is only an EDS file available. The StorageLocation is an example of setting the custom property for the CO_storageGroup and this is adding a similar extension for the CO_countLabel. An example eds for NMT 0x1000 is shown below [1000] ParameterName=Device type ObjectType=0x7 ;CountLabel=NMT ;StorageLocation=ROM DataType=0x0007 AccessType=ro DefaultValue=0x00000000 PDOMapping=0 Signed-off-by: Charles Hardin <charles.hardin@redoxblox.com>
1 parent ada7c1b commit 7937b10

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

libEDSsharp/CanOpenEDS.cs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,14 @@ public void Write(StreamWriter writer, InfoSection.Filetype ft, Odtype odt = Odt
387387
}
388388

389389
writer.WriteLine(string.Format("ObjectType=0x{0:X}", (int)objecttype));
390-
writer.WriteLine(string.Format(";StorageLocation={0}", prop.CO_storageGroup));
390+
if (prop.CO_countLabel != "")
391+
{
392+
writer.WriteLine(string.Format(";CountLabel={0}", prop.CO_countLabel));
393+
}
394+
if (prop.CO_storageGroup != "")
395+
{
396+
writer.WriteLine(string.Format(";StorageLocation={0}", prop.CO_storageGroup));
397+
}
391398

392399
if (objecttype == ObjectType.ARRAY)
393400
{
@@ -521,9 +528,9 @@ public void Parseline(string linex, int no)
521528
}
522529
}
523530
else
524-
//Only allow our own extensions to populate the key/value pair
525531
{
526-
if (key == "StorageLocation" || key == "TPDODetectCos")
532+
//Only allow our own extensions to populate the key/value pair
533+
if (key == "CountLabel" || key == "StorageLocation" || key == "TPDODetectCos")
527534
{
528535
try
529536
{
@@ -618,6 +625,11 @@ public void ParseEDSentry(KeyValuePair<string, Dictionary<string, string>> kvp)
618625
}
619626

620627
//Access Type
628+
if (kvp.Value.ContainsKey("CountLabel"))
629+
{
630+
od.prop.CO_countLabel = kvp.Value["CountLabel"];
631+
}
632+
621633
if (kvp.Value.ContainsKey("StorageLocation"))
622634
{
623635
od.prop.CO_storageGroup = kvp.Value["StorageLocation"];

0 commit comments

Comments
 (0)