MX Foundation 4
Putting it together: Hello MXF World

The simple program below is a summary of all the concepts defined previously.

int main()
{
HMXF_SERVER server;
HMXF_DEVICE device=NULL;
HMXF_MODULE module;
HMXF_CHANNEL tx;
HMXF_BUFFER txBuffer;
uint64 count;
uint32 rc;
// Connect to the local server
rc=mxfServerConnect("0.0.0.0", "", "", 0, &server);
// Initialization
if (!rc)
rc = mxfSystemInit(server);
// Obtain the first device handle
if (!rc)
rc = mxfSystemDeviceGet(server, 0, &device);
// Obtain the first ASYNC-EH module handle
if (!rc)
rc = mxfDeviceModuleAllGet(device, MXF_MODULE_ASYNC_EH, 1, &count, &module);
// Obtain the first TX ASYNC channel handle
if (!rc && count)
rc = mxfModuleChannelAllGet(module, MXF_CLASS_ASYNC_ENHANCED, MXF_SCLASS_TX_CHANNEL, 1, &count, &tx);
if(!rc && !count)
rc = MAXT_ERROR_NOT_FOUND;
if (!rc)
{
uint64 txBufferSize = 10*1024;
// Allocate an Aperiodic transmit buffer with HIGH priority
rc=mxfTxAperiodicBufferAlloc(tx, MXF_TXAPERIODIC_PRIORITY_HIGH, txBufferSize, &txBuffer);
}
if (!rc)
{
// Build the message DATAREC and send it.
memset(&rec, 0 , sizeof(rec));
rec.timeTag = 0;
rec.control = 0;
rec.repeatCount = 1;
rec.dataSize = 11;
memcpy(&rec.data[0],"Hello world", 11);
// Transmit the "Hello" string.
rc = mxfTxAperiodicWrite(txBuffer, MXF_TXAPERIODIC_FLAG_DEFAULT, 0, 1, &rec);
}
// Wait for transmission to occur
if(!rc)
mxfSleep(100);
if (rc)
printf("Error code=0x%lX\n", rc);
return 0;
}
Updated 10/23/2023