MX Foundation 4
selfTests.c
/*****************************************************************************
//
// File:
// selfTests.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 some self test functions
// for different protocols and some card components.
//
// Hardware requirements:
// - MAXT Flex.
//
*****************************************************************************/
#include "example.h"
#define EXT_LOOPBACK FALSE
#define LOCAL
int main(void)
{
uint32 rc;
HMXF_SERVER server=0;
HMXF_DEVICE device=0;
uint64 result=0;
char info[256]="";
char diagnostic[256]="";
uint64 zone=0;
uint64 port;
int testCnt=0;
int failCnt=0;
// Connects to services and initialize environment
#ifdef LOCAL
rc = mxfServerConnect("0.0.0.0", "", "", FALSE, &server);
#else
rc = mxfServerConnect("192.168.0.1", "admin", "admin", FALSE, &server);
#endif
if(rc!=MAXT_SUCCESS)
{
printf("Failed to connect; rc=0x%08x", rc);
getchar();
return 0;
}
if (!rc)
printf("Starting ...\n\n");
// Gets the device handle
if (!rc)
rc = mxfSystemDeviceGet(server, 0, &device);
if(!rc)
{
printf("mxfSelfTestMEMORY(EXHAUSTIVE) ... ");
rc=mxfSelfTestMEMORY(device, MXF_SELFTEST_LEVEL_EXHAUSTIVE, &result, info, diagnostic);
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
for(port=0; !rc; port++)
{
printf("mxfSelfTestMILSTD1553(port #%"PRIu64") ... ", port);
rc=mxfSelfTestMILSTD1553(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestEBR1553(port #%"PRIu64") ... ", port);
rc=mxfSelfTestEBR1553(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if((rc==MAXT_ERROR_PORT_NOT_FOUND) || (rc == MAXT_ERROR_MODULE_OPT_NOT_SUPPORTED)) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestSERIALASYNC(port #%"PRIu64") ... ", port);
rc=mxfSelfTestSERIALASYNC(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestARINC429(port #%"PRIu64") ... ", port);
rc=mxfSelfTestARINC429(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestARINC717(port #%"PRIu64") ... ", port);
rc=mxfSelfTestARINC717(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestHDLC(port #%"PRIu64") ... ", port);
rc=mxfSelfTestHDLC(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestCSDB(port #%"PRIu64") ... ", port);
rc=mxfSelfTestCSDB(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestARINC629(port #%"PRIu64") ... ", port);
rc=mxfSelfTestARINC629(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestDISCRETE(port #%"PRIu64") ... ", port);
rc=mxfSelfTestDISCRETE(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestARINC708(port #%"PRIu64") ... ", port);
rc=mxfSelfTestARINC708(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestASCB(port #%"PRIu64") ... ", port);
rc=mxfSelfTestASCB(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestHFCE(port #%"PRIu64") ... ", port);
rc=mxfSelfTestHFCE(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port=0; !rc; port++)
{
printf("mxfSelfTestCANBUS(port #%"PRIu64") ... ", port);
rc=mxfSelfTestCANBUS(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc==MAXT_ERROR_PORT_NOT_FOUND) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(port = 0; !rc; port++)
{
printf("mxfSelfTestFLEXDIO(port #%"PRIu64") ... ", port);
rc = mxfSelfTestFLEXDIO(device, port, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc == MAXT_ERROR_PORT_NOT_FOUND) { rc = 0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result ? "FAILED" : "PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(zone=0; !rc; zone++)
{
double value;
printf("mxfSelfTestVOLTAGE(%"PRIu64") ... ", zone);
rc=mxfSelfTestVOLTAGE(device, zone, &value, &result, info, diagnostic);
if(rc==MAXT_ERROR_ZONE) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
printf(" value = %.2f \n", value);
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(zone=0; !rc; zone++)
{
double value;
printf("mxfSelfTestCURRENT(%"PRIu64") ... ", zone);
rc=mxfSelfTestCURRENT(device, zone, &value, &result, info, diagnostic);
if(rc==MAXT_ERROR_ZONE) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
printf(" value = %.2f \n", value);
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
for(zone=0; !rc; zone++)
{
double value;
printf("mxfSelfTestTEMPERATURE(%"PRIu64") ... ", zone);
rc=mxfSelfTestTEMPERATURE(device, zone, &value, &result, info, diagnostic);
if(rc==MAXT_ERROR_ZONE) { rc=0; printf("\r \r"); break; }
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
printf(" value = %.2f \n", value);
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
if(!rc)
{
printf("mxfSelfTestRTCLK() ... ");
rc=mxfSelfTestRTCLK(device, MXF_SELFTEST_LEVEL_QUICK, &result, info, diagnostic);
if(rc == MAXT_ERROR_NOT_SUPPORTED)
{
rc = MAXT_SUCCESS;
printf("\r \r");
}
else
{
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
}
if(!rc)
{
printf("mxfSelfTestDEBUGCOMPORT() ... ");
rc=mxfSelfTestDEBUGCOMPORT(device, 0, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc == MAXT_ERROR_NOT_SUPPORTED)
{
rc = MAXT_SUCCESS;
printf("\r \r");
}
else
{
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
}
if(!rc)
{
printf("mxfSelfTestNVSTORAGE() ...");
rc=mxfSelfTestNVSTORAGE(device, MXF_SELFTEST_LEVEL_QUICK, &result, info, diagnostic);
if((rc == MAXT_ERROR_NVSTORAGE_NOT_FOUND) || (rc == MAXT_ERROR_FUNCTION_NOT_IMPLEMENTED))
{
rc = MAXT_SUCCESS;
printf("\r \r");
}
else
{
printf("\n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
}
if(!rc)
{
printf("mxfSelfTestSYNCIO() ... \n");
rc=mxfSelfTestSYNCIO(device, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
if(!rc)
{
printf("mxfSelfTestIRIGB(Digital) ... \n");
rc=mxfSelfTestIRIGB(device, MXF_SELFTEST_IRIGB_SIGNAL_DIGITAL, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
#if EXT_LOOPBACK
if(!rc)
{
printf("mxfSelfTestIRIGB(AM) ... \n");
rc=mxfSelfTestIRIGB(device, MXF_SELFTEST_IRIGB_SIGNAL_AM, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
if(!rc)
{
printf("mxfSelfTestIRIGB(AM+1PPS External Signal) ... \n");
rc=mxfSelfTestIRIGB(device, MXF_SELFTEST_IRIGB_SIGNAL_AM_1PPS, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
#endif
#ifdef LOCAL
if(!rc)
{
rc=mxfSelfTestETHERNET(device, 0, MXF_SELFTEST_LEVEL_QUICK, EXT_LOOPBACK, &result, info, diagnostic);
if(rc != MAXT_ERROR_NOT_SUPPORTED)
{
printf("mxfSelfTestETHERNET() ... \n");
testCnt++; if(rc || result) failCnt++;
if(rc)
{
printf(" ERROR = 0x%08X \n", rc);
}
else
{
printf(" info = %s \n", info);
printf(" Result = %s \n", result?"FAILED":"PASSED");
if(result)
printf(" diagnostic = %s \n", diagnostic);
}
printf(" \n");
}
else
{
rc = MAXT_SUCCESS;
}
}
#endif
printf(" --------------------------------------- \n");
printf(" TEST %s ", failCnt?"FAILED":"PASSED");
if(failCnt)
printf("(%u of %u tests failed) \n", failCnt, testCnt);
else
printf("\n");
printf(" --------------------------------------- \n");
printf("\n");
}
if(rc)
{
char errorString[256];
printf("\n");
if(mxfSystemErrorStringGet(server, rc, sizeof(errorString), errorString))
sprintf (errorString,"ERROR # 0x%X", rc);
printf("%s\n\r", errorString);
}
printf("\nPress a key to terminate\n");
getchar();
return rc;
}
Updated 10/23/2023