Windows CAN DLL driver sanity check.
authorJaFojtik
Fri, 03 Feb 2012 22:13:25 +0100
changeset 696 381af6bb6155
parent 695 0271f08ba819
child 697 24a2aec61731
Windows CAN DLL driver sanity check.
drivers/can_peak_win32/can_peak_win32.c
drivers/win32/win32.c
--- a/drivers/can_peak_win32/can_peak_win32.c	Fri Feb 03 21:42:48 2012 +0100
+++ b/drivers/can_peak_win32/can_peak_win32.c	Fri Feb 03 22:13:25 2012 +0100
@@ -2,6 +2,7 @@
 This file is part of CanFestival, a library implementing CanOpen Stack.
 
 Copyright (C): Edouard TISSERANT and Francis DUPIN
+Modified by: Jaroslav Fojtik
 
 See COPYING file for copyrights details.
 
--- a/drivers/win32/win32.c	Fri Feb 03 21:42:48 2012 +0100
+++ b/drivers/win32/win32.c	Fri Feb 03 22:13:25 2012 +0100
@@ -118,6 +118,17 @@
 	m_canOpen = (CANOPEN_DRIVER_PROC)GetProcAddress(handle, myTEXT("canOpen_driver"));
 	m_canClose = (CANCLOSE_DRIVER_PROC)GetProcAddress(handle, myTEXT("canClose_driver"));
 	m_canChangeBaudRate = (CANCHANGEBAUDRATE_DRIVER_PROC)GetProcAddress(handle, myTEXT("canChangeBaudRate_driver"));
+
+	if(m_canReceive==NULL || m_canSend==NULL || m_canOpen==NULL || m_canClose==NULL || m_canChangeBaudRate==NULL)
+	{
+	  m_canReceive = NULL;
+	  m_canSend = NULL;
+	  m_canOpen = NULL;
+	  m_canClose = NULL;
+	  m_canChangeBaudRate = NULL;
+	  FreeLibrary(handle);
+	  handle = NULL;
+	}
 #else
   //compiled in...
   handle = 1; //TODO: remove this hack
@@ -140,7 +151,7 @@
 	{
 		return m_canSend(((CANPort*)port)->fd, m);
 	}
-	return 1;
+	return 1; /* NOT OK */	
 }
 
 /***************************************************************************/