User manual

CAN API reference
20 © 2007-2010 Analytica GmbH
CANWrite, CANWriteEx
CANWrite, CANWriteEx — Send a CAN telegram to the CAN bus via the AnaGate device.
Syntax
#include <AnaGateDllCan.h>
int CANWrite(int hHandle, int nIdentifier, const char * pcBuffer, int
nBufferLen, int nFlags);
int CANWriteEx(int hHandle, int nIdentifier, const char * pcBuffer, int
nBufferLen, int nFlags, long * pnSeconds, long * pnMicroSeconds);
Parameter
hHandle Valid access handle.
nIdentifier CAN identifier of the sender. Parameter nFlags defines, if the address is in
extended format (29-bit) or standard format (11-bit).
pcBuffer Pointer to the data buffer.
nBufferLen Length of data buffer (max. 8 bytes).
nFlags The format flags are defined as follows.
• Bit 0: If set, the CAN identifier is in extended format (29 bit), otherwise not
(11 bit).
• Bit 1: If set, the telegram is marked as remote frame.
pnSeconds Timestamp of the confirmation of the CAN controller (seconds from 01.01.1970).
pnMicroSeconds Micro seconds portion of the timestamp.
Return value
Returns Null if successful, or an error value otherwise (Appendix A, Return Codes).
Description
Both functions sends a CAN telegram to the CAN bus via the AnaGate device.
The CANWriteEx additionallly returns a timestamp of the time at which the telegram is sent.
Note
With remote frames (RTR = remote transmission request) a destination node can request data
from a source node. The data length is to be set to the number of requested bytes - on the
CAN bus no data is sent only the data size information.
When using the CANWrite bzw. CANWriteEx functions to send remote frames the data
buffer and the buffer size equal to the number of requested bytes have to be set correctly.