MX Foundation 4
ar429_selftest.c
/*****************************************************************************
//
// File:
// ar429_selftest.c
//
// Copyright (c) MAX Technologies Inc. 1988-2023, All Rights Reserved.
// CONFIDENTIAL AND PROPRIETARY INFORMATION WHICH IS THE
// PROPERTY OF MAX TECHNOLOGIES INC.
//
// This example demonstrates how to perform a self-test on all ARINC 429
// ports using an external loopback.
//
// Hardware requirements:
// - MAXT ARINC 429 channels
// - TX port must be physically connected to its corresponding RX port (TX0 with RX0, TX1 with RX1, ...).
//
*****************************************************************************/
#include "example.h"
#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 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) {
for(port=0; !rc; port++) {
printf("mxfSelfTestARINC429(port #%"PRIu64") ... ", port);
rc=mxfSelfTestARINC429(device, port, MXF_SELFTEST_LEVEL_QUICK, VMXF_DISABLE, &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");
}
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