Fixed PEAK Win 32 driver, for PEAK Light API 1.x and 2.x
authorJaFojtik
Sat, 04 Feb 2012 14:26:54 +0100
changeset 713 ca2c2dad3a22
parent 697 24a2aec61731
child 714 ab83333fee78
Fixed PEAK Win 32 driver, for PEAK Light API 1.x and 2.x
drivers/can_peak_win32/can_peak_win32.c
drivers/can_peak_win32/can_peak_win32.def
drivers/can_peak_win32/can_peak_win32.vcproj
drivers/can_peak_win32/cancfg.h
--- a/drivers/can_peak_win32/can_peak_win32.c	Fri Feb 03 22:34:44 2012 +0100
+++ b/drivers/can_peak_win32/can_peak_win32.c	Sat Feb 04 14:26:54 2012 +0100
@@ -33,6 +33,21 @@
 #include "cancfg.h"
 #include "can_driver.h"
 #include "def.h"
+
+
+#define VERSION_2
+
+/* dummy implementation for older version. */
+#ifndef VERSION_2
+void CAN_SetRcvEvent(HANDLE hEventx)
+{
+  SetEvent(hEventx);
+}
+#endif
+
+
+
+
 #ifndef extra_PCAN_init_params
 	#define extra_PCAN_init_params /**/
 #else
@@ -56,22 +71,25 @@
 		,print_getenv("PCANInterupt")
 #endif
 
+
 static s_BOARD *first_board = NULL;
-
 //Create the Event for the first board
 HANDLE hEvent1 = NULL;
+CRITICAL_SECTION InitLock1;
+CRITICAL_SECTION InitLock2;
 
 
 #ifdef PCAN2_HEADER_
-	static s_BOARD *second_board = NULL;
-	HANDLE hEvent2 = NULL;
+  static s_BOARD *second_board = NULL;
+  HANDLE hEvent2 = NULL;
 #endif
 
 // Define for rtr CAN message
 #define CAN_INIT_TYPE_ST_RTR MSGTYPE_STANDARD | MSGTYPE_RTR
 
 /***************************************************************************/
-int TranslateBaudeRate(char* optarg){
+static int TranslateBaudeRate(char* optarg)
+{
 	if(!strcmp( optarg, "1M")) return CAN_BAUD_1M;
 	if(!strcmp( optarg, "500K")) return CAN_BAUD_500K;
 	if(!strcmp( optarg, "250K")) return CAN_BAUD_250K;
@@ -85,7 +103,7 @@
 	return 0x0000;
 }
 
-UNS8 canInit (s_BOARD *board)
+static UNS8 canInit (s_BOARD *board)
 {
 	int baudrate;
 	int ret = 0;
@@ -93,52 +111,69 @@
 #ifdef PCAN2_HEADER_
 	// if not the first handler
 	if(second_board == (s_BOARD *)board) {
+		if(hEvent2==NULL)
+		{	/* Create the Event for the first board */
+		  hEvent2 = CreateEvent(NULL, // lpEventAttributes
+							FALSE,  // bManualReset
+							FALSE,  // bInitialState
+							"");    // lpName
+		  InitializeCriticalSection(&InitLock2);
+		}
+
+		EnterCriticalSection(&InitLock2);
 		if(baudrate = TranslateBaudeRate(board->baudrate))
 		{
-			ret = CAN2_Init(baudrate, CAN_INIT_TYPE_ST extra_PCAN_init_params);
-			if(ret != CAN_ERR_OK)
-				return 0;
-		}
-
-		//Create the Event for the first board
-		if(hEvent2 != NULL){
-			hEvent2 = CreateEvent(NULL, // lpEventAttributes
-			                      FALSE,  // bManualReset
-			                      FALSE,  // bInitialState
-			                      "");    // lpName
+		  ret = CAN2_Init(baudrate, CAN_INIT_TYPE_ST extra_PCAN_init_params);
+		  if(ret != CAN_ERR_OK)
+		  {
+		    LeaveCriticalSection(&InitLock2);
+		    return 0;
+		  }
 		}
 		//Set Event Handle for CANReadExt
 		CAN2_SetRcvEvent(hEvent2);
+		LeaveCriticalSection(&InitLock2);
 	}
 	else
 #endif
 	if(first_board == (s_BOARD *)board) {
+		//Create the Event for the first board
+		if(hEvent1==NULL)
+		{
+		  hEvent1 = CreateEvent(NULL, // lpEventAttributes
+							FALSE,  // bManualReset
+							FALSE,  // bInitialState
+							"");    // lpName
+		  InitializeCriticalSection(&InitLock1);
+                }
+
+		EnterCriticalSection(&InitLock1);
 		if(baudrate = TranslateBaudeRate(board->baudrate))
 		{
-			ret = CAN_Init(baudrate, CAN_INIT_TYPE_ST extra_PCAN_init_params);
-			if(ret != CAN_ERR_OK)
-				return 0;
-		}
-		//Create the Event for the first board
-		if(hEvent1 != NULL){
-			hEvent1 = CreateEvent(NULL, // lpEventAttributes
-			                      FALSE,  // bManualReset
-			                      FALSE,  // bInitialState
-			                      "");    // lpName
+		  ret = CAN_Init(baudrate, CAN_INIT_TYPE_ST extra_PCAN_init_params);
+		  if(ret != CAN_ERR_OK)
+		  {
+		    LeaveCriticalSection(&InitLock1);
+		    return 0;
+		  }
 		}
 		//Set Event Handle for CANReadExt
 		CAN_SetRcvEvent(hEvent1);
+		LeaveCriticalSection(&InitLock1);
 	}
 	return 1;
 }
 
 /********* functions which permit to communicate with the board ****************/
-UNS8 __stdcall canReceive_driver (CAN_HANDLE fd0, Message * m)
-{
+UNS8 LIBAPI canReceive_driver(CAN_HANDLE fd0, Message * m)
+{
+static int HeavyCounter = 0;
 	int ret=0;
 	UNS8 data;
 	TPCANMsg peakMsg;
+#ifdef CAN_READ_EX
 	TPCANTimestamp peakRcvTime;
+#endif
 	DWORD Res;
 	DWORD result;
 	// loop until valid message or fatal error
@@ -151,52 +186,82 @@
 			if (result == WAIT_OBJECT_0)
 				Res = CAN2_ReadEx(&peakMsg, &peakRcvTime);
 				// Exit receive thread when handle is no more valid
-				if(Res & CAN_ERR_ILLHANDLE)
+				if(Res & CAN_ERRMASK_ILLHANDLE)
 					return 1;
 		}
 		else
 #endif
 
 		// We read the queue looking for messages.
-		if(first_board == (s_BOARD *)fd0) {
+		if(first_board == (s_BOARD *)fd0) 
+		{
+#ifdef VERSION_2
 			result = WaitForSingleObject(hEvent1, INFINITE);
 			if (result == WAIT_OBJECT_0)
+#endif
 			{
+#ifdef CAN_READ_EX
 				Res = CAN_ReadEx(&peakMsg, &peakRcvTime);
+#else
+				Res = CAN_Read(&peakMsg);
+#endif
 				// Exit receive thread when handle is no more valid
-				if(Res & CAN_ERR_ILLHANDLE)
-					return 1;
+#ifdef CAN_ERRMASK_ILLHANDLE
+				if(Res & CAN_ERRMASK_ILLHANDLE) return 1;
+#else
+				if(Res & CAN_ERR_ILLHANDLE) return 1;
+#endif				
+
+#ifndef VERSION_2
+				if(Res != CAN_ERR_OK) 
+					result = WaitForSingleObject(hEvent1, 1);  	//pooling
+#endif
 			}
 		}
+#ifdef VERSION_2
 		else
 			Res = CAN_ERR_BUSOFF;
-
+#endif
+		
 		// A message was received : we process the message(s)
-		if (Res == CAN_ERR_OK)
-		{
-			// if something different that 11bit or rtr... problem
-			if (peakMsg.MSGTYPE & ~(MSGTYPE_STANDARD | MSGTYPE_RTR))
-			{
-				if (peakMsg.MSGTYPE == CAN_ERR_BUSOFF)
-				{
-					printf ("!!! Peak board read : re-init\n");
-					canInit((s_BOARD*) fd0);
-					usleep (10000);
-				}
-
-				// If status, return status if 29bit, return overrun
-				return peakMsg.MSGTYPE ==
-					MSGTYPE_STATUS ? peakMsg.DATA[2] : CAN_ERR_OVERRUN;
-			}
-			m->cob_id = peakMsg.ID;
-
-			if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST)	/* bits of MSGTYPE_ */
-				m->rtr = 0;
-			else
-				m->rtr = 1;
-			m->len = peakMsg.LEN;	/* count of data bytes (0..8) */
-			for (data = 0; data < peakMsg.LEN; data++)
-				m->data[data] = peakMsg.DATA[data];	/* data bytes, up to 8 */
+		if(Res == CAN_ERR_OK)
+		{			
+		  switch(peakMsg.MSGTYPE)
+		  {
+		    case MSGTYPE_STATUS:
+			  switch(peakMsg.DATA[3])
+		          {
+			    case CAN_ERR_BUSHEAVY: 
+				      break;
+		            case CAN_ERR_BUSOFF: 
+			              printf ("Peak board read BUSOFF: re-init!!!\n");
+				      canInit((s_BOARD*)fd0);
+				      usleep(33);
+				      break;
+			  }
+			  return peakMsg.DATA[3];	/* if something different that 11bit or rtr... problem */
+
+		    case MSGTYPE_STANDARD:		/* bits of MSGTYPE_ */
+		    case MSGTYPE_EXTENDED:
+			  m->rtr = 0;
+			  break;
+
+		    case MSGTYPE_RTR:			/* bits of MSGTYPE_ */
+			  m->rtr = 1;
+			  break;
+
+		    default: return CAN_ERR_OVERRUN;	/* If status, return status if 29bit, return overrun. */
+		    
+		    }
+
+		   m->cob_id = peakMsg.ID;				
+		   if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST)  /* bits of MSGTYPE_ */
+                     m->rtr = 0;
+		   else
+		     m->rtr = 1;
+		   m->len = peakMsg.LEN;		/* count of data bytes (0..8) */
+		   for (data = 0; data < peakMsg.LEN; data++)
+			m->Data[data] = peakMsg.DATA[data];	/* data bytes, up to 8 */
 #if defined DEBUG_MSG_CONSOLE_ON
 			MSG("in : ");
 			print_message(m);
@@ -213,27 +278,30 @@
 				return 1;
 			}
 		}
-	}while(Res != CAN_ERR_OK);
+	} while(Res != CAN_ERR_OK);
 	return 0;
 }
 
 /***************************************************************************/
-UNS8 __stdcall canSend_driver (CAN_HANDLE fd0, Message const * m)
+UNS8 LIBAPI canSend_driver(CAN_HANDLE fd0, Message const *m)
 {
 	UNS8 data;
-	DWORD localerrno;
 	TPCANMsg peakMsg;
 	peakMsg.ID = m->cob_id;	/* 11/29 bit code */
 	if (m->rtr == 0)
-		peakMsg.MSGTYPE = CAN_INIT_TYPE_ST;	/* bits of MSGTYPE_ */
-	else
 	{
-		peakMsg.MSGTYPE = CAN_INIT_TYPE_ST_RTR;	/* bits of MSGTYPE_ */
-	}
+	  if(peakMsg.ID > 0x7FF)
+		peakMsg.MSGTYPE = MSGTYPE_EXTENDED;	/* bits of MSGTYPE_ */
+	  else
+		peakMsg.MSGTYPE = MSGTYPE_STANDARD;	/* bits of MSGTYPE_ */
+	}
+	else	
+		peakMsg.MSGTYPE = MSGTYPE_RTR;		/* bits of MSGTYPE_ */
+	
 	peakMsg.LEN = m->len;
 	/* count of data bytes (0..8) */
 	for (data = 0; data < m->len; data++)
-		peakMsg.DATA[data] = m->data[data];	/* data bytes, up to 8 */
+		peakMsg.DATA[data] = m->Data[data];	/* data bytes, up to 8 */
 
 	do
 	{
@@ -241,19 +309,19 @@
 		// if not the first handler
 		if(second_board == (s_BOARD *)fd0)
 		{
-			errno = localerrno = CAN2_Write (&peakMsg);
+			errno = CAN2_Write (&peakMsg);
 		}
 		else
 #endif
 		if(first_board == (s_BOARD *)fd0)
 			{
-				errno = localerrno = CAN_Write (&peakMsg);
+				errno = CAN_Write (&peakMsg);
 			}
 		else
 			goto fail;
-		if (localerrno)
-		{
-			if (localerrno == CAN_ERR_BUSOFF)
+		if (errno)
+		{
+			if (errno == CAN_ERR_BUSOFF)
 			{
 				printf ("!!! Peak board write : re-init\n");
 				canInit((s_BOARD*)fd0);
@@ -262,7 +330,7 @@
 			usleep (1000);
 		}
 	}
-	while (localerrno != CAN_ERR_OK);
+	while (errno != CAN_ERR_OK);
 #if defined DEBUG_MSG_CONSOLE_ON
 	MSG("out : ");
 	print_message(m);
@@ -273,16 +341,15 @@
 }
 
 /***************************************************************************/
-UNS8 __stdcall canChangeBaudRate_driver( CAN_HANDLE fd, char* baud)
+UNS8 LIBAPI canChangeBaudRate_driver(CAN_HANDLE fd, char* baud)
 {
 	printf("canChangeBaudRate not yet supported by this driver\n");
 	return 0;
 }
 
 /***************************************************************************/
-CAN_HANDLE __stdcall canOpen_driver (s_BOARD * board)
-{
-  char busname[64];
+LIBPUBLIC CAN_HANDLE LIBAPI canOpen_driver(s_BOARD * board)
+{
   char* pEnd;
   int ret;
 
@@ -308,35 +375,36 @@
   return NULL;
 }
 
+
 /***************************************************************************/
-int __stdcall canClose_driver (CAN_HANDLE fd0)
+int LIBAPI canClose_driver(CAN_HANDLE fd0)
 {
 #ifdef PCAN2_HEADER_
-      // if not the first handler
-      if(second_board == (s_BOARD *)fd0)
-      {
-           CAN2_SetRcvEvent(NULL);
-           CAN2_Close ();
-           if(hEvent2)
-           {
-             SetEvent(hEvent2);
-             CloseHandle(hEvent2);
-             hEvent2 = NULL;
-           }
-           second_board = (s_BOARD *)NULL;
-      }else
-#endif
-      if(first_board == (s_BOARD *)fd0)
-      {
-           CAN_SetRcvEvent(NULL);
-           CAN_Close ();
-           if(hEvent1)
-           {
-             SetEvent(hEvent1);
-             CloseHandle(hEvent1);
-             hEvent1 = NULL;
-            }
-           first_board = (s_BOARD *)NULL;
-      }
-      return 0;
-}
+	// if not the first handler
+	if(second_board == (s_BOARD *)fd0)
+	{
+		CAN2_SetRcvEvent(NULL);
+		CAN2_Close ();		
+		if(hEvent2)
+		{
+		  SetEvent(hEvent2);
+		  CloseHandle(hEvent2);		
+		  hEvent2 = NULL;
+		}
+		second_board = (s_BOARD *)NULL;
+	}else
+#endif
+	if(first_board == (s_BOARD *)fd0)
+	{
+		CAN_SetRcvEvent(NULL);
+		CAN_Close ();		
+		if(hEvent1) 
+		{
+                  SetEvent(hEvent1);
+		  CloseHandle(hEvent1);
+		  hEvent1 = NULL;
+                }
+		first_board = (s_BOARD *)NULL;
+	}
+	return 0;
+}
--- a/drivers/can_peak_win32/can_peak_win32.def	Fri Feb 03 22:34:44 2012 +0100
+++ b/drivers/can_peak_win32/can_peak_win32.def	Sat Feb 04 14:26:54 2012 +0100
@@ -4,4 +4,5 @@
    canReceive_driver
    canSend_driver
    canOpen_driver
-   canClose_driver
\ No newline at end of file
+   canClose_driver
+   canChangeBaudRate_driver
\ No newline at end of file
--- a/drivers/can_peak_win32/can_peak_win32.vcproj	Fri Feb 03 22:34:44 2012 +0100
+++ b/drivers/can_peak_win32/can_peak_win32.vcproj	Sat Feb 04 14:26:54 2012 +0100
@@ -1,339 +1,277 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9,00"
+	Version="7.10"
 	Name="can_peak_win32"
 	ProjectGUID="{732EC5B6-C6F1-4783-9BC8-924FFF67BF5A}"
-	Keyword="Win32Proj"
-	TargetFrameworkVersion="131072"
-	>
+	Keyword="Win32Proj">
 	<Platforms>
 		<Platform
-			Name="Win32"
-		/>
+			Name="Win32"/>
 	</Platforms>
-	<ToolFiles>
-	</ToolFiles>
 	<Configurations>
 		<Configuration
 			Name="Debug|Win32"
 			OutputDirectory="../../Debug"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
+			CharacterSet="2">
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="../../include;../../include/win32"
+				AdditionalIncludeDirectories="../../include;../../include/win32;../../../lib/PEAK-2.49/Include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CANpeak_EXPORTS"
-				MinimalRebuild="true"
+				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
 				UsePrecompiledHeader="0"
-				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
+				ProgramDataBaseFileName="$(IntDir)/can_peak_win32.pdb"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="Pcan_usb.lib"
 				OutputFile="$(OutDir)/can_peak_win32.dll"
 				LinkIncremental="2"
-				ModuleDefinitionFile="can_peak_win32.def"
-				GenerateDebugInformation="true"
+				AdditionalLibraryDirectories="&quot;..\..\..\lib\PEAK-2.49\VC_LIB&quot;"
+				ModuleDefinitionFile="can_peak_win32.def"
+				GenerateDebugInformation="TRUE"
 				ProgramDatabaseFile="$(OutDir)/can_peak_win32.pdb"
 				SubSystem="2"
 				OptimizeForWindows98="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				ImportLibrary="$(OutDir)/can_peak_win32.lib"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
+				ImportLibrary="$(OutDir)/can_peak_win32.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 		<Configuration
 			Name="Release|Win32"
 			OutputDirectory="../../Release"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="../../include;../../include/win32"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="../../include;../../include/win32;../../../lib/PEAK-2.49/Include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CANpeak_EXPORTS"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
-			<Tool
-				Name="VCLinkerTool"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="Pcan_usb.lib"
 				OutputFile="$(OutDir)/can_peak_win32.dll"
 				LinkIncremental="1"
-				ModuleDefinitionFile="can_peak_win32.def"
-				GenerateDebugInformation="true"
+				AdditionalLibraryDirectories="&quot;..\..\..\lib\PEAK-2.49\VC_LIB&quot;"
+				ModuleDefinitionFile="can_peak_win32.def"
+				GenerateDebugInformation="TRUE"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
 				OptimizeForWindows98="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				ImportLibrary="$(OutDir)/can_peak_win32.lib"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
+				ImportLibrary="$(OutDir)/can_peak_win32.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 		<Configuration
 			Name="Release UNICODE|Win32"
 			OutputDirectory="&quot;../../Release UNICODE&quot;"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
-			<Tool
-				Name="VCCLCompilerTool"
-				AdditionalIncludeDirectories="../../include;../../include/win32"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="../../include;../../include/win32;../../../lib/PEAK-2.49/Include"
 				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CANpeak_EXPORTS"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="3"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
 				OutputFile="$(OutDir)/can_peak_win32.dll"
 				LinkIncremental="1"
-				ModuleDefinitionFile="can_peak_win32.def"
-				GenerateDebugInformation="true"
+				AdditionalLibraryDirectories="&quot;..\..\..\lib\PEAK-2.49\VC_LIB&quot;"
+				ModuleDefinitionFile="can_peak_win32.def"
+				GenerateDebugInformation="TRUE"
 				SubSystem="2"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
 				OptimizeForWindows98="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				ImportLibrary="$(OutDir)/can_peak_win32.lib"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
+				ImportLibrary="$(OutDir)/can_peak_win32.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 		<Configuration
 			Name="Debug UNICODE|Win32"
 			OutputDirectory="&quot;../../Debug UNICODE&quot;"
 			IntermediateDirectory="$(ConfigurationName)"
 			ConfigurationType="2"
-			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
-			CharacterSet="2"
-			>
-			<Tool
-				Name="VCPreBuildEventTool"
-			/>
-			<Tool
-				Name="VCCustomBuildTool"
-			/>
-			<Tool
-				Name="VCXMLDataGeneratorTool"
-			/>
-			<Tool
-				Name="VCWebServiceProxyGeneratorTool"
-			/>
-			<Tool
-				Name="VCMIDLTool"
-			/>
+			CharacterSet="2">
 			<Tool
 				Name="VCCLCompilerTool"
 				Optimization="0"
-				AdditionalIncludeDirectories="../../include;../../include/win32"
+				AdditionalIncludeDirectories="../../include;../../include/win32;../../../lib/PEAK-2.49/Include"
 				PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;CANpeak_EXPORTS"
-				MinimalRebuild="true"
+				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
-				Detect64BitPortabilityProblems="true"
-				DebugInformationFormat="4"
-			/>
-			<Tool
-				Name="VCManagedResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCResourceCompilerTool"
-			/>
-			<Tool
-				Name="VCPreLinkEventTool"
-			/>
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
 			<Tool
 				Name="VCLinkerTool"
 				OutputFile="$(OutDir)/can_peak_win32.dll"
 				LinkIncremental="2"
-				ModuleDefinitionFile="can_peak_win32.def"
-				GenerateDebugInformation="true"
+				AdditionalLibraryDirectories="&quot;..\..\..\lib\PEAK-2.49\VC_LIB&quot;"
+				ModuleDefinitionFile="can_peak_win32.def"
+				GenerateDebugInformation="TRUE"
 				ProgramDatabaseFile="$(OutDir)/can_peak_win32.pdb"
 				SubSystem="2"
 				OptimizeForWindows98="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				ImportLibrary="$(OutDir)/can_peak_win32.lib"
-				TargetMachine="1"
-			/>
-			<Tool
-				Name="VCALinkTool"
-			/>
-			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
-				Name="VCXDCMakeTool"
-			/>
-			<Tool
-				Name="VCBscMakeTool"
-			/>
-			<Tool
-				Name="VCFxCopTool"
-			/>
-			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
-				Name="VCPostBuildEventTool"
-			/>
+				ImportLibrary="$(OutDir)/can_peak_win32.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release2|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="../../include;../../include/win32;../../../lib/PEAK-2.49/Include"
+				PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;CANpeak_EXPORTS;PCAN2_HEADER_"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="Pcan_usb.lib"
+				OutputFile="$(OutDir)/can_peak2_win32.dll"
+				LinkIncremental="1"
+				AdditionalLibraryDirectories="&quot;..\..\..\lib\PEAK-2.49\VC_LIB&quot;"
+				ModuleDefinitionFile="can_peak_win32.def"
+				GenerateDebugInformation="TRUE"
+				SubSystem="2"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="1"
+				ImportLibrary="$(OutDir)/can_peak_win32.lib"
+				TargetMachine="1"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCWebDeploymentTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
 		</Configuration>
 	</Configurations>
 	<References>
@@ -342,41 +280,27 @@
 		<Filter
 			Name="Source Files"
 			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
-			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
-			>
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
 			<File
-				RelativePath=".\can_peak_win32.c"
-				>
+				RelativePath=".\can_peak_win32.c">
 			</File>
 			<File
-				RelativePath=".\can_peak_win32.def"
-				>
+				RelativePath=".\can_peak_win32.def">
 			</File>
 		</Filter>
 		<Filter
 			Name="Header Files"
 			Filter="h;hpp;hxx;hm;inl;inc;xsd"
-			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
-			>
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
 			<File
-				RelativePath=".\cancfg.h"
-				>
+				RelativePath=".\cancfg.h">
 			</File>
 		</Filter>
 		<Filter
 			Name="Resource Files"
 			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
-			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
-			>
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
 		</Filter>
-		<File
-			RelativePath="..\..\..\..\PC-Card\Lib\Visual C++\Pcan_2pcc.lib"
-			>
-		</File>
-		<File
-			RelativePath="..\..\..\..\PC-Card\Lib\Visual C++\Pcan_pcc.lib"
-			>
-		</File>
 	</Files>
 	<Globals>
 	</Globals>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/drivers/can_peak_win32/cancfg.h	Sat Feb 04 14:26:54 2012 +0100
@@ -0,0 +1,56 @@
+/*
+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.
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) any later version.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+*/
+
+#ifndef __CANCFG_H__
+#define __CANCFG_H__
+
+
+#if defined(__CYGWIN__)
+#include <windef.h>
+#else
+#include <windows.h>
+#endif
+
+// Following part of the file is copied by configure script
+// from choosen PcanLight header file
+//-------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------
+//-------------------------------------------------------------------------------
+
+#ifdef PCAN2_HEADER_
+ #include "pcan_2usb.h"
+ #define CAN_Init(wBTR0BTR1,Type) CAN2_Init(wBTR0BTR1,Type)
+ #define CAN_Close()		  CAN2_Close()
+ #define CAN_Status()		  CAN2_Status()
+ #define CAN_Write(PCANMsg)	  CAN2_Write(PCANMsg)
+ #define CAN_Read(PCANMsg)	  CAN2_Read(PCANMsg)  
+ #define CAN_VersionInfo(lpszTextBuff) CAN2_VersionInfo(lpszTextBuff)
+ #define CAN_ResetClient()       CAN2_ResetClient() 
+ #define CAN_MsgFilter(FromID,ToID,Type) CAN2_MsgFilter(FromID,ToID,Type)
+ #define CAN_ReadEx(pMsgBuff,pRcvTime) CAN2_ReadEx(pMsgBuff,pRcvTime)
+ #define CAN_SetRcvEvent(hEvent) CAN2_SetRcvEvent(hEvent)
+#else
+ #include "pcan_usb.h"
+#endif
+
+#endif
\ No newline at end of file