User manual

CAN API reference
11 © 2007-2010 Analytica GmbH
Return value
Returns Null if successful, or an error value otherwise (Appendix A, Return Codes).
Description
Opens a TCP/IP connection to an CAN interface of a AnaGate CAN device. With CANOpenDeviceEx it
is possible to set the ethernet layer4 protocol (tcp or udp). If the connection is established, CAN telegrams
can be sent and received.
The connection should be closed with the function CANCloseDevice if not longer needed.
Important
It is recommended to close the connection, because all internally allocated system resources
are freed again and the connected AnaGate device is signalled that the active connection is
not longer in use and can be used again for new connect requests.
See the following example for the initial programming steps.
#include <AnaGateCANDll.h>
int main()
{
int hHandle;
int nRC = CANOpenDevice(&hHandle, TRUE, TRUE, 0, "192.168.0.254", 5000);
if ( nRC == 0 )
{
// ... now do something
CANCloseDevice(hHandle);
}
return 0;
}
Remarks
The CANOpenDeviceEx function is supported for library versions 1.5-1.10 or higher and firmware
version 1.3.7 or higher.
Device models of type AnaGate CAN (hardware version 1.1.A) do not listen for UPD connection requests.
If trying to connect such a device via UPD, the CANOpenDeviceEx returns with a timeout error.
See also
CANCloseDevice
CANRestart