beautypg.com

Acrosser AIV-HM76V1FL User Manual

Page 52

background image

AIV-HM76V1FL Series User Manual

52

Acrosser Technology Co., Ltd.

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”);

Syntax:

i32 getCanMessage(struct CanMsg *buffer, u8 count)

Description:

This function receives CAN packets from the CAN bus

subsystem.

Parameters:

This function stores received CAN packages sequentially

at an array of type ‘CanMsg’. The number of packages to

receive is indicated by the parameter ‘count’.

Return Value:

If this function receives the CAN packet successfully, it

returns 0, any other returned value stands for error.
Here is an example:
If the array ‘canAry[]’ of type ‘CanMsg’ has been declared

and allocated. The code listed below will receive 30 CAN

packages from the CAN bus subsystem and stores the

packages in the ‘canAry[]’.

unsigned int result = 0;

struct CanMsg canAry[30];

result = getCanMessage( canAry, 30 );

if( result != 0)

fprintf( stderr, “Fail to receive CAN packets!\n”);