Chapter 4 Korenix Library Reference
This section shows how to use Korenix CANbus Library to develop your program.
When you call "make install" in the example directory, the library will be installed to
the /usr/lib path.
4-1
How to Use Library
We use dlopen to load CANBus library. You will see it in the example. Like this
handle = dlopen ("/usr/lib/libmycanbus.so.1", RTLD_NOW);
Use dlsym to take a "handle" of a dynamic library returned by dlopen and the null
terminated symbol name, returning the address where that symbol is loaded.
Init_CanBus = dlsym(handle, "Init_Can");
Call "man dlopen" to detail information of dlopen, dlsym.
All functions (symbol) are listed in next session.
4-2
Functions
The CanPort library provides the following functions
Init_Can
void Init_Can(BYTE BTR0, BYTE BTR1)
Parameters
BTR0
BUS TIMING REGISTER 0
BTR1
BUS TIMING REGISTER 1
This function sets configuration parameters to initialize the CAN controller.
Configuration parameters include baud rate. Valid Baud rate codes can be taken from
the
Baud Rate
Table.
Korenix | Korenix Library Reference
9