Skip to content

tom4711/eds-dcf-net

Β 
Β 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

33 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

EdsDcfNet

Build Status Semantic Release NuGet Version NuGet Downloads License: MIT codecov

A comprehensive, easy-to-use C# .NET library for CiA DS 306 - Electronic Data Sheet (EDS), Device Configuration File (DCF) and Nodelist Project (CPJ) for CANopen devices.

Features

✨ Simple API - Intuitive, fluent API style for quick integration

πŸ“– Read EDS - Complete parsing of Electronic Data Sheets

πŸ“ Read & Write DCF - Process and create Device Configuration Files

🌐 Read & Write CPJ - Parse and create Nodelist Project files (CiA 306-3 network topologies)

πŸ”„ EDS to DCF Conversion - Easy conversion with configuration parameters

🎯 Type-Safe - Fully typed models for all CANopen objects

πŸ“¦ Modular - Support for modular devices (bus couplers + modules)

βœ… CiA DS 306 v1.4 Compliant - Implemented according to official specification

Quick Start

Reading an EDS File

using EdsDcfNet;

// Read EDS file
var eds = CanOpenFile.ReadEds("device.eds");

// Display device information
Console.WriteLine($"Device: {eds.DeviceInfo.ProductName}");
Console.WriteLine($"Vendor: {eds.DeviceInfo.VendorName}");
Console.WriteLine($"Product Number: 0x{eds.DeviceInfo.ProductNumber:X}");

Reading a DCF File

using EdsDcfNet;

// Read DCF file
var dcf = CanOpenFile.ReadDcf("configured_device.dcf");

Console.WriteLine($"Node ID: {dcf.DeviceCommissioning.NodeId}");
Console.WriteLine($"Baudrate: {dcf.DeviceCommissioning.Baudrate} kbit/s");

Converting EDS to DCF

using EdsDcfNet;

// Read EDS
var eds = CanOpenFile.ReadEds("device.eds");

// Convert to DCF with node ID and baudrate
var dcf = CanOpenFile.EdsToDcf(eds, nodeId: 2, baudrate: 500, nodeName: "MyDevice");

// Save DCF
CanOpenFile.WriteDcf(dcf, "device_node2.dcf");

Working with Nodelist Projects (CPJ)

using EdsDcfNet;
using EdsDcfNet.Models;

// Read a CPJ file describing the network topology
var cpj = CanOpenFile.ReadCpj("nodelist.cpj");

foreach (var network in cpj.Networks)
{
    Console.WriteLine($"Network: {network.NetName}");
    foreach (var node in network.Nodes.Values)
    {
        Console.WriteLine($"  Node {node.NodeId}: {node.Name} ({node.DcfFileName})");
    }
}

// Create a new CPJ
var project = new NodelistProject();
project.Networks.Add(new NetworkTopology
{
    NetName = "Production Line 1",
    Nodes =
    {
        [2] = new NetworkNode { NodeId = 2, Present = true, Name = "PLC", DcfFileName = "plc.dcf" },
        [3] = new NetworkNode { NodeId = 3, Present = true, Name = "IO Module", DcfFileName = "io.dcf" }
    }
});
CanOpenFile.WriteCpj(project, "network.cpj");

Working with Object Dictionary

using EdsDcfNet.Extensions;

var dcf = CanOpenFile.ReadDcf("device.dcf");

// Get object
var deviceType = dcf.ObjectDictionary.GetObject(0x1000);

// Set value
dcf.ObjectDictionary.SetParameterValue(0x1000, "0x00000191");

// Browse PDO objects
var tpdos = dcf.ObjectDictionary.GetPdoCommunicationParameters(transmit: true);

API Overview

Main Class: CanOpenFile

// Read EDS
ElectronicDataSheet ReadEds(string filePath)
ElectronicDataSheet ReadEdsFromString(string content)

// Read DCF
DeviceConfigurationFile ReadDcf(string filePath)
DeviceConfigurationFile ReadDcfFromString(string content)

// Write DCF
void WriteDcf(DeviceConfigurationFile dcf, string filePath)
string WriteDcfToString(DeviceConfigurationFile dcf)

// Read CPJ (CiA 306-3 Nodelist Project)
NodelistProject ReadCpj(string filePath)
NodelistProject ReadCpjFromString(string content)

// Write CPJ
void WriteCpj(NodelistProject cpj, string filePath)
string WriteCpjToString(NodelistProject cpj)

// Convert EDS to DCF
DeviceConfigurationFile EdsToDcf(ElectronicDataSheet eds, byte nodeId,
                                  ushort baudrate = 250, string? nodeName = null)

Supported Features

  • βœ… Complete EDS parsing
  • βœ… Complete DCF parsing and writing
  • βœ… CPJ nodelist project parsing and writing (CiA 306-3 network topologies)
  • βœ… All Object Types (NULL, DOMAIN, DEFTYPE, DEFSTRUCT, VAR, ARRAY, RECORD)
  • βœ… Sub-objects and sub-indexes
  • βœ… Compact Storage (CompactSubObj, CompactPDO)
  • βœ… Object Links
  • βœ… Modular device concept
  • βœ… Hexadecimal, decimal, and octal numbers
  • βœ… $NODEID formula evaluation (e.g., $NODEID+0x200)
  • βœ… CANopen Safety (EN 50325-5) - SRDOMapping, InvertedSRAD
  • βœ… Comments and additional sections

Examples

Complete examples can be found in the examples/EdsDcfNet.Examples project.

Project Structure

eds-dcf-net/
β”œβ”€β”€ src/
β”‚   └── EdsDcfNet/              # Main library
β”‚       β”œβ”€β”€ Models/             # Data models
β”‚       β”œβ”€β”€ Parsers/            # EDS/DCF/CPJ parsers
β”‚       β”œβ”€β”€ Writers/            # DCF/CPJ writers
β”‚       β”œβ”€β”€ Utilities/          # Helper classes
β”‚       β”œβ”€β”€ Exceptions/         # Custom exceptions
β”‚       └── Extensions/         # Extension methods
β”œβ”€β”€ examples/
β”‚   └── EdsDcfNet.Examples/     # Example application
└── docs/
    β”œβ”€β”€ architecture/           # ARC42 software architecture
    └── cia/                    # CiA DS 306 specification

Requirements

For consuming the NuGet package:

  • Any .NET implementation compatible with .NET Standard 2.0 (e.g., .NET Framework 4.6.1+, .NET Core 2.0+, .NET 5+, Unity, Xamarin)

For building this repository (library, tests, examples):

  • .NET SDK 10.0 or higher
  • C# 13.0 (as provided by the .NET 10 SDK)

License

MIT License - see LICENSE file

Specification

Based on CiA DS 306 Version 1.4.0 (December 15, 2021) "Electronic data sheet specification for CANopen"

Support

For questions or issues:


EdsDcfNet - Professional CANopen EDS/DCF processing in C# .NET

About

Read EDS + DCF, Write DCF .NET Library

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages

  • C# 100.0%