User manual

SPI API reference
32 © 2007-2010 Analytica GmbH
SPIOpenDevice
SPIOpenDevice — Opens a network connection to an AnaGate SPI device.
Syntax
#include <AnaGateDllSPI.h>
int SPIOpenDevice(int * pHandle, const char * pcIPAddress, int nTimeout);
Parameter
pHandle Pointer to a variable, in which the access handle is saved in the event of a successful
connection to the AnaGate device.
pcIPAddress Network address of the AnaGate partner.
nTimeout Default timeout for accessing the AnaGate in milliseconds.
A timeout is reported if the AnaGate partner does not respond within the defined
timeout period. This global timeout value is valid on the current network connection
for all commands and functions which do not offer a specific timeout value.
Return value
Returns Null if successful, or an error value otherwise (Appendix A, Return Codes).
Description
Opens a TCP/IP connection to an AnaGate SPI (resp. AnaGate Universal Programmer). After the
connection is established, access to the SPI bus is possible.
Note
The AnaGate SPI (resp. the SPI interface of an AnaGate Universal Programmer) does
not allow more than one concurrent network connection. During an established network
connection all new connections are refused.
See the following example for the initial programming steps.
#include <AnaGateDllSPI.h>
int main()
{
int hHandle;
int nRC = SPIOpenDevice(&hHandle, "192.168.0.254", 5000);
if ( nRC == 0 )
{
// ... now do something
SPICloseDevice(hHandle);
}
return 0;
}