Diamond Systems DS-MPE-CAN2L Руководство - Страница 15

Просмотреть онлайн или скачать pdf Руководство для Карта PCI Diamond Systems DS-MPE-CAN2L. Diamond Systems DS-MPE-CAN2L 19 страниц.

9. HOW TO CONFIGURE AND MANAGE THE PORTS USING SOFTWARE

CANLib library provides the set of APIs to configure and manage the CAN ports. The CANLib library can be used
to build the CAN application. It is a shared library built on top of Linux platform. To compile the CANLib shared
library, use the below command
cd CANLib
make
All the CAN APIs prototypes are defined in the can.h file. This file is located in the CANLib directory. Include the
can.h file in the application to use all these APIs.

9.1 API to Configure and Manage CAN ports.

init_can0() & init_can1(): These function will initialize the CAN#0 & CAN#1 ports respectively.
Both these functions will return the CAN file descriptor (fd). The return value of these functions should be
retained for all subsequent operations. Its prototypes are defined in the can.h file. Declare two CAN file
descriptors and retains its return values.
#include "can.h"
...
int can0_fd;
int can1_fd;
...
can0_fd = init_can0() ;
if ( can0_fd < 0 )
{
printf("Error while initializing the CAN#0\n") ;
exit(0) ;
}
...
can1_fd = init_can1() ;
if ( can1_fd < 0 )
{
printf("Error while initializing the CAN#1\n") ;
exit(0) ;
}
Baud rate configuration.
set_baudrate() : This function will configure the baud rate for the specified CAN port. By default it will not
configure any baud rate.
DS-MPE-CAN2L User Manual Rev A.
www.diamondsystems.com
Page 15