DS-MPE-CAN2L User Manual Rev A.1
www.diamondsystems.com
Page 32
The above sample code will transmit the CAN Standard message with CAN ID=0x12 of data length=4 and
message data = {0x1A, 0xAB, 0x22, 0x4D} ;
CAN Receive Prototype.
int check_rx_msg( int can_ch, unsigned char *msgType, unsigned char *rx_data, unsigned int *can_id, unsigned
char *can_msg_len);
Pass the appropriate pointers for calling the check_rx_msg function.
if ( check_rx_msg(0, &msgType, data, &can_id, &dlc) )
{
If (msgType == MSG_STANDARD )
{
// Received message is CAN Standard Message.
}
else if (msgType == MSG_EXTENDED)
{
// Received message is CAN Extended Message.
}
// dlc : Received CAN Data Length
// can_id : Will contain the received CAN Message ID
// Data of dlc length
printf("ID=%x DLC=%d Data : ", can_id, dlc) ;
for (i=0; i< dlc; i++ )
printf("%x ", data[i] ) ;
printf("\n") ;
}
The sample example programs for both transmit and receive can be found in the
DSC_CAN2_PCI_V1.0.2_2015_01_13 directory for the reference.
Compile and build the CAN Application using VC++
Содержание Diamond Systems DS-MPE-CAN2L
Страница 1: ......