.....................................................
response = F_OpenInstancesAndFPAs( "*# *" ); //get first FPA
if( response > 0 )
{
response = F_Set_FPA_index( 1 );
response = F_Initialization();
get_device_names(); //now you can read data from API-DLL
}
.........................................................
int get_device_names( void )
{
int n,k, st, index_bak, max_up_index;
DEVICELIST tmp;
tmp.index = 0; *tmp.name = '\0';
index_bak = F_GetConfig( CFG_MICROCONTROLLER ); //get current uP index
for(k=0; k<MAX_NO_OF_DEVICES; k++)
DeviceList[k] = tmp; //clr device list
max_up_index = 0;
for(k=0; k<MAX_NO_OF_DEVICES; k++)
{
F_SetConfig( CFG_MICROCONTROLLER, k ); //set new uP index
for( n = 0; n<DEVICE_NAME_SIZE; n++ )
{
DeviceList[k].name[n] = char(0xFF & F_Get_Device_Info( DEVICE_NAME+n ));
}
if( DeviceList[k].name[0] == 0 ) break; //break if name is empty
DeviceList[k].index = k;
max_up_index = k;
}
F_SetConfig( CFG_MICROCONTROLLER, index_bak ); //restore uP index
//sort names in the table from min to max.
if( max_up_index > 0 )
for( k=0; k<max_up_index; k++ )
{
st = FALSE;
for( n=1; n <= max_up_index; n++ )
{
if( strcmp( DeviceList[n-1].name, DeviceList[n].name ) >=0 )
{
st = TRUE;
tmp = DeviceList[n-1];
DeviceList[n-1] = DeviceList[n];
DeviceList[n] = tmp;
}
}
67