return 0x0000;
}
-#define MyCase(fc) case fc: printf(#fc);break;
-void print_message(Message *m)
-{
- int i;
- switch(m->cob_id.w >> 7)
- {
- MyCase(SYNC)
- MyCase(TIME_STAMP)
- MyCase(PDO1tx)
- MyCase(PDO1rx)
- MyCase(PDO2tx)
- MyCase(PDO2rx)
- MyCase(PDO3tx)
- MyCase(PDO3rx)
- MyCase(PDO4tx)
- MyCase(PDO4rx)
- MyCase(SDOtx)
- MyCase(SDOrx)
- MyCase(NODE_GUARD)
- MyCase(NMT)
- }
- printf(" rtr:%d", m->rtr);
- printf(" len:%d", m->len);
- for (i = 0 ; i < m->len ; i++)
- printf(" %02x", m->data[i]);
- printf("\n");
-}
-
void
canInit (s_BOARD *board)
{
int baudrate;
-//#ifdef PCAN2_HEADER_
+#ifdef PCAN2_HEADER_
// if not the first handler
if(second_board == (s_BOARD *)board)
if(baudrate = TranslateBaudeRate(board->baudrate))
CAN2_Init (baudrate,
CAN_INIT_TYPE_ST extra_PCAN_init_params);
-//#endif
+#endif
if(first_board == (s_BOARD *)board)
if(baudrate = TranslateBaudeRate(board->baudrate))
CAN_Init (baudrate,
return peakMsg.MSGTYPE ==
MSGTYPE_STATUS ? peakMsg.DATA[2] : CAN_ERR_OVERRUN;
}
- m->cob_id.w = peakMsg.ID;
+ m->cob_id = peakMsg.ID;
if (peakMsg.MSGTYPE == CAN_INIT_TYPE_ST) /* bits of MSGTYPE_ */
m->rtr = 0;
m->len = peakMsg.LEN; /* count of data bytes (0..8) */
for (data = 0; data < peakMsg.LEN; data++)
m->data[data] = peakMsg.DATA[data]; /* data bytes, up to 8 */
-
+#if defined DEBUG_MSG_CONSOLE_ON
+ MSG("in : ");
+ print_message(m);
+#endif
}else{
//pthread_mutex_unlock (&PeakCan_mutex);
//if (Res != CAN_ERR_OK)
{
UNS8 data;
TPCANMsg peakMsg;
- peakMsg.ID = m->cob_id.w; /* 11/29 bit code */
+ peakMsg.ID = m->cob_id; /* 11/29 bit code */
if (m->rtr == 0)
peakMsg.MSGTYPE = CAN_INIT_TYPE_ST; /* bits of MSGTYPE_ */
else
}
}
while (errno != CAN_ERR_OK);
+#if defined DEBUG_MSG_CONSOLE_ON
+ MSG("out : ");
+ print_message(m);
+#endif
return 0;
fail:
return 1;
}
+/***************************************************************************/
+UNS8 canChangeBaudRate_driver( CAN_HANDLE fd, char* baud)
+{
+ printf("canChangeBaudRate not yet supported by this driver\n");
+ return 0;
+}
+
/***************************************************************************/
CAN_HANDLE
canOpen_driver (s_BOARD * board)
{
char busname[64];
char* pEnd;
-
+
//printf ("Board Busname=%d.\n",strtol(board->busname, &pEnd,0));
if (strtol(board->busname, &pEnd,0) == 0)
{
first_board = board;
printf ("First Board selected\n");
+ canInit(board);
+ return (CAN_HANDLE)board;
}
+ #ifdef PCAN2_HEADER_
if (strtol(board->busname, &pEnd,0) == 1)
{
- second_board = board;
- printf ("Second Board selected\n");
+ second_board = board;
+ printf ("Second Board selected\n");
+ canInit(board);
+ return (CAN_HANDLE)board;
}
- canInit(board);
-
- return (CAN_HANDLE)board;
+ #endif
+ return NULL;
}
/***************************************************************************/