Canrcvmsg() – ADLINK PCI-7841/cPCI-7841 User Manual

Page 34

Advertising
background image

26

Function Reference

-1 if error occurs

Remarks

Send a message to an opened CAN port.
Actually, this function copies the data to the
sending queue. Error occurs when the port
has not been opened yet or the packet is a
NULL pointer. You can use the Error and
Event handling functions to handle the
exceptions.

See Also

CanRcvMsg()

Usage

C/C++

#include “pci7841.h
PORT_STRUCT port_struct;
CAN_PACKET sndPacket, rcvPacket;
int handle = CanOpenDriver(0, 0);//open the port

0 of card 0

CanConfigPort(handle, &port_struct);
CanSendMsg(handle, &sndPacket);
if(CanRcvMsg(handle, &rcvPacket) == 0)
{
}
CanCloseDriver(handle);

CanRcvMsg()

Purpose

Receive a can packet from a port

Prototype

C/C++
int CanSendMsg(int handle, CAN_PACKET
*packet);

Parameters

handle : handle retrieve from CanOpen-
Driver()
Packet : CAN_PACKET data

Return Value

Return 0 is successful
-1 if error occurs

Remarks

Receive a message from an opened CAN
port.
There are only 64-bytes FIFO under hard-
ware. It can store from 3 to 21 packets. So
there are memory buffer under driver. When
data comes, the driver would move it from

Advertising