CanOpen device EDS file to ObjectDictionary class



  • Hello i'm working on a CanOpen qml API.
    The EDS file is a file describing CanOpen object dictionary of a device.
    What i want to do is extract informations(entries,subentries) in my EDS file and add it to my object dictionary object.
    My EDS File is structured like this

    [1000]
    ParameterName=Device Type
    ObjectType=0x7
    DataType=0x0007
    LowLimit=
    HighLimit=
    AccessType=ro
    DefaultValue=0x00000000
    PDOMapping=0
    ObjFlags=0x0
    
    [1001]
    ParameterName=Error Register
    ObjectType=0x7
    DataType=0x0005
    LowLimit=
    HighLimit=
    AccessType=ro
    DefaultValue=0x0
    PDOMapping=0
    ObjFlags=0x0
    
    [1018]
    ParameterName=Identity Object
    SubNumber=4
    ObjectType=0x8
    
    [1018sub0]
    ParameterName=Number of entries
    ObjectType=0x7
    DataType=0x0005
    LowLimit=3
    HighLimit=3
    AccessType=ro
    DefaultValue=3
    PDOMapping=0
    ObjFlags=0x0
    
    [1018sub1]
    ParameterName=Vendor ID
    ObjectType=0x7
    DataType=0x0007
    LowLimit=
    HighLimit=
    AccessType=ro
    DefaultValue=0x0200005A
    PDOMapping=0
    ObjFlags=0x0
    
    [1018sub2]
    ParameterName=Product code
    ObjectType=0x7
    DataType=0x0007
    LowLimit=
    HighLimit=
    AccessType=ro
    DefaultValue=0x00414645
    PDOMapping=0
    ObjFlags=0x0
    
    [1018sub3]
    ParameterName=Revision number
    ObjectType=0x7
    DataType=0x0007
    LowLimit=
    HighLimit=
    AccessType=ro
    DefaultValue=0x00010000
    PDOMapping=0
    ObjFlags=0x0
    
    [OptionalObjects]
    SupportedObjects=19
    1=0x1003
    2=0x1005
    3=0x1008
    4=0x100B
    5=0x100C
    6=0x100D
    7=0x100E
    8=0x100F
    9=0x1014
    10=0x1016
    11=0x1017
    12=0x1400
    13=0x1401
    14=0x1600
    15=0x1601
    16=0x1800
    17=0x1801
    18=0x1A00
    19=0x1A01
    
    [1003]
    ParameterName=Pre-defined Error Field
    SubNumber=2
    ObjectType=0x8
    
    

    And here is my ObjectDictionnary class header

    #ifndef OBJECTDICTIONARY_H
    #define OBJECTDICTIONARY_H
    #include <QtCore/QtGlobal>
    
    
    #include <QObject>
    #include <QMap>
    #include "qobjectdictionarydefs.h"
    #include "qobjectdictionarysubdataentry.h"
    #include "qobjectdictionarydataentry.h"
    #include "qobjectdictionarydatatypes.h"
    #include "sparsearray.h"
    
    
    class QTOBJECTDICTONNARY_EXPORT  ObjectDictionary: public QObject {
        Q_OBJECT
    
    public:
        explicit ObjectDictionary(QObject * parent = Q_NULLPTR);
    
        void addEntry(QObjectDictionaryDataEntry *entry, const ObjDicIndex idx);
        bool hasEntry(const ObjDicIndex idx) const;
        bool hasSubEntry(const ObjDicIndex idx, const ObjDicSubIndex subIdx) const;
        QObjectDictionaryDataEntry* getEntry(const ObjDicIndex idx) const;
        QObjectDictionarySubDataEntry* getSubEntry(const ObjDicIndex idx, const ObjDicSubIndex subIdx) const;
    
        void createVarEntry (const ObjDicIndex idx, const ObjDicDataType datatype, const ObjDicDataLen datalen=0);
        void createSdoConfigEntry    (const ObjDicIndex idx);
        void createPdoCommParamEntry (const ObjDicIndex idx);
        void createPdoMappingEntry   (const ObjDicIndex idx);
    
        void     setMetaDataForObdPos (const ObjDicIndex idx, const ObjDicSubIndex subIdx, const QString & metaKey, const QVariant & metaData);
            QVariant getMetaDataForObdPos (const ObjDicIndex idx, const ObjDicSubIndex subIdx, const QString & metaKey) const;
    
    public slots:
            void traverseObd();
    
    signals:
        void beginObd(QObjectDictionary *obd);
        void beginEntry    (const ObjDicIndex    idx,    QObjectDictionaryDataEntry    * entry);
        void beginSubEntry (const ObjDicIndex subIdx, QObjectDictionarySubDataEntry *subEntry);
        void endSubEntry   (void);
        void endEntry      (void);
        void endObd        (void);
    
    
    private:
        SparseArray<ObjDicIndex, QObjectDictionaryDataEntry *> m_entriesByIndex;
    
    };
    
    #endif // OBJECTDICTIONARY_H
    
    

    I want to read entries and subentries from my EDS file and add it to my ObjectDictionary object.

    I'm quite new at Qt.
    Anyone can help?



  • Really doubtful that you are going to find anyone at the level you're looking for...at least without paying them.


  • Lifetime Qt Champion

    Hi
    About reading the EDS file.
    It looks quite like ini format
    QSettings might be able to read it
    https://doc.qt.io/Qt-5/qsettings.html
    However, you might need to take care of converting some of them back to values from QVariant.
    Following code, dumps all ini sections and all keys and values.

      QSettings settings("e:/eds.ini", QSettings::IniFormat);
        const QStringList childGroups = settings.childGroups();
        foreach (const QString &group, childGroups) {
            settings.beginGroup(group);
            qDebug().noquote().nospace() << "|" << group << "|";
            const QStringList childKeys = settings.childKeys();
            foreach (const QString &childKey, childKeys)
                qDebug().noquote().nospace() << childKey << "=" << settings.value(childKey).toString();
            settings.endGroup();
        }
    

    output:

    |1000|
    AccessType=ro
    DataType=0x0007
    DefaultValue=0x00000000
    HighLimit=
    LowLimit=
    ObjFlags=0x0
    ObjectType=0x7
    PDOMapping=0
    ParameterName=Device Type
    |1001|
    AccessType=ro
    DataType=0x0005
    DefaultValue=0x0
    HighLimit=
    LowLimit=
    ObjFlags=0x0
    ObjectType=0x7
    PDOMapping=0
    ParameterName=Error Register
    |1003|
    ObjectType=0x8
    ParameterName=Pre-defined Error Field
    SubNumber=2
    |1018|
    ObjectType=0x8
    ParameterName=Identity Object
    SubNumber=4
    |1018sub0|
    AccessType=ro
    DataType=0x0005
    DefaultValue=3
    HighLimit=3
    LowLimit=3
    ObjFlags=0x0
    ObjectType=0x7
    PDOMapping=0
    ParameterName=Number of entries
    |1018sub1|
    AccessType=ro
    DataType=0x0007
    DefaultValue=0x0200005A
    HighLimit=
    LowLimit=
    ObjFlags=0x0
    ObjectType=0x7
    PDOMapping=0
    ParameterName=Vendor ID
    |1018sub2|
    AccessType=ro
    DataType=0x0007
    DefaultValue=0x00414645
    HighLimit=
    LowLimit=
    ObjFlags=0x0
    ObjectType=0x7
    PDOMapping=0
    ParameterName=Product code
    |1018sub3|
    AccessType=ro
    DataType=0x0007
    DefaultValue=0x00010000
    HighLimit=
    LowLimit=
    ObjFlags=0x0
    ObjectType=0x7
    PDOMapping=0
    ParameterName=Revision number
    |OptionalObjects|
    1=0x1003
    10=0x1016
    11=0x1017
    12=0x1400
    13=0x1401
    14=0x1600
    15=0x1601
    16=0x1800
    17=0x1801
    18=0x1A00
    19=0x1A01
    2=0x1005
    3=0x1008
    4=0x100B
    5=0x100C
    6=0x100D
    7=0x100E
    8=0x100F
    9=0x1014
    SupportedObjects=19
    


  • @mrjj thank you for you response. My further goal is to expose all this data to a qml application that will allow me to configure my devices correctly. For know i'll try what you suggested.


Log in to reply