--- a/drivers/can_ixxat_win32/ixxat.cpp Tue May 22 08:07:59 2012 +0200
+++ b/drivers/can_ixxat_win32/ixxat.cpp Tue May 22 08:10:09 2012 +0200
@@ -69,6 +69,8 @@
~IXXAT();
bool send(const Message *m);
bool receive(Message *m);
+
+ static bool isDriverClosed() {return m_driverClosed;}
private:
bool open(int board_number, const char* baud_rate);
bool close();
@@ -86,6 +88,8 @@
UINT16 m_RxQueHdl;
async_access_que<VCI_CAN_OBJ> m_RX_Que;
static IXXAT* m_callbackPtr;
+
+ static bool m_driverClosed;
static UINT_PTR m_watchdogTimerId;
static const unsigned int CAN_BUS_WATCHDOG_INTERVAL_MSEC = 10000;
@@ -103,6 +107,8 @@
UINT_PTR IXXAT::m_watchdogTimerId = 0;
+bool IXXAT::m_driverClosed = false;
+
IXXAT::IXXAT(s_BOARD *board) : m_BoardHdl(0xFFFF),
m_TxQueHdl(0xFFFF),
m_RxQueHdl(0xFFFF)
@@ -244,11 +250,14 @@
//Start CAN Bus-Off watchdog
m_watchdogTimerId = SetTimer(NULL, NULL, IXXAT::CAN_BUS_WATCHDOG_INTERVAL_MSEC, IXXAT::canBusWatchdog);
+ m_driverClosed = false;
+
return true;
}
bool IXXAT::close()
{
+ m_driverClosed = true;
if (m_BoardHdl == 0xFFFF)
return true;
VCI_ResetBoard(m_BoardHdl);
@@ -369,12 +378,14 @@
extern "C"
UNS8 __stdcall canReceive_driver(CAN_HANDLE inst, Message *m)
{
+ if (IXXAT::isDriverClosed()) return 0;
return reinterpret_cast<IXXAT*>(inst)->receive(m) ? 0 : 1;
}
extern "C"
UNS8 __stdcall canSend_driver(CAN_HANDLE inst, Message const *m)
{
+ if (IXXAT::isDriverClosed()) return 0;
return reinterpret_cast<IXXAT*>(inst)->send(m) ? 0 : 1;
}