Skip to content
  • 0 Votes
    2 Posts
    260 Views
    G

    @Guy-Radford

    This appears to be a bug as the CAN Frames are decoded correctly on a windows machine, I have raised a Bug report with QT:

    https://bugreports.qt.io/browse/QTBUG-113538

  • 0 Votes
    11 Posts
    4k Views
    B

    @aha_1980 i call setConfiguration parameter in my class constructor.
    Here is my class header

    #ifndef CANOPENDEVICE_H #define CANOPENDEVICE_H #include <QObject> #include <QSettings> #include <QQmlEngine> #include "protocolmanager.h" #include "ByteArrayQmlWrapper.h" #include "objectdictionary.h" #include "TypesQmlWrapper.h" #include "QQmlVarPropertyHelpers.h" #include "QQmlConstRefPropertyHelpers.h" #include "QQmlPtrPropertyHelpers.h" #include "edsreader.h" #include "QQmlEnumClassHelper.h" #include "QQmlObjectListModel.h" #include "QQmlListPropertyHelper.h" QML_ENUM_CLASS (CanOpenNmtCmd, StartNode = 0x01, StopNode = 0x02, SetPreOp = 0x80, ResetNode = 0x81, ResetComm = 0x82, NB_CMDS) QML_ENUM_CLASS (CanOpenLssCommands, SwitchState = 0x04, ChangeNodeId = 0x11, ChangeBitrate = 0x13, StoreConfig = 0x17, NB_CMDS) class CanOpenDevice: public QObject { Q_OBJECT QML_WRITABLE_VAR_PROPERTY(CanOpenNodeId,nodeId) QML_WRITABLE_VAR_PROPERTY (bool, isMaster) QML_WRITABLE_PTR_PROPERTY (QCanBusDevice, device) QML_WRITABLE_PTR_PROPERTY(ProtocolManager,protocolManager) QML_WRITABLE_VAR_PROPERTY (QString, edsFileName) QML_WRITABLE_VAR_PROPERTY(QString,deviceName) QML_WRITABLE_VAR_PROPERTY(QStringList,deviceInfo) QML_WRITABLE_VAR_PROPERTY(QStringList,subEntriesList) QML_WRITABLE_VAR_PROPERTY(QStringList,entries) QML_WRITABLE_VAR_PROPERTY(QString, deviceProfile) public: explicit CanOpenDevice(QObject *parent=Q_NULLPTR); CanOpenDevice(const CanOpenNodeId &nodeId,const QString &identNumber,QObject *parent=nullptr); void init(void); void start(); void stop(void); void reset(void); void createDevice(QString plugin,QString interface); void setConfiguration(int key); ProtocolManager * getProtocolManger(); ObjectDictionary * getObjectDictionary(); Q_INVOKABLE ByteArrayWrapper * createBufferFromInt8 (const QmlBiggestInt value); Q_INVOKABLE ByteArrayWrapper * createBufferFromInt16 (const QmlBiggestInt value); Q_INVOKABLE ByteArrayWrapper * createBufferFromInt32 (const QmlBiggestInt value); Q_INVOKABLE ByteArrayWrapper * createBufferFromUInt8 (const QmlBiggestInt value); Q_INVOKABLE ByteArrayWrapper * createBufferFromUInt16 (const QmlBiggestInt value); Q_INVOKABLE ByteArrayWrapper * createBufferFromUInt32 (const QmlBiggestInt value); Q_INVOKABLE ByteArrayWrapper * createBufferFromHex (const QString & hex); Q_INVOKABLE ByteArrayWrapper * createBufferFromString (const QString & str); Q_INVOKABLE ByteArrayWrapper * readValue (const int index, const int subIndex); Q_INVOKABLE void changeValue (const int index, const int subIndex, ByteArrayWrapper * buffer); Q_INVOKABLE void sendNmtChangeRequest (const int nodeId, const CanOpenNmtCmd::Type state); Q_INVOKABLE void sendLssActionRequest (const CanOpenLssCommands::Type cmd, const int argument = 0); Q_INVOKABLE void sendSdoReadRequest (const int nodeId, const int index, const int subIndex, const bool blockMode = false); Q_INVOKABLE void sendSdoWriteRequest (const int nodeId, const int index, const int subIndex, ByteArrayWrapper * buffer); Q_INVOKABLE void writeValuetoSubEntry(ObjDicIndex index,ObjDicSubIndex subIndex,QString value); Q_INVOKABLE QString getParameterNameforSubEntry(QString subEntry); void getWritableEntries(); Q_INVOKABLE QString entryParamName(QString idxStr); Q_INVOKABLE QString getDefaultValue(QString subIdx); Q_INVOKABLE void modifyValue(QString val,QString subEntry); Q_INVOKABLE QStringList getSubEntries(QString entry); Q_INVOKABLE void dataToCan(QString entry); public slots: Q_INVOKABLE void loadObjectDictionary(QString edsFilePath); //Q_INVOKABLE bool writeValueToEntry(); protected slots: //void onCanOpenParamChanged(void); signals: void initialized(quint32 bitRateKey,QString plugin="systeccan",QString interface = "can"); void started(void); void stopped(void); void reseting(void); void EntryWritten(); void loaded(QString edsFilePath); private: bool m_ready; bool m_running; QString m_interface; QString m_plugin; EdsReader *m_edsReader; QSettings *m_setting; ObjectDictionary *m_obd; }; #endif // CANOPENDEVICE_H
  • 0 Votes
    4 Posts
    3k Views
    M

    Yes, you're right. Thanks.

  • 0 Votes
    7 Posts
    2k Views
    aha_1980A

    @MrBrightSide8 said in bool QCanBusDevice::connectDevice and QCanBus's createDevice always return true?:

    Yes, I can see it in vcanconf.exe in channel 1 and 2 of the CAN device.

    So you mean, channel 1 and 2 are the real hardware channels, right? Do you see virtual channels there also? (You could also post a screenshot of vcanconf.exe).

    If the channels 1 and 2 are the hardware CAN channels, you should be able to connect to "can0" or "can1". Unfortunately I don't have Vector CAN hardware at hand so I could always test using the virtual channels only.

    Is there anyway to determine the actual hardware connection in code?

    There is currently none, except using availableDevices() first.