
AIV-QM97V1FL Series User Manual
58
Acrosser Technology Co., Ltd.
Syntax:
i32 setCanBaudRate(u8 baud)
Description:
This function sets the Baud Rate of the CAN Bus.
Parameters:
It takes an ‘unsigned char’ as the parameter and sets the
Baud Rate according to the value stored at the parameter
‘baud’. The correspondence between the Baud rate and
the value to set to the function is the same as the table
listed in the previous API ‘getCanBaudRate( )’
Return Value:
If this function sets the baud rate successfully, it returns 0,
any other returned value stands for error.
Syntax:
i32 sendCanMessage(struct CanMsg *buffer, u8 count)
Description:
This function sends out CAN packages over the CAN bus.
Parameters:
If there is more than one CAN packet to send, these CAN
packages are stored in an array of type ‘CanMsg’. This
function sends out packets in a sequential fashion. The
memory address of the first CAN packet to be sent is
pointed at by the parameter ‘buffer’. The number of CAN
packets to be sent is indicated by the parameter ‘count’.
Return Value:
If this function sends the CAN packet successfully, it
returns 0, any other returned value stands for error.
Here is an example:
If the CAN packets in the array ‘canAry[]’ have been
initialized. The code listed below will send out the CAN
packets in the ‘canAry[]’ over the CAN bus.
unsigned int result = 0;
struct CanMsg canAry[30];
/* …
Initialize the CAN packages in the
canAry[30]
*/
result = sendCanMessages(canAry, 30);
if(result != 0)
fprintf(stderr, “Send CAN package
error!\n”);