User manual

CAN API reference
21 © 2007-2010 Analytica GmbH
See the following example for sending a data telegram to the connected CAN bus.
#include <AnaGateCANDll.h>
int main()
{
char cMsg[] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
int hHandle = 0;
int nRC = 0;
int nFlags = 0x0; // 11bit address + standard (not remote frame)
int nIdentifier = 0x25; // send with CAN ID 0x25;
int nRC = CANOpenDevice(&hHandle, TRUE, TRUE, 0, "192.168.0.254", 5000);
if ( nRC == 0 )
{
// send 8 bytes with CAN id 37
nRC = CANWrite( hHandle, nIdentifier, cMsg, 8, nFlags );
// send a remote frame to CAN id 37 (request 4 data bytes)
nRC = CANWrite( hHandle, nIdentifier, cMsg, 4, 0x02 );
CANCloseDevice(hHandle);
}
return 0;
}
Remarks
The CANWriteEx function is supported by library version 1.4-1.8 or higher.
For devices of type AnaGate CAN (hardware version 1.1.A) the function CANWriteEx is equal to
CANWrite, the return values pnSeconds and pnMicroSeconds will remain unchanged.