Changement de l'identification des pucks CAN par device ID plutôt que par Handle
This commit is contained in:
@@ -28,14 +28,30 @@ CPCANInterface::CPCANInterface(QObject *parent) : QObject(parent)
|
||||
CANInterfaceOpened = false;
|
||||
}
|
||||
|
||||
int CPCANInterface::Init(TPCANHandle CANDeviceChannel, TPCANBaudrate CANBaudRate)
|
||||
int CPCANInterface::GetDeviceHandle(quint8 DeviceID, TPCANHandle &Handle)
|
||||
{
|
||||
TPCANHandle TempHandle;
|
||||
QString Parameters = QString("devicetype=pcan_usb, deviceid=%1").arg(DeviceID);
|
||||
if(CAN_LookUpChannel(Parameters.toLocal8Bit().data(),&TempHandle) != PCAN_ERROR_OK)
|
||||
{
|
||||
Handle = 0;
|
||||
return RET_GENERAL_ERROR;
|
||||
}
|
||||
Handle = TempHandle;
|
||||
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Module PCAN trouvé à l'adresse %1 avec le handle 0x%2").arg(DeviceID).arg(Handle,0,16));
|
||||
|
||||
return RET_OK;
|
||||
}
|
||||
|
||||
int CPCANInterface::Init(TPCANHandle CANDeviceHandle, TPCANBaudrate CANBaudRate)
|
||||
{
|
||||
mInterfaceBaudrate = CANBaudRate;
|
||||
mInterfaceCANHandle = CANDeviceChannel;
|
||||
mInterfaceCANHandle = CANDeviceHandle;
|
||||
|
||||
TPCANStatus Result;
|
||||
Result = CAN_Initialize(CANDeviceChannel, CANBaudRate);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initialisation d'un module PCAN. Channel:%1, Baudrate:%2").arg(CANDeviceChannel).arg(CANBaudRate));
|
||||
Result = CAN_Initialize(CANDeviceHandle, CANBaudRate);
|
||||
CGeneralMessagesLogDispatcher::instance()->AddLogMessage(QString("Initialisation d'un module PCAN. Handle:0x%1, Baudrate:%2").arg(CANDeviceHandle,0,16).arg(CANBaudRate));
|
||||
|
||||
if(Result != PCAN_ERROR_OK)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user