beautypg.com

Acrosser AR-B6051 User Manual

Page 48

background image

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

5. 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 );

48