Développement CAN Watchdog
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "CANMessage.h"
|
||||
#include "defines.h"
|
||||
#include <QtEndian>
|
||||
|
||||
CCANMessage::CCANMessage():
|
||||
mPendingData(false)
|
||||
@@ -97,6 +98,34 @@ int CCANMessage::UpdateValue(CCANMessage *NewDeviceMessage)
|
||||
|
||||
}
|
||||
|
||||
//This function should be used to set the raw data to send over CAN
|
||||
//It will do the byte swapping crap and fill the data array
|
||||
int CCANMessage::SetRawData(quint64 RawData, int Encoding)
|
||||
{
|
||||
if(Encoding != CCANSignal::CAN_SIGNAL_ENCODING_INTEL)
|
||||
{
|
||||
//MOTOROLA encoding not supported for now...
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
|
||||
mCANRawDataIntel = qToLittleEndian(RawData);
|
||||
// mCANRawDataIntel = RawData;
|
||||
|
||||
|
||||
for(unsigned int i = 0; i < mCANMsgLength; i++)
|
||||
{
|
||||
unsigned char byte;
|
||||
byte = (unsigned char)((mCANRawDataIntel >> (i*8)) & 0xFF);
|
||||
mCANMsgData[i] = byte;
|
||||
}
|
||||
}
|
||||
|
||||
quint64 CCANMessage::GetRawData()
|
||||
{
|
||||
// return qFromBigEndian(mCANRawDataIntel);
|
||||
return mCANRawDataIntel;
|
||||
}
|
||||
|
||||
QDataStream &operator<<(QDataStream &out, const CCANMessage &source)
|
||||
{
|
||||
out << source.mCANChannel
|
||||
|
||||
@@ -17,7 +17,7 @@ public:
|
||||
unsigned int mCANChannel;
|
||||
unsigned int mCANMsgType; // Type of the message, using the PCAN interface driver encoding defined in PCANbasic.h
|
||||
QByteArray mCANMsgData; // Raw data structure of the message, max size = 8 bytes
|
||||
quint64 mCANRawDataMotorola, mCANRawDataIntel;
|
||||
|
||||
bool mPendingData;
|
||||
|
||||
|
||||
@@ -40,6 +40,11 @@ public:
|
||||
int SetDataFromDriver(quint32 Channel,TPCANMsg CANMsg,TPCANTimestamp CANTimeStamp);
|
||||
int AddSignal(CCANSignal* NewSignal);
|
||||
int UpdateValue(CCANMessage* NewDeviceMessage);
|
||||
int SetRawData(quint64 RawData,int Encoding);
|
||||
quint64 GetRawData();
|
||||
|
||||
private:
|
||||
quint64 mCANRawDataMotorola, mCANRawDataIntel;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
|
||||
#include "CANWatchdog.h"
|
||||
#include "GeneralMessagesLogDispatcher.h"
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
#include <QFloat16>
|
||||
|
||||
CCANWatchdog::CCANWatchdog()
|
||||
{
|
||||
@@ -45,14 +48,49 @@ int CCANWatchdog::Init(CPCANInterface *CANDriverIF, TPCANHandle CANDeviceHandle,
|
||||
|
||||
void CCANWatchdog::WatchdogTimeoutTimerExpired()
|
||||
{
|
||||
char data = mWDTCANMsg.mCANMsgData[7];
|
||||
data ^= (char)0x01;
|
||||
mWDTCANMsg.mCANMsgData[7] = data;
|
||||
quint64 BigData = 0;
|
||||
|
||||
// int seconds = (QTime::currentTime().minute() * 60) + QTime::currentTime().second();
|
||||
// float Hours32bits = (float)((float)seconds / 3600);
|
||||
// Hours32bits += QTime::currentTime().hour();
|
||||
|
||||
// quint16 Hours = static_cast<quint16>(Hours32bits*1000);
|
||||
// quint16 buffer;
|
||||
// memcpy(&buffer,&Hours,2);
|
||||
// BigData |= buffer;
|
||||
// BigData <<= 16;
|
||||
// quint16 DaysSinceALongTimeAgo;
|
||||
// DaysSinceALongTimeAgo = -QDate::currentDate().daysTo(QDate(1899,12,30));
|
||||
// BigData |= DaysSinceALongTimeAgo;
|
||||
// BigData |= 0x100000000;
|
||||
|
||||
BigData = GetCANDateTimeBuffer();
|
||||
|
||||
mWDTCANMsg.SetRawData(BigData,CCANSignal::CAN_SIGNAL_ENCODING_INTEL);
|
||||
mCANDriverIF->SendCANMessage(mCANDeviceHandle,mWDTCANMsg);
|
||||
qDebug("Sending 0x%X to CAN",data);
|
||||
|
||||
// qDebug("Sending 0x%X to CAN",data);
|
||||
//QString LogMsg = QString("Écriture du watchdog. CAN ID %1 Payload: 0x%2 0x%3 0x%4 0x%5 0x%6 0x%7 0x%8 0x%9").arg(mWDTCANMsg.mCANMsgID,0,16).arg(mWDTCANMsg.mCANMsgData.at(7),0,16).arg(mWDTCANMsg.mCANMsgData.at(6),0,16).arg(mWDTCANMsg.mCANMsgData.at(5),0,16).arg(mWDTCANMsg.mCANMsgData.at(4),0,16).arg(mWDTCANMsg.mCANMsgData.at(3),0,16).arg(mWDTCANMsg.mCANMsgData.at(2),0,16).arg(mWDTCANMsg.mCANMsgData.at(1),0,16).arg(mWDTCANMsg.mCANMsgData[0],0,16);
|
||||
QString LogMsg = QString("Écriture du watchdog. CAN ID 0x%1").arg(mWDTCANMsg.mCANMsgID,0,16);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(LogMsg,"CCANWatchdog",true,3);
|
||||
// QString LogMsg = QString("Écriture du watchdog. CAN ID 0x%1").arg(mWDTCANMsg.mCANMsgID,0,16);
|
||||
// CGeneralMessagesLogDispatcher::instance()->AddLogMessage(LogMsg,"CCANWatchdog",true,3);
|
||||
}
|
||||
|
||||
quint64 CCANWatchdog::GetCANDateTimeBuffer()
|
||||
{
|
||||
quint64 OutputBuffer = 0;
|
||||
|
||||
int seconds = (QTime::currentTime().minute() * 60) + QTime::currentTime().second();
|
||||
float Hours32bits = (float)((float)seconds / 3600);
|
||||
Hours32bits += QTime::currentTime().hour();
|
||||
quint16 Hours = static_cast<quint16>(Hours32bits*1000);
|
||||
OutputBuffer |= Hours;
|
||||
OutputBuffer <<= 16;
|
||||
|
||||
quint16 DaysSinceALongTimeAgo;
|
||||
DaysSinceALongTimeAgo = -QDate::currentDate().daysTo(QDate(1899,12,30));
|
||||
OutputBuffer |= DaysSinceALongTimeAgo;
|
||||
|
||||
return OutputBuffer;
|
||||
}
|
||||
|
||||
int CCANWatchdog::StartWDT()
|
||||
|
||||
@@ -6,6 +6,11 @@
|
||||
#include <QTimer>
|
||||
#include "CANMessage.h"
|
||||
|
||||
|
||||
//This class is not a watchdog per say. It manages the update of the CAN register that is sent to the
|
||||
//Parker controller. This controller uses this update as a watchdog signal, but the register contains
|
||||
//some useful data for the Parker controller as well.
|
||||
|
||||
class CCANWatchdog: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -17,6 +22,7 @@ public:
|
||||
int StartWDT();
|
||||
int StopWDT();
|
||||
bool IsInitialized(){return mWDTInitialized;}
|
||||
quint64 GetCANDateTimeBuffer();
|
||||
|
||||
CPCANInterface *mCANDriverIF;
|
||||
unsigned int mWDTPeriod;
|
||||
|
||||
@@ -235,7 +235,7 @@ void CMQTTClientWrapper::MQTTSendTimerExpired()
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(LogMsg,"CMQTTClientWrapper",true,3);
|
||||
|
||||
}
|
||||
qDebug("Sent %d MQTT messages",MessagesList->size());
|
||||
// qDebug("Sent %d MQTT messages",MessagesList->size());
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,17 @@ CLoggingSettingsPage::CLoggingSettingsPage(QWidget *parent) :
|
||||
ui->mCloudMQTTRefreshRateSpinBx->setEnabled(false);
|
||||
ui->mCloudMQTTClientID->setEnabled(false);
|
||||
|
||||
ui->mDevicePresenceAdd1LineEdit->setInputMask("000.000.000.000");
|
||||
ui->mDevicePresenceAdd2LineEdit->setInputMask("000.000.000.000");
|
||||
ui->mDevicePresenceAdd3LineEdit->setInputMask("000.000.000.000");
|
||||
ui->mDevicePresenceAdd4LineEdit->setInputMask("000.000.000.000");
|
||||
ui->mDevicePresenceAdd5LineEdit->setInputMask("000.000.000.000");
|
||||
|
||||
ui->mDevicePresenceAdd1LineEdit->setText("192.168.10.111");
|
||||
ui->mDevicePresenceAdd2LineEdit->setText("192.168.10.222");
|
||||
ui->mDevicePresenceAdd3LineEdit->setText("192.168.10.333");
|
||||
ui->mDevicePresenceAdd4LineEdit->setText("192.168.10.444");
|
||||
ui->mDevicePresenceAdd5LineEdit->setText("192.168.10.555");
|
||||
|
||||
connect(ui->mCancelBtn,&QPushButton::clicked,this,&CLoggingSettingsPage::CancelBtnPressed);
|
||||
connect(ui->mChangeParamsBtn,&QPushButton::clicked,this,&CLoggingSettingsPage::ModifyParamsBtnPressed);
|
||||
|
||||
@@ -32,6 +32,7 @@ private:
|
||||
int UpdateCloudConfig();
|
||||
int UpdateGeneralParams();
|
||||
int UpdateCPUWatchdogParams();
|
||||
int UpdateCANFlagsParams();
|
||||
|
||||
Ui::CLoggingSettingsPage *ui;
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1196</width>
|
||||
<height>676</height>
|
||||
<width>1621</width>
|
||||
<height>797</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -485,6 +485,374 @@
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mCANBusFlagsLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1020</x>
|
||||
<y>30</y>
|
||||
<width>181</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>14</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Flags CANbus</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QGroupBox" name="mCANFlagsGroupBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>1020</x>
|
||||
<y>80</y>
|
||||
<width>411</width>
|
||||
<height>311</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Assignations des flags à un signal CAN</string>
|
||||
</property>
|
||||
<widget class="QLabel" name="mInternetPresenceLbl_3">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>280</x>
|
||||
<y>70</y>
|
||||
<width>41</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>BIT</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mWatchdogMsgIDLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>30</y>
|
||||
<width>111</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>CAN Msg ID (HEX):</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QSpinBox" name="mWatchdogMsgIDSpinBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>150</x>
|
||||
<y>30</y>
|
||||
<width>91</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<number>2048</number>
|
||||
</property>
|
||||
<property name="value">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<property name="displayIntegerBase">
|
||||
<number>16</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mInternetPresenceLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>100</y>
|
||||
<width>131</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Présence Internet</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mWatchdogMsgIDPrefixLbl">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>120</x>
|
||||
<y>30</y>
|
||||
<width>30</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>0x</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mInternetPresBitComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>100</y>
|
||||
<width>65</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="maxCount">
|
||||
<number>63</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="mMQTTPresenceLbl_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>110</x>
|
||||
<y>130</y>
|
||||
<width>141</width>
|
||||
<height>16</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Présence Serveur MQTT</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mMQTTPresenceBitComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>130</y>
|
||||
<width>65</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="currentText">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>-1</number>
|
||||
</property>
|
||||
<property name="maxCount">
|
||||
<number>63</number>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mDevicePresenceActive1ChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>160</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Actif</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="mDevicePresenceAdd1LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>160</y>
|
||||
<width>171</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mDevicePresenceBit1ComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>160</y>
|
||||
<width>65</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mDevicePresenceActive2ChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>190</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Actif</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="mDevicePresenceAdd2LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>190</y>
|
||||
<width>171</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mDevicePresenceBit2ComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>190</y>
|
||||
<width>65</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="mDevicePresenceAdd3LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>220</y>
|
||||
<width>171</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mDevicePresenceBit3ComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>220</y>
|
||||
<width>65</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mDevicePresenceActive3ChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>220</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Actif</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mDevicePresenceActive4ChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>250</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Actif</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mDevicePresenceBit4ComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>250</y>
|
||||
<width>65</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="mDevicePresenceAdd4LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>250</y>
|
||||
<width>171</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QCheckBox" name="mDevicePresenceActive5ChkBx">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>280</y>
|
||||
<width>51</width>
|
||||
<height>20</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Actif</string>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLineEdit" name="mDevicePresenceAdd5LineEdit">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>70</x>
|
||||
<y>280</y>
|
||||
<width>171</width>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QComboBox" name="mDevicePresenceBit5ComboBox">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>260</x>
|
||||
<y>280</y>
|
||||
<width>65</width>
|
||||
<height>22</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>20</x>
|
||||
<y>60</y>
|
||||
<width>241</width>
|
||||
<height>31</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="font">
|
||||
<font>
|
||||
<pointsize>10</pointsize>
|
||||
</font>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Les bits 0 à 30 sont utilisés pour
|
||||
la date et l'heure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</widget>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
||||
Reference in New Issue
Block a user