CHANGED: - option to integrate a can driver statically (hack)
authorChristian Taedcke
Fri, 10 Sep 2010 08:55:42 +0200
changeset 638 00bc03cb5606
parent 637 c676669ec3c1
child 639 27c0a025acf3
CHANGED: - option to integrate a can driver statically (hack)
FIXED: - missing () in log message
* * *
CHANGED: - adapted UnLoadCanDriver() for the macro NOT_USE_DYNAMIC_LOADING
drivers/win32/win32.c
--- a/drivers/win32/win32.c	Thu Sep 09 15:50:02 2010 +0200
+++ b/drivers/win32/win32.c	Fri Sep 10 08:55:42 2010 +0200
@@ -75,6 +75,7 @@
 /***************************************************************************/
 UNS8 UnLoadCanDriver(LIB_HANDLE handle)
 {
+#ifndef NOT_USE_DYNAMIC_LOADING
 	if(handle != NULL)
 	{
 		FreeLibrary(handle);
@@ -82,6 +83,10 @@
 		return 0;
 	}
 	return -1;
+#else
+  handle = NULL;
+  return 0;
+#endif //NOT_USE_DYNAMIC_LOADING
 }
 
 /***************************************************************************/
@@ -96,6 +101,7 @@
 	// driver module handle
 	LIB_HANDLE handle = NULL;
 
+#ifndef NOT_USE_DYNAMIC_LOADING
 	if(handle == NULL)
 	{
 		handle = LoadLibrary(driver_name);
@@ -112,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"));
+#else
+  //compiled in...
+  handle = 1; //TODO: remove this hack
+
+  m_canReceive = canReceive_driver;
+	m_canSend = canSend_driver;
+	m_canOpen = canOpen_driver;
+	m_canClose = canClose_driver;
+	m_canChangeBaudRate = canChangeBaudRate_driver;
+#endif
+
 
 	return handle;
 }
@@ -173,7 +190,7 @@
 	}
 	else
 	{
-		MSG("CanOpen : Cannot open board {busname='%s',baudrate='%s'}\n",board->busname, board->baudrate);
+		MSG(("CanOpen : Cannot open board {busname='%s',baudrate='%s'}\n",board->busname, board->baudrate));
 		return NULL;
 	}
 }