YULTek/Otarcik_CAN/Sources/PCANInterface.cpp
jfmartel 087245571a Ajout du support pour les fichiers CAN database .dbc
Ajout shortcut pour RDP vers le PC dans le champs
2023-01-09 16:45:23 -05:00

56 lines
1.9 KiB
C++

/*******************************************************************************
* *
* Gros Gin électronique *
* 2023 *
* *
* Project: Otarcik CAN *
* *
* *
* *
*******************************************************************************/
/*
Description:
This class interfaces the PCAN USB CAN puck
*/
#include "PCANInterface.h"
#include "GeneralMessagesLogDispatcher.h"
CPCANInterface::CPCANInterface(QObject *parent) : QObject(parent)
{
}
int CPCANInterface::Init()
{
QString LogMsg;
TPCANStatus Result;
Result = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initializing PCAN USB module. Channel:%1, Baudrate:%2").arg(PCAN_USBBUS1).arg(PCAN_BAUD_500K));
if(Result != PCAN_ERROR_OK)
{
// An error occurred, get a text describing the error and show it
//
char strMsg[256];
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);
}
else
{
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("PCAN USB init SUCCESS");
}
return RET_OK;
}
int CPCANInterface::DeInit(unsigned short Channel)
{
CAN_Uninitialize(Channel);
return RET_OK;
}