MX Foundation 4
device_info.c
/*****************************************************************************
//
// File:
// device_info.c
//
// Copyright (c) MAX Technologies Inc. 1988-2015, All Rights Reserved.
// CONFIDENTIAL AND PROPRIETARY INFORMATION WHICH IS THE
// PROPERTY OF MAX TECHNOLOGIES INC.
//
// This example demonstrates the basic usage of device management functions.
//
// Hardware requirements:
// - MAXT Flex1553-PCIe or FlexMulti.
//
*****************************************************************************/
#include "example.h"
//#define LOCAL
int
main(void)
{
uint32 rc=0;
HMXF_SERVER server=0;
HMXF_DEVICE device=0;
MXF_DEVICE_INFO deviceInfo;
MXF_FLASH_INFO flashInfo;
uint64 deviceIndex=0;
uint64 i;
MXF_SENSOR_VALUE sensors[32];
uint64 sensorsCount=0;
MXF_SENSOR_INFO sensorInfo;
memset(&deviceInfo, 0, sizeof(deviceInfo));
memset(&flashInfo, 0, sizeof(flashInfo));
memset(&sensors, 0, sizeof(sensors));
// Connect to MX Foundation library
#ifdef LOCAL
rc = mxfServerConnect("0.0.0.0", "", "", FALSE, &server);
#else
rc = mxfServerConnect("192.168.0.1", "admin", "admin", FALSE, &server);
#endif
if(!rc)
rc = mxfSystemDeviceGet(server, deviceIndex, &device);
// Read device information
if(!rc)
rc = mxfDeviceInfoGet(device, &deviceInfo);
// Read device flash information
if(!rc)
rc = mxfDeviceFlashInfoRead(device, -1, &flashInfo);
// Read device sensors
if(!rc)
rc = mxfSensorsReadAll(device, 32, &sensorsCount, sensors);
if(!rc)
{
// Display device/sensors/modules informations
printf("\n\r");
printf("Device #%"PRIu64" \n\r", deviceInfo.deviceIndex);
printf("--------- \n\r");
printf("\n\r");
printf(" Name : %s \n\r", deviceInfo.name);
printf(" Revision : %s \n\r", deviceInfo.deviceRev);
printf(" Part Number : %s \n\r", flashInfo.partNumber);
printf(" Serial Number : %s \n\r", flashInfo.serialNumber);
printf(" PCB Version : %s \n\r", flashInfo.pcbVersion);
printf(" Modification Rev : %s \n\r", flashInfo.modificationRev);
for(i=0; i < deviceInfo.revisionCount; i++)
printf(" %-19s: %s \n\r", deviceInfo.revisions[i].name, deviceInfo.revisions[i].rev);
for(i=0; i < flashInfo.revisionCount; i++)
printf(" %-19s: %s \n\r", flashInfo.revisions[i].name, flashInfo.revisions[i].rev);
printf(" MAC address : %s \n", flashInfo.macAddress);
printf(" IP address : %s \n", flashInfo.ipAddress);
printf(" IP Netmask : %s \n", flashInfo.ipNetMask);
printf("\n\r");
printf("Sensors \n\r");
printf("------- \n\r");
printf("\n\r");
for(i=0; i < sensorsCount && !rc; i++)
{
rc = mxfSensorsInfoGet(device, sensors[i].sensorId, &sensorInfo);
if(!rc)
printf(" %-19s: %2.2f %s\n\r", sensorInfo.name, sensors[i].value, sensorInfo.unit);
}
printf("\n\r");
printf("Modules \n\r");
printf("------- \n\r");
printf("\n\r");
for(i=0 ; i<deviceInfo.moduleCount; i++)
{
printf(" IO # %"PRId64" : %s \n\r", deviceInfo.modules[i].position, deviceInfo.modules[i].name);
printf(" Type: %02"PRIu64", Rev: %s, RX Nb: %02"PRIu64", TX Nb: %02"PRIu64", Discrete Nb: %02"PRIu64" \n\r",
deviceInfo.modules[i].type,
deviceInfo.modules[i].rev,
deviceInfo.modules[i].rxCount,
deviceInfo.modules[i].txCount,
deviceInfo.modules[i].discreteCount);
}
}
// Catch any previous failing function
if(rc)
{
char buffer[256];
if(mxfSystemErrorStringGet(server, rc, sizeof(buffer), buffer))
sprintf (buffer,"ERROR # 0x%08X", rc);
printf("%s\n\r", buffer);
}
// Disconnect from MX Foundation library
printf("\n\rPress a key to terminate\n\r");
getchar();
return rc;
}
Updated 10/23/2023