MX Foundation 4
relaybox.c
/*******************************************************************************
//
// File:
// relaybox.c
//
// Copyright (c) MAX Technologies Inc. 1988-2022, All Rights Reserved.
// CONFIDENTIAL AND PROPRIETARY INFORMATION WHICH IS THE
// PROPERTY OF MAX TECHNOLOGIES INC.
//
// This example shows how to control a RelayBox using Ethernet.
//
// Hardware Requirements:
// - MAXT RelayBox
//
*******************************************************************************/
#include "example.h"
/***************************************************************************************************************/
// Main
/***************************************************************************************************************/
int main(void)
{
uint32 rc;
HMXF_SERVER server=0;
HMXF_DEVICE device=0;
uint64 rotarySw=0, db9=0, relay=0;
// Connect to RelayBox
rc = mxfServerConnect("192.168.0.1", "admin", "admin", TRUE, &server);
if(rc)
{
printf("Failed to connect; rc=0x%08x", rc);
printf("\nPress a key to terminate\n");
getchar();
return 0;
}
printf("\nStarting\n");
// Get the device handle
if (!rc)
rc = mxfSystemDeviceGet(server, 0, &device);
// Get RelayBox current relays configuration
if(!rc)
rc = mxfRelayBoxStatusGet(device, &rotarySw, &db9, NULL, &relay);
// Connect A0-B0, A1-C1, A2-D2, A3-B3-C3, A4-B4-D4, A5-C5-D5, A6-B6-C6-D6
if(!rc)
{
printf("Relays currently set to 0x%016"PRIX64"\n", relay);
if(rotarySw || db9)
printf("Rotary switch and DB9 configuration will override software configuration\n");
rc = mxfRelayBoxConfigSet(device, MXF_RELAYBOX_CONFIG_OPT_MASK, 0x0074006A0059007FULL);
}
// Get RelayBox current relays configuration
if(!rc)
rc = mxfRelayBoxStatusGet(device, NULL, NULL, NULL, &relay);
if(!rc)
{
uint16 i, A, B, C, D;
uint16 mask;
printf("Relays now set to 0x%016"PRIX64"\n", relay);
A = relay & 0xFFFF;
B = (relay >> 16) & 0xFFFF;
C = (relay >> 32) & 0xFFFF;
D = (relay >> 48) & 0xFFFF;
for(i=0; i<16; i++)
{
printf("%02u: ", i);
mask = 1<<i;
if(A & mask)
printf("A");
if(B & mask)
printf("B");
if(C & mask)
printf("C");
if(D & mask)
printf("D");
if((A|B|C|D) & mask)
printf("\n");
else
printf("-\n");
}
}
// Catch any previous error
if (rc)
{
char buffer[256];
rc = mxfSystemErrorStringGet(server, rc, sizeof(buffer), buffer);
printf("%s\n", buffer);
}
printf("\nTerminating\n");
printf("\nPress enter to terminate\n");
getchar();
return rc;
}
Updated 10/23/2023