Skip to content

Commit

Permalink
Add optional file path to Eds constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
wilkinsw committed Dec 14, 2023
1 parent d6b2dda commit 53e4a85
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion source/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class Device extends EventEmitter {
});
}

this.eds = args.eds || new Eds();
if(typeof args.eds === 'string')
this.eds = new Eds(args.eds);
else
this.eds = args.eds || new Eds();

this.emcy = new Emcy(this);
this.lss = new Lss(this);
this.nmt = new Nmt(this);
Expand Down
6 changes: 5 additions & 1 deletion source/eds.js
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,7 @@ class DataObject extends EventEmitter {
*
* This class provides methods for loading and saving CANopen EDS v4.0 files.
*
* @param {string} [path] - path to EDS file.
* @see CiA306 "Electronic data sheet specification for CANopen"
* @example
* const eds = new Eds();
Expand All @@ -458,7 +459,7 @@ class DataObject extends EventEmitter {
* eds.save();
*/
class Eds {
constructor() {
constructor(path) {
this.fileInfo = {};
this.deviceInfo = {};
this.dummyUsage = {};
Expand Down Expand Up @@ -523,6 +524,9 @@ class Eds {
dataType: DataType.UNSIGNED32,
accessType: AccessType.READ_ONLY,
});

if(path)
this.load(path);
}

/**
Expand Down

0 comments on commit 53e4a85

Please sign in to comment.