Implémentation des lectures des messages
Ajout de la page CAN View
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
|
||||
#include "PCANInterface.h"
|
||||
#include "GeneralMessagesLogDispatcher.h"
|
||||
//#include "CANMessage.h"
|
||||
|
||||
|
||||
|
||||
CPCANInterface::CPCANInterface(QObject *parent) : QObject(parent)
|
||||
@@ -38,6 +40,7 @@ int CPCANInterface::Init()
|
||||
CAN_GetErrorText(Result, 0, strMsg);
|
||||
qDebug("%s",strMsg);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Could not initialize PCAN USB module. Error:%1").arg(strMsg),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -48,8 +51,43 @@ int CPCANInterface::Init()
|
||||
|
||||
int CPCANInterface::DeInit(unsigned short Channel)
|
||||
{
|
||||
CAN_Uninitialize(Channel);
|
||||
CAN_Uninitialize(PCAN_USBBUS1);
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
QList<CCANMessage *> CPCANInterface::ReadCANFullBuffer(unsigned short Channel)
|
||||
{
|
||||
TPCANMsg CANMsg;
|
||||
TPCANTimestamp CANTimeStamp;
|
||||
TPCANStatus stsResult;
|
||||
int cnt = 0;
|
||||
|
||||
QList<CCANMessage *> MessagesList;
|
||||
MessagesList.clear();
|
||||
|
||||
do
|
||||
{
|
||||
// We execute the "Read" function of the PCANBasic
|
||||
stsResult = CAN_Read(Channel, &CANMsg, &CANTimeStamp);
|
||||
if (stsResult != PCAN_ERROR_QRCVEMPTY)
|
||||
{
|
||||
CCANMessage *NewMsg = new CCANMessage(Channel,CANMsg,CANTimeStamp);
|
||||
MessagesList.append(NewMsg);
|
||||
|
||||
// We process the received message
|
||||
qDebug("Type: 0x%X ",CANMsg.MSGTYPE);
|
||||
qDebug("ID: 0x%X",CANMsg.ID);
|
||||
qDebug("Length: %d",CANMsg.LEN);
|
||||
qDebug("Time: micros %d - millis %d - overflow %d", CANTimeStamp.micros, CANTimeStamp.millis, CANTimeStamp.millis_overflow);
|
||||
// qDebug("Data: " << GetDataString(CANMsg.DATA, CANMsg.MSGTYPE, GetLengthFromDLC(CANMsg.DLC)) << "\n";
|
||||
qDebug("Count: %d",cnt++);
|
||||
qDebug("----------------------------------------------------------");
|
||||
|
||||
}
|
||||
}
|
||||
while (!(stsResult & PCAN_ERROR_QRCVEMPTY));
|
||||
|
||||
return MessagesList;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user