fix some minor bugs
authorgreg
Fri, 17 Jul 2009 11:56:24 +0200
changeset 568 84fb13d1b3d2
parent 567 8c71fdc46735
child 569 ecaac955c16a
fix some minor bugs
examples/CANOpenShell/CANOpenShell.c
--- a/examples/CANOpenShell/CANOpenShell.c	Fri Jul 17 11:51:22 2009 +0200
+++ b/examples/CANOpenShell/CANOpenShell.c	Fri Jul 17 11:56:24 2009 +0200
@@ -97,31 +97,33 @@
 void CheckReadInfoSDO(CO_Data* d, UNS8 nodeid)
 {
 	UNS32 abortCode;
-	UNS32 data;
+	UNS32 data=0;
 	UNS32 size=64;
 
 	if(getReadResultNetworkDict(CANOpenShellOD_Data, nodeid, &data, &size, &abortCode) != SDO_FINISHED)
 		printf("Master : Failed in getting information for slave %2.2x, AbortCode :%4.4x \n", nodeid, abortCode);
-
+	else
+	{
+		/* Display data received */
+		switch(get_info_step)
+		{
+			case 1:
+					printf("Device type     : %x\n", data);
+					break;
+			case 2:
+					printf("Vendor ID       : %x\n", data);
+					break;
+			case 3:
+					printf("Product Code    : %x\n", data);
+					break;
+			case 4:
+					printf("Revision Number : %x\n", data);
+					break;
+		}
+	}
 	/* Finalize last SDO transfer with this node */
 	closeSDOtransfer(CANOpenShellOD_Data, nodeid, SDO_CLIENT);
 
-	/* Display data received */
-	switch(get_info_step)
-	{
-		case 1:
-				printf("Device type     : %x\n", data);
-				break;
-		case 2:
-				printf("Vendor ID       : %x\n", data);
-				break;
-		case 3:
-				printf("Product Code    : %x\n", data);
-				break;
-		case 4:
-				printf("Revision Number : %x\n", data);
-				break;
-	}
 	GetSlaveNodeInfo(nodeid);
 }
 
@@ -158,7 +160,7 @@
 void CheckReadSDO(CO_Data* d, UNS8 nodeid)
 {
 	UNS32 abortCode;
-	UNS32 data;
+	UNS32 data=0;
 	UNS32 size=64;
 
 	if(getReadResultNetworkDict(CANOpenShellOD_Data, nodeid, &data, &size, &abortCode) != SDO_FINISHED)
@@ -300,13 +302,9 @@
 int NodeInit(int NodeID, int NodeType)
 {
 	if(NodeType)
-	{
 		CANOpenShellOD_Data = &CANOpenShellMasterOD_Data;
-	}
-	else
-	{
+	else
 		CANOpenShellOD_Data = &CANOpenShellSlaveOD_Data;
-	}
 
 	/* Load can library */
 	LoadCanDriver(LibraryPath);
@@ -474,6 +472,9 @@
 	// Stop timer thread
 	StopTimerLoop(&Exit);
 
+	/* Close CAN board */
+	canClose(CANOpenShellOD_Data);
+
 init_fail:
 	TimerCleanup();
 	return 0;