![background image](http://html1.mh-extra.com/html/aim/api-fdx-2-v2/api-fdx-2-v2_getting-started-manual_2871728029.webp)
API-FDX Linux Getting Started Manual
21
GmbH
Section 8 – Programming the API-FDX Module
8. PROGRAMMING THE API-FDX MODULE
8.1. Sample API-FDX-2/4 Source Code
8.1.1. Include the AyI-FDX Header File
//
T
HE
A
Y
I-FDX
A
PPLICATION
I
NTERFACE
H
EADER
F
ILE MUST BE INCLUDED HERE
!!
#
INCLUDE
"
AIFDX
_
DEF
.
H
"
//
D
EFINE SOME
AIM
A
Y
I-FDX
G
LOBALS
A
I
UI
NT
32
G
_
UL
B
OARD
H
ANDLE
=
0;
A
I
UI
NT
32
G
_
UL
P
ORT
1H
ANDLE
=
0;
A
I
UI
NT
32
G
_
UL
P
ORT
2H
ANDLE
=
0;
A
I
UI
NT
32
G
_U
DP
1P
ORT
1H
ANDLE
=
0;
A
I
UI
NT
32
G
_U
DP
2P
ORT
1H
ANDLE
=
0;
A
I
UI
NT
32
G
_U
DP
1P
ORT
2H
ANDLE
=
0;
A
I
U
INT
32
G
_U
DP
2P
ORT
2H
ANDLE
=
0;
8.1.2. Basic Library Functions and AIM Resource Login
Initialize the API, find available AyI-FDX resources, and login to local board and ports.
bool MyFdxInit()
{
DWORD dwTmp;
bool bRetSuccess = false;
bool bFoundLocalServer = false;
TY_SERVER_LIST * px_ServerNames = NULL;
TY_SERVER_LIST * px_TmpServer;
TY_RESOURCE_LIST_ELEMENT * pRLE = NULL;
TY_RESOURCE_LIST_ELEMENT * pRLEHead = NULL;
TY_FDX_CLIENT_INFO x_ClientInfo;
//--- init client-info
sprintf(x_ClientInfo.ac_ClApplication, "AFDX-Sample Application");
sprintf(x_ClientInfo.ac_ClApplicationVersion, "1.0");
dwTmp = MAX_FDX_CLIENT_HOST_NAME;
::GetComputerName(x_ClientInfo.ac_ClHostName, &dwTmp);
dwTmp = MAX_FDX_CLIENT_USER_NAME;
::GetUserName(x_ClientInfo.ac_ClUser, &dwTmp);
//--- application interface initialize
// and get a list of available servers
if (FdxInit(&px_ServerNames) != FDX_OK)
{
printf("API Open Failed!!\n");
if (px_ServerNames != NULL)
{
FdxCmdFreeMemory(pRLEHead, pRLEHead->ul_StructId);
}
return(bRetSuccess);
}