]> git.kernelconcepts.de Git - karo-tx-redboot.git/blobdiff - packages/devs/can/loop/v2_0/tests/can_overrun1.c
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / packages / devs / can / loop / v2_0 / tests / can_overrun1.c
index cedf3161b33763478efde16e04e5501a84de11bf..9def002ce2938553aca4d800b7526df43a91d0a9 100644 (file)
@@ -110,10 +110,13 @@ void can0_thread(cyg_addrword_t data)
     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
+        1,                                                   // data length code
     };
     
     if (ENOERR != cyg_io_lookup("/dev/can0", &hCAN0)) 
@@ -140,8 +143,8 @@ void can0_thread(cyg_addrword_t data)
     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))
@@ -153,6 +156,11 @@ void can0_thread(cyg_addrword_t data)
             print_can_msg(&tx_msg, "");
         } 
     }
+
+    //
+    // Give the loop back driver time to process all those messages.
+    //
+    cyg_thread_delay(10);
     
     //
     // now check if receive queue is completely filled - that means number of rx events should
@@ -190,7 +198,7 @@ void can0_thread(cyg_addrword_t data)
             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");
                 }