diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/ChangeLog ecos/ecos/packages/devs/can/loop/current/ChangeLog
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/ChangeLog	2005-08-25 15:40:36.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/ChangeLog	2007-03-23 16:26:52.000000000 +0100
@@ -1,3 +1,17 @@
+2007-03-23  Uwe Kindler  <uwe_kindler@web.de>
+
+	* cdl/can_loop.cdl: Driver now implements the interfaces
+	  CYGINT_IO_CAN_TX_EVENTS, CYGINT_IO_CAN_STD_CAN_ID, 
+	  CYGINT_IO_CAN_EXT_CAN_ID.
+	  Removed CYGPKG_IO_CAN_LOOP_CFLAGS_ADD and 
+	  CYGPKG_IO_CAN_LOOP_CFLAGS_REMOVE because they had no function.
+	  
+	* src/loop_can.c: Added missing function loop_can_get_config
+	  to make the driver build properly.
+	
+	* tests: Did some fixes and cleanups for all test cases to make them
+	  work properly with the changes in the CAN I/O layer.
+	
 2005-08-15  Uwe Kindler  <uwe_kindler@web.de>
 
 	* Loopback CAN driver created
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/cdl/can_loop.cdl ecos/ecos/packages/devs/can/loop/current/cdl/can_loop.cdl
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/cdl/can_loop.cdl	2005-08-25 15:40:36.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/cdl/can_loop.cdl	2007-03-11 20:04:53.000000000 +0100
@@ -71,6 +71,9 @@
         flavor        bool
         default_value 0
         implements    CYGINT_IO_CAN_TIMESTAMP
+        implements    CYGINT_IO_CAN_TX_EVENTS
+        implements    CYGINT_IO_CAN_STD_CAN_ID
+        implements    CYGINT_IO_CAN_EXT_CAN_ID
         description   "
             This option includes the CAN loop device driver for channel [set ::loopcan]." 
     
@@ -124,28 +127,6 @@
 	    compiler flags used only in building this package,
 	    and details of which tests are built."
 
-
-        cdl_option CYGPKG_IO_CAN_LOOP_CFLAGS_ADD {
-            display "Additional compiler flags"
-            flavor  data
-            no_define
-            default_value { "" }
-            description   "
-                This option modifies the set of compiler flags for
-                building these CAN device drivers. These flags
-                are used in addition to the set of global flags."
-        }
-
-        cdl_option CYGPKG_IO_CAN_LOOP_CFLAGS_REMOVE {
-            display "Suppressed compiler flags"
-            flavor  data
-            no_define
-            default_value { "" }
-            description   "
-                This option modifies the set of compiler flags for
-                building these CAN device drivers. These flags are
-                removed from the set of global flags if present."
-        }
         
         cdl_option CYGPKG_IO_CAN_LOOP_TESTS {
             display "CAN loop device driver tests"
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/src/loop_can.c ecos/ecos/packages/devs/can/loop/current/src/loop_can.c
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/src/loop_can.c	2005-08-25 15:40:36.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/src/loop_can.c	2007-03-11 12:09:05.000000000 +0100
@@ -82,6 +82,8 @@
 static bool loop_can_getevent(can_channel *priv, cyg_can_event *pevent, void *pdata);
 static Cyg_ErrNo loop_can_set_config(can_channel *chan, cyg_uint32 key,
                                      const void *xbuf, cyg_uint32 *len);
+static Cyg_ErrNo loop_can_get_config(can_channel *chan, cyg_uint32 key, 
+                                     const void*  buf,  cyg_uint32* len);
 static void loop_can_start_xmit(can_channel *chan);
 static void loop_can_stop_xmit(can_channel *chan);
 
@@ -129,6 +131,7 @@
 CAN_LOWLEVEL_FUNS(loop_can_lowlevel_funs,
                   loop_can_putmsg,
                   loop_can_getevent,
+                  loop_can_get_config,
                   loop_can_set_config,
                   loop_can_start_xmit,
                   loop_can_stop_xmit
@@ -266,7 +269,9 @@
     loop_can_info *loop_chan = (loop_can_info *)chan->dev_priv;
 
     struct fifo *fwr = loop_chan->write_fifo;
+#ifdef CYGOPT_IO_CAN_TX_EVENT_SUPPORT 
     struct fifo *frd = loop_chan->read_fifo;
+#endif
 
     if( fwr->num == FIFO_SIZE )
     {
@@ -333,6 +338,16 @@
     return ENOERR;
 }
 
+//-------------------------------------------------------------------------
+// Query device configuration
+
+static Cyg_ErrNo 
+loop_can_get_config(can_channel *chan, cyg_uint32 key, 
+                    const void*  buf,  cyg_uint32* len)
+{
+	return ENOERR;
+}
+
 
 //-------------------------------------------------------------------------
 // Enable the transmitter on the device
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_nonblock.c ecos/ecos/packages/devs/can/loop/current/tests/can_nonblock.c
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_nonblock.c	2005-09-13 15:36:37.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/tests/can_nonblock.c	2007-03-14 20:04:53.000000000 +0100
@@ -70,7 +70,7 @@
 #include <cyg/kernel/kapi.h>
 
 // Package option requirements
-#if defined(CYGOPT_IO_CAN_SUPPORT_NONBLOCKING) && !defined(CYGOPT_IO_CAN_SUPPORT_TIMEOUTS)
+#if defined(CYGOPT_IO_CAN_SUPPORT_NONBLOCKING)
 
 //===========================================================================
 //                               DATA TYPES
@@ -107,6 +107,7 @@
     cyg_uint32             len;
     cyg_uint32             blocking;
     cyg_can_event          rx_event;
+    Cyg_ErrNo              res;
 
     blocking = 0;
     len = sizeof(blocking);
@@ -115,12 +116,17 @@
         CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
     } 
     
-    len = sizeof(rx_event); 
+    len = sizeof(rx_event);  
+    res = cyg_io_read(hDrvFlexCAN, &rx_event, &len);
             
-    if (-EAGAIN == cyg_io_read(hDrvFlexCAN, &rx_event, &len))
+    if (-EAGAIN == res)
     {
         CYG_TEST_PASS_FINISH("can_test1 test OK");
     }
+    else if (-EINTR == res)
+    {
+    	CYG_TEST_PASS_FINISH("can_test1 test OK");
+    }
     else
     {
         CYG_TEST_FAIL_FINISH("Error reading from /dev/can0");
@@ -155,9 +161,7 @@
     }
     
     //
-    // create the two threads which access the CAN device driver
-    // a reader thread with a higher priority and a writer thread
-    // with a lower priority
+    // create the main thread
     //
     cyg_thread_create(4, can0_thread, 
                         (cyg_addrword_t) 0,
@@ -172,8 +176,8 @@
     cyg_scheduler_start();
 }
 
-#else // #if defined(CYGOPT_IO_CAN_SUPPORT_NONBLOCKING) && !defined(CYGOPT_IO_CAN_SUPPORT_TIMEOUTS
-#define N_A_MSG "Needs nonblocking calls and disabled timeouts"
+#else // #if defined(CYGOPT_IO_CAN_SUPPORT_NONBLOCKING)
+#define N_A_MSG "Needs nonblocking calls"
 #endif
 
 #else // CYGFUN_KERNEL_API_C
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_overrun1.c ecos/ecos/packages/devs/can/loop/current/tests/can_overrun1.c
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_overrun1.c	2005-08-25 15:40:37.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/tests/can_overrun1.c	2007-03-11 20:08:51.000000000 +0100
@@ -110,7 +110,10 @@
     cyg_can_message    tx_msg =
     {
         0x000,                                               // CAN identifier
-        {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7},    // 8 data bytes
+        data :
+        {
+            {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }// 8 data bytes
+        },
         CYGNUM_CAN_ID_STD,                                   // standard frame
         CYGNUM_CAN_FRAME_DATA,                               // data frame
         0,                                                   // data length code
@@ -140,8 +143,8 @@
     diag_printf("Sending %d CAN messages to /dev/can0\n", buf_info.rx_bufsize + 1);
     for (i = 0; i <= buf_info.rx_bufsize; ++i)
     {
-        tx_msg.id = 0x000 + i;
-        tx_msg.data[0] = i;
+        CYG_CAN_MSG_SET_STD_ID(tx_msg, 0x000 + i);
+        CYG_CAN_MSG_SET_DATA(tx_msg, 0, i);
         len = sizeof(tx_msg);
         
         if (ENOERR != cyg_io_write(hCAN0, &tx_msg, &len))
@@ -190,7 +193,7 @@
             if (rx_event.flags & CYGNUM_CAN_EVENT_TX)
             {
                 print_can_msg(&rx_event.msg, "");
-                if (rx_event.msg.data[0] != (i + 1))
+                if (rx_event.msg.data.bytes[0] != (i + 1))
                 {
                     CYG_TEST_FAIL_FINISH("Received /dev/can0 TX event contains invalid data");
                 }                    
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_overrun2.c ecos/ecos/packages/devs/can/loop/current/tests/can_overrun2.c
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_overrun2.c	2005-08-25 15:40:37.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/tests/can_overrun2.c	2007-03-11 19:58:31.000000000 +0100
@@ -111,7 +111,10 @@
     cyg_can_message    tx_msg =
     {
         0x000,                                               // CAN identifier
-        {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7},    // 8 data bytes
+        data :
+        {
+            {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }// 8 data bytes
+        },
         CYGNUM_CAN_ID_STD,                                   // standard frame
         CYGNUM_CAN_FRAME_DATA,                               // data frame
         2,                                                   // data length code
@@ -148,7 +151,7 @@
         CYG_TEST_FAIL_FINISH("Unexpected RX event for /dev/can0");
     }
     
-    rx_bufsize = *((cyg_uint32 *)rx_event.msg.data);
+    rx_bufsize = *((cyg_uint32 *)rx_event.msg.data.bytes);
     
     //
     // now we send exactly one CAN message more than there is space in the receive buffer
@@ -161,8 +164,8 @@
         // we store the message number as CAN id and in first data byte so
         // a receiver can check this later
         //
-        tx_msg.id = 0x000 + i;
-        tx_msg.data[0] = i;
+        CYG_CAN_MSG_SET_STD_ID(tx_msg, 0x000 + i);
+        CYG_CAN_MSG_SET_DATA(tx_msg, 0, i);
         len = sizeof(tx_msg); 
             
         if (ENOERR != cyg_io_write(hCAN0, &tx_msg, &len))
@@ -216,7 +219,7 @@
     // endianess here because this is a loopback driver test and we will receive
     // our own messages
     //
-    *((cyg_uint32 *)tx_msg.data) = rx_buf_info.rx_bufsize;
+    *((cyg_uint32 *)tx_msg.data.bytes) = rx_buf_info.rx_bufsize;
     len = sizeof(tx_msg); 
     
     //
@@ -261,7 +264,7 @@
             if (rx_event.flags & CYGNUM_CAN_EVENT_RX)
             {
                 print_can_msg(&rx_event.msg, "");
-                if (rx_event.msg.data[0] != (i + 1))
+                if (rx_event.msg.data.bytes[0] != (i + 1))
                 {
                     CYG_TEST_FAIL_FINISH("Received /dev/can1 RX event contains invalid data");
                 }                    
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_rdwr.c ecos/ecos/packages/devs/can/loop/current/tests/can_rdwr.c
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_rdwr.c	2005-08-25 15:40:37.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/tests/can_rdwr.c	2007-03-14 19:57:57.000000000 +0100
@@ -90,6 +90,8 @@
 cyg_thread_entry_t can1_thread;
 thread_data_t      can1_thread_data;
 
+cyg_sem_t          sem_wait;
+
 
 //===========================================================================
 //                          LOCAL FUNCTIONS
@@ -108,11 +110,14 @@
     cyg_can_buf_info_t tx_buf_info;
     cyg_can_message    tx_msg =
     {
-        0x000,                                               // CAN identifier
-        {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7},    // 8 data bytes
-        CYGNUM_CAN_ID_STD,                                   // standard frame
-        CYGNUM_CAN_FRAME_DATA,                               // data frame
-        8,                                                   // data length code
+        0x000,                                                   // CAN identifier
+        data :
+        {
+            {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7},    // 8 data bytes
+        },
+        CYGNUM_CAN_ID_STD,                                       // standard frame
+        CYGNUM_CAN_FRAME_DATA,                                   // data frame
+        8,                                                       // data length code
     };
     
     if (ENOERR != cyg_io_lookup("/dev/can0", &hCAN0)) 
@@ -143,8 +148,8 @@
             // we store the message number as CAN id and in first data byte so
             // a receiver can check this later
             //
-            tx_msg.id = 0x000 + i;
-            tx_msg.data[0] = i;
+            CYG_CAN_MSG_SET_STD_ID(tx_msg, 0x000 + i);
+            CYG_CAN_MSG_SET_DATA(tx_msg, 0, i);
             len = sizeof(tx_msg); 
             
             if (ENOERR != cyg_io_write(hCAN0, &tx_msg, &len))
@@ -155,15 +160,21 @@
             {
                 print_can_msg(&tx_msg, "");
             }
-        }
+        } // for (i = 0; i < 10; ++i)    
         
         //
-        // Now we we give the reader thread a chance to run and to read
-        // the messages      
+        // Give reader thread 200 ticks time for readung all messages. The reader thread
+        // signals the semaphore if it received all transmitted messages
         //
-        cyg_thread_delay(100);
-        CYG_TEST_FAIL_FINISH("Error reading from /dev/can0");                      
-    }
+        if (!cyg_semaphore_timed_wait( &sem_wait,  cyg_current_time( ) + 200 ))
+        {
+        	CYG_TEST_FAIL_FINISH("Waiting for reader thread timed out.");
+        } 
+        else
+        {
+        	CYG_TEST_PASS_FINISH("can_rdwr test OK");
+        }      
+    } // while (1)
 }
 
 
@@ -223,7 +234,7 @@
             // The writer thread stored the message number in CAN id and first
             // data byte so we can check now if we received valid data
             //
-            if ((rx_event.msg.id != i) || (rx_event.msg.data[0] != i))
+            if ((rx_event.msg.id != i) || (rx_event.msg.data.bytes[0] != i))
             {
                 CYG_TEST_FAIL_FINISH("Received CAN message contains unexpected data");
             }
@@ -233,7 +244,10 @@
             }
         } //for (i = 0; i < 10; ++i)
         
-        CYG_TEST_PASS_FINISH("can_rdwr test OK");
+        //
+        // signal successfull reception of all messages
+        //
+        cyg_semaphore_post(&sem_wait);
     } // while (1)
 }
 
@@ -245,6 +259,11 @@
     CYG_TEST_INIT();
     
     //
+    // Initialize the wait semaphore to 0
+    //
+    cyg_semaphore_init( &sem_wait, 0 );
+    
+    //
     // create the two threads which access the CAN device driver
     //
     cyg_thread_create(4, can0_thread, 
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_test_aux.inl ecos/ecos/packages/devs/can/loop/current/tests/can_test_aux.inl
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_test_aux.inl	2005-09-13 15:36:37.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/tests/can_test_aux.inl	2007-03-04 10:46:54.000000000 +0100
@@ -68,11 +68,12 @@
     
     if (pmsg->rtr)
     {
-        diag_printf("%s [ID:%03X] [RTR:%d] [EXT:%d]\n",
+        diag_printf("%s [ID:%03X] [RTR:%d] [EXT:%d] [DLC:%d]\n",
                     pMsg,
                     pmsg->id,
                     pmsg->rtr,
-                    pmsg->ext);
+                    pmsg->ext,
+                    pmsg->dlc);
                     
         return;
     }
@@ -91,14 +92,14 @@
                 pmsg->id,
                 pmsg->rtr,
                 pmsg->ext,
-                pmsg->data[0],
-                pmsg->data[1],
-                pmsg->data[2],
-                pmsg->data[3],
-                pmsg->data[4],
-                pmsg->data[5],
-                pmsg->data[6],
-                pmsg->data[7]);
+                pmsg->data.bytes[0],
+                pmsg->data.bytes[1],
+                pmsg->data.bytes[2],
+                pmsg->data.bytes[3],
+                pmsg->data.bytes[4],
+                pmsg->data.bytes[5],
+                pmsg->data.bytes[6],
+                pmsg->data.bytes[7]);
 }
 
 
@@ -124,7 +125,7 @@
         "ESTY  ",
         "ALOS  ",
         "DEVC  ",
-        "PHY   ",
+        "PHYF  ",
         "PHYH  ",
         "PHYL  "
     };
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_timeout.c ecos/ecos/packages/devs/can/loop/current/tests/can_timeout.c
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_timeout.c	2005-08-25 15:40:37.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/tests/can_timeout.c	2007-03-14 19:43:29.000000000 +0100
@@ -113,6 +113,7 @@
 
     timeout_info.tx_timeout = timeout;
     timeout_info.rx_timeout = timeout;
+    len = sizeof(timeout_info);
     if (ENOERR != cyg_io_set_config(hCAN, CYG_IO_SET_CONFIG_CAN_TIMEOUT ,&timeout_info, &len))
     {
         CYG_TEST_FAIL_FINISH("Error writing config of /dev/can0");
diff -ruN -x 'Entries*' ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_txevent.c ecos/ecos/packages/devs/can/loop/current/tests/can_txevent.c
--- ecos_web_cvs/ecos/packages/devs/can/loop/current/tests/can_txevent.c	2005-08-25 15:40:37.000000000 +0200
+++ ecos/ecos/packages/devs/can/loop/current/tests/can_txevent.c	2007-03-11 20:09:23.000000000 +0100
@@ -110,7 +110,10 @@
     cyg_can_message    tx_msg =
     {
         0x000,                                               // CAN identifier
-        {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7},    // 8 data bytes
+        data :
+        {
+            {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }// 8 data bytes
+        },
         CYGNUM_CAN_ID_STD,                                   // standard frame
         CYGNUM_CAN_FRAME_DATA,                               // data frame
         4,                                                   // data length code
@@ -146,8 +149,8 @@
     diag_printf("Sending %d CAN messages to /dev/can0 \n", buf_info.rx_bufsize);
     for (i = 0; i < buf_info.rx_bufsize; ++i)
     {
-        tx_msg.id = i;
-        tx_msg.data[0] = i;
+        CYG_CAN_MSG_SET_STD_ID(tx_msg, 0x000 + i);
+        CYG_CAN_MSG_SET_DATA(tx_msg, 0, i);
         len = sizeof(tx_msg);
         
         if (ENOERR != cyg_io_write(hCAN0, &tx_msg, &len))
@@ -204,7 +207,7 @@
         // Now check if TX events contain valid data - we know that the ID and the first
         // data byte contain the message number
         //
-        if ((rx_event.msg.id != i) || (rx_event.msg.data[0] != i))
+        if ((rx_event.msg.id != i) || (rx_event.msg.data.bytes[0] != i))
         {
             CYG_TEST_FAIL_FINISH("Received invalid data in TX event");
         }
