changes merged
author'Gr?gory Tr?lat <gregory.trelat@lolitech.fr>'
Thu, 08 Oct 2009 17:34:44 +0200
changeset 606 15a175f6305d
parent 605 f91ee161b3a1 (current diff)
parent 604 96e632bc1e58 (diff)
child 607 5fec528f66cf
child 609 c59dce78bbad
changes merged
drivers/timers_win32/timers_win32.c
--- a/drivers/AVR/can_AVR.c	Thu Oct 08 17:21:15 2009 +0200
+++ b/drivers/AVR/can_AVR.c	Thu Oct 08 17:34:44 2009 +0200
@@ -174,6 +174,7 @@
 CAN Interrupt
 ******************************************************************************/
 {
+  unsigned char saved_page = CANPAGE;
   unsigned char i;
 
   if (CANGIT & (1 << CANIT))	// is a messagebox interrupt
@@ -211,6 +212,8 @@
     }
   }
 
+  CANPAGE = saved_page;
+
   // Bus Off Interrupt Flag
   if (CANGIT & (1 << BOFFIT))    // Finaly clear the interrupt status register
   {
--- a/drivers/can_socket/can_socket.c	Thu Oct 08 17:21:15 2009 +0200
+++ b/drivers/can_socket/can_socket.c	Thu Oct 08 17:34:44 2009 +0200
@@ -200,7 +200,7 @@
                &loopback, sizeof(loopback));
     if (err) {
         fprintf(stderr, "rt_dev_setsockopt: %s\n", strerror (CAN_ERRNO (err)));
-        goto failure;
+        goto error_close;
     }
   }
   
@@ -211,7 +211,7 @@
                &recv_own_msgs, sizeof(recv_own_msgs));
     if (err) {
         fprintf(stderr, "rt_dev_setsockopt: %s\n", strerror (CAN_ERRNO (err)));
-        goto failure;
+        goto error_close;
     }
   }
 #endif
--- a/drivers/timers_win32/timers_win32.c	Thu Oct 08 17:21:15 2009 +0200
+++ b/drivers/timers_win32/timers_win32.c	Thu Oct 08 17:34:44 2009 +0200
@@ -70,7 +70,10 @@
 
 void WaitReceiveTaskEnd(TASK_HANDLE *Thread)
 {
-	WaitForSingleObject(*Thread, INFINITE);
+	if(WaitForSingleObject(*Thread, 1000) == WAIT_TIMEOUT)
+	{
+		TerminateThread(*Thread, -1);
+	}
 	CloseHandle(*Thread);
 }
 
@@ -121,7 +124,10 @@
 
 	stop_timer = 1;
 	setTimer(0);
-	WaitForSingleObject(timer_thread, INFINITE);
+	if(WaitForSingleObject(timer_thread,1000) == WAIT_TIMEOUT)
+	{
+		TerminateThread(timer_thread, -1);
+	}
 	CloseHandle(timer);
 	CloseHandle(timer_thread);
 }
--- a/drivers/win32/win32.c	Thu Oct 08 17:21:15 2009 +0200
+++ b/drivers/win32/win32.c	Thu Oct 08 17:34:44 2009 +0200
@@ -103,7 +103,7 @@
 
 	if (!handle)
 	{
-		fprintf (stderr, "%s\n", GetLastError());
+		fprintf (stderr, "%d\n", GetLastError());
     	return NULL;
 	}
 
@@ -181,7 +181,7 @@
 /***************************************************************************/
 int canClose(CO_Data * d)
 {
-	UNS8 res;
+	UNS8 res = 1;
 	CANPort* tmp;
 
 	if((CANPort*)d->canHandle)
--- a/src/sdo.c	Thu Oct 08 17:21:15 2009 +0200
+++ b/src/sdo.c	Thu Oct 08 17:34:44 2009 +0200
@@ -113,7 +113,7 @@
 
 /** Returns the index from the bytes 1 and 2 of the SDO
  */
-#define getSDOindex(byte1, byte2) ((byte2 << 8) | (byte1))
+#define getSDOindex(byte1, byte2) (((UNS16)byte2 << 8) | ((UNS16)byte1))
 
 /** Returns the subIndex from the byte 3 of the SDO
  */
@@ -866,7 +866,7 @@
       }
       else {/* So, if it is not an expedited transfert */
 	if (getSDOs(m->data[0])) {
-	  nbBytes = (m->data[4]) + (m->data[5]<<8) + (m->data[6]<<16) + (m->data[7]<<24);
+	  nbBytes = (m->data[4]) + ((UNS32)(m->data[5])<<8) + ((UNS32)(m->data[6])<<16) + ((UNS32)(m->data[7])<<24);
 	  err = setSDOlineRestBytes(d, nodeId, nbBytes);
 	  if (err) {
 	    failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);
@@ -1058,7 +1058,7 @@
       else { /* So, if it is not an expedited transfert */
 	/* Storing the nb of data to receive. */
 	if (getSDOs(m->data[0])) {
-	  nbBytes = m->data[4] + (m->data[5]<<8) + (m->data[6]<<16) + (m->data[7]<<24);
+	  nbBytes = m->data[4] + ((UNS32)(m->data[5])<<8) + ((UNS32)(m->data[6])<<16) + ((UNS32)(m->data[7])<<24);
 	  err = setSDOlineRestBytes(d, line, nbBytes);
 	  if (err) {
 	    failedSDO(d, nodeId, whoami, index, subIndex, SDOABT_GENERAL_ERROR);