comparison packages/devs/can/loop/current/tests/can_overrun2.c @ 2377:1ca46bebd705

* AT91SAM7 CAN driver package created * cdl/can_at91sam7.cdl * include/can_at91sam7.inl * src/can_at91sam7.c
author asl
date Mon, 26 Mar 2007 10:38:04 +0000
parents f929becf4af2
children 74dbf4c3f2e1
comparison
equal deleted inserted replaced
2376:244e21c63018 2377:1ca46bebd705
109 cyg_can_buf_info_t tx_buf_info; 109 cyg_can_buf_info_t tx_buf_info;
110 cyg_can_event rx_event; 110 cyg_can_event rx_event;
111 cyg_can_message tx_msg = 111 cyg_can_message tx_msg =
112 { 112 {
113 0x000, // CAN identifier 113 0x000, // CAN identifier
114 {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7}, // 8 data bytes 114 data :
115 {
116 {0x00, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 }// 8 data bytes
117 },
115 CYGNUM_CAN_ID_STD, // standard frame 118 CYGNUM_CAN_ID_STD, // standard frame
116 CYGNUM_CAN_FRAME_DATA, // data frame 119 CYGNUM_CAN_FRAME_DATA, // data frame
117 2, // data length code 120 2, // data length code
118 }; 121 };
119 122
146 if (!(rx_event.flags & CYGNUM_CAN_EVENT_RX) || (rx_event.flags & !CYGNUM_CAN_EVENT_RX)) 149 if (!(rx_event.flags & CYGNUM_CAN_EVENT_RX) || (rx_event.flags & !CYGNUM_CAN_EVENT_RX))
147 { 150 {
148 CYG_TEST_FAIL_FINISH("Unexpected RX event for /dev/can0"); 151 CYG_TEST_FAIL_FINISH("Unexpected RX event for /dev/can0");
149 } 152 }
150 153
151 rx_bufsize = *((cyg_uint32 *)rx_event.msg.data); 154 rx_bufsize = *((cyg_uint32 *)rx_event.msg.data.bytes);
152 155
153 // 156 //
154 // now we send exactly one CAN message more than there is space in the receive buffer 157 // now we send exactly one CAN message more than there is space in the receive buffer
155 // this should cause an RX ovverun in receive buffer 158 // this should cause an RX ovverun in receive buffer
156 // 159 //
159 { 162 {
160 // 163 //
161 // we store the message number as CAN id and in first data byte so 164 // we store the message number as CAN id and in first data byte so
162 // a receiver can check this later 165 // a receiver can check this later
163 // 166 //
164 tx_msg.id = 0x000 + i; 167 CYG_CAN_MSG_SET_STD_ID(tx_msg, 0x000 + i);
165 tx_msg.data[0] = i; 168 CYG_CAN_MSG_SET_DATA(tx_msg, 0, i);
166 len = sizeof(tx_msg); 169 len = sizeof(tx_msg);
167 170
168 if (ENOERR != cyg_io_write(hCAN0, &tx_msg, &len)) 171 if (ENOERR != cyg_io_write(hCAN0, &tx_msg, &len))
169 { 172 {
170 CYG_TEST_FAIL_FINISH("Error writing to /dev/can0"); 173 CYG_TEST_FAIL_FINISH("Error writing to /dev/can0");
214 // 217 //
215 // we store size of rx buffer in CAN message. We do not need to care about 218 // we store size of rx buffer in CAN message. We do not need to care about
216 // endianess here because this is a loopback driver test and we will receive 219 // endianess here because this is a loopback driver test and we will receive
217 // our own messages 220 // our own messages
218 // 221 //
219 *((cyg_uint32 *)tx_msg.data) = rx_buf_info.rx_bufsize; 222 *((cyg_uint32 *)tx_msg.data.bytes) = rx_buf_info.rx_bufsize;
220 len = sizeof(tx_msg); 223 len = sizeof(tx_msg);
221 224
222 // 225 //
223 // as soon as we send a CAN message, thread 0 will resume because it is waiting 226 // as soon as we send a CAN message, thread 0 will resume because it is waiting
224 // for a message 227 // for a message
259 else 262 else
260 { 263 {
261 if (rx_event.flags & CYGNUM_CAN_EVENT_RX) 264 if (rx_event.flags & CYGNUM_CAN_EVENT_RX)
262 { 265 {
263 print_can_msg(&rx_event.msg, ""); 266 print_can_msg(&rx_event.msg, "");
264 if (rx_event.msg.data[0] != (i + 1)) 267 if (rx_event.msg.data.bytes[0] != (i + 1))
265 { 268 {
266 CYG_TEST_FAIL_FINISH("Received /dev/can1 RX event contains invalid data"); 269 CYG_TEST_FAIL_FINISH("Received /dev/can1 RX event contains invalid data");
267 } 270 }
268 } 271 }
269 else 272 else