Diamond Systems DS-MPE-CAN2L 매뉴얼 - 페이지 15
{카테고리_이름} Diamond Systems DS-MPE-CAN2L에 대한 매뉴얼을 온라인으로 검색하거나 PDF를 다운로드하세요. 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