Continuage de dev
This commit is contained in:
@@ -22,14 +22,20 @@
|
||||
|
||||
CPCANInterface::CPCANInterface(QObject *parent) : QObject(parent)
|
||||
{
|
||||
//Init only... values not used.
|
||||
mInterfaceBaudrate = PCAN_BAUD_500K;
|
||||
mInterfaceCANHandle = PCAN_USBBUS1;
|
||||
CANInterfaceOpened = false;
|
||||
}
|
||||
|
||||
int CPCANInterface::Init()
|
||||
int CPCANInterface::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANBaudRate)
|
||||
{
|
||||
QString LogMsg;
|
||||
mInterfaceBaudrate = CANBaudRate;
|
||||
mInterfaceCANHandle = CANDeviceChannel;
|
||||
|
||||
TPCANStatus Result;
|
||||
Result = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
|
||||
// Result = CAN_Initialize(PCAN_USBBUS1, PCAN_BAUD_500K);
|
||||
Result = CAN_Initialize(CANDeviceChannel, CANBaudRate);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initializing PCAN USB module. Channel:%1, Baudrate:%2").arg(PCAN_USBBUS1).arg(PCAN_BAUD_500K));
|
||||
|
||||
if(Result != PCAN_ERROR_OK)
|
||||
@@ -40,18 +46,32 @@ 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);
|
||||
CANInterfaceOpened = false;
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
CANInterfaceOpened = true;
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("PCAN USB init SUCCESS");
|
||||
}
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CPCANInterface::DeInit(unsigned short Channel)
|
||||
int CPCANInterface::DeInit()
|
||||
{
|
||||
CAN_Uninitialize(PCAN_USBBUS1);
|
||||
TPCANStatus Result;
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Uninitializing PCAN USB module ID %1").arg(mInterfaceCANHandle));
|
||||
Result = CAN_Uninitialize(mInterfaceCANHandle) != PCAN_ERROR_OK;
|
||||
if(Result)
|
||||
{
|
||||
char strMsg[256];
|
||||
CAN_GetErrorText(Result, 0, strMsg);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Could not uninitialize PCAN USB module. Error:%1").arg(strMsg),true,CGeneralMessagesLogDispatcher::GEN_MSG_TXT_ERROR_STATUS);
|
||||
}
|
||||
else
|
||||
{
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage("Uninitializing PCAN USB module...");
|
||||
}
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user