equal
deleted
inserted
replaced
215 |
215 |
216 /***************************************************************************/ |
216 /***************************************************************************/ |
217 UNS8 canSend_driver (CAN_HANDLE fd0, Message * m) |
217 UNS8 canSend_driver (CAN_HANDLE fd0, Message * m) |
218 { |
218 { |
219 UNS8 data; |
219 UNS8 data; |
|
220 DWORD localerrno; |
220 TPCANMsg peakMsg; |
221 TPCANMsg peakMsg; |
221 peakMsg.ID = m->cob_id; /* 11/29 bit code */ |
222 peakMsg.ID = m->cob_id; /* 11/29 bit code */ |
222 if (m->rtr == 0) |
223 if (m->rtr == 0) |
223 peakMsg.MSGTYPE = CAN_INIT_TYPE_ST; /* bits of MSGTYPE_ */ |
224 peakMsg.MSGTYPE = CAN_INIT_TYPE_ST; /* bits of MSGTYPE_ */ |
224 else |
225 else |
234 { |
235 { |
235 #ifdef PCAN2_HEADER_ |
236 #ifdef PCAN2_HEADER_ |
236 // if not the first handler |
237 // if not the first handler |
237 if(second_board == (s_BOARD *)fd0) |
238 if(second_board == (s_BOARD *)fd0) |
238 { |
239 { |
239 errno = CAN2_Write (&peakMsg); |
240 errno = localerrno = CAN2_Write (&peakMsg); |
240 } |
241 } |
241 else |
242 else |
242 #endif |
243 #endif |
243 if(first_board == (s_BOARD *)fd0) |
244 if(first_board == (s_BOARD *)fd0) |
244 { |
245 { |
245 errno = CAN_Write (&peakMsg); |
246 errno = localerrno = CAN_Write (&peakMsg); |
246 } |
247 } |
247 else |
248 else |
248 goto fail; |
249 goto fail; |
249 if (errno) |
250 if (localerrno) |
250 { |
251 { |
251 if (errno == CAN_ERR_BUSOFF) |
252 if (localerrno == CAN_ERR_BUSOFF) |
252 { |
253 { |
253 printf ("!!! Peak board write : re-init\n"); |
254 printf ("!!! Peak board write : re-init\n"); |
254 canInit((s_BOARD*)fd0); |
255 canInit((s_BOARD*)fd0); |
255 usleep (10000); |
256 usleep (10000); |
256 } |
257 } |
257 usleep (1000); |
258 usleep (1000); |
258 } |
259 } |
259 } |
260 } |
260 while (errno != CAN_ERR_OK); |
261 while (localerrno != CAN_ERR_OK); |
261 #if defined DEBUG_MSG_CONSOLE_ON |
262 #if defined DEBUG_MSG_CONSOLE_ON |
262 MSG("out : "); |
263 MSG("out : "); |
263 print_message(m); |
264 print_message(m); |
264 #endif |
265 #endif |
265 return 0; |
266 return 0; |