Add print_getenv function wich print extra init params
authorgreg
Mon, 20 Jul 2009 10:55:11 +0200
changeset 574 e5d7f4412a4c
parent 573 29b95f4880e5
child 575 18db803e593f
Add print_getenv function wich print extra init params
drivers/can_peak_win32/can_peak_win32.c
--- a/drivers/can_peak_win32/can_peak_win32.c	Fri Jul 17 20:34:13 2009 +0200
+++ b/drivers/can_peak_win32/can_peak_win32.c	Mon Jul 20 10:55:11 2009 +0200
@@ -35,10 +35,24 @@
 #ifndef extra_PCAN_init_params
 	#define extra_PCAN_init_params /**/
 #else
+	long int print_getenv(const char* pcanparam)
+	{
+		char* param=NULL;
+		long int res=0;
+
+		param = getenv(pcanparam);
+		if(param != NULL){
+			res = strtol(param,NULL,0);
+		}
+		else
+			printf("Environment variable %s not defined !\n", pcanparam);
+		printf("Found environment variable %s : %ld\n", pcanparam ,res);
+		return res;
+	}
 	#define extra_PCAN_init_params\
-		,getenv("PCANHwType") ? strtol(getenv("PCANHwType"),NULL,0):0\
-		,getenv("PCANIO_Port") ? strtol(getenv("PCANIO_Port"),NULL,0):0\
-		,getenv("PCANInterupt") ? strtol(getenv("PCANInterupt"),NULL,0):0
+		,print_getenv("PCANHwType")\
+		,print_getenv("PCANIO_Port")\
+		,print_getenv("PCANInterupt")
 #endif
 
 static s_BOARD *first_board = NULL;