#include "example.h"
#define TEST_DATASIZE 64
#define DATARECS_BUFFER_SIZE_MAX 64*1024
#define SRC_IP_ADRS "10.0.0.111"
#define SRC_UDP_PORT 1234
#define DST_IP_ADRS "10.0.0.222"
#define DST_UDP_PORT 5678
uint32 readSamplingData(HMXF_BUFFER rxBuffer);
int main(void)
{
HMXF_SERVER server = 0;
HMXF_PORT portTx = 0;
HMXF_PORT portRx = 0;
HMXF_VL vlTx = 0, vlRx = 0;
HMXF_BUFFER rxBuffer = 0;
HMXF_MODULE module = 0;
HMXF_DEVICE device = 0;
HMXF_CHANNEL phyChn = 0;
uint32 srcIpAdrs = 0, dstIpAdrs = 0;
uint64 status;
uint64 usedBytes, freeBytes;
uint64 msgCount = 0;
uint32 dataIdx;
uint32 vlid = 100;
uint32 rc;
uint64 count = 0;
#ifndef LOCAL
char szAddress[20];
#endif
#ifdef LOCAL
#else
printf("Enter address of remote MXF4 server (IP or USB)\n\n");
printf(" xxx.xxx.xxx.xxx or usb\n\n");
fgets(szAddress, sizeof(szAddress), stdin);
szAddress[strcspn(szAddress, "\n")] = '\0';
if (!strcmp(szAddress, "usb"))
{
if (!rc && count)
if (!rc && !count)
rc = MAXT_ERROR_NOT_FOUND;
if (rc)
printf("No USB device detected; rc=0x%08x\n", rc);
}
else
{
if (rc)
printf("Error connecting to %s; rc=0x%08x\n", szAddress, rc);
}
#endif
if (rc)
{
printf("Failed to connect; rc=0x%08x\n", rc);
printf("\nPress a key to terminate\n");
getchar();
return 0;
}
if (!rc)
if (!rc)
if (!rc && count)
if (!rc && !count)
rc = MAXT_ERROR_NOT_FOUND;
#ifdef LOOPBACK
if (!rc)
if (!rc)
#endif
if (!rc)
if (!rc)
{
vlParam.
frameType = MXF_A664_FRAME_TYPE_ARINC664;
}
if (!rc)
{
inet_pton(AF_INET, SRC_IP_ADRS, &srcIpAdrs);
srcIpAdrs = ntohl(srcIpAdrs);
inet_pton(AF_INET, DST_IP_ADRS, &dstIpAdrs);
dstIpAdrs = ntohl(dstIpAdrs);
portParam.
portType = MXF_A664_PORT_TYPE_COM;
portParam.
family = MXF_A664_PORT_FAMILY_IPV4;
portParam.
mode = MXF_A664_PORT_MODE_SAMPLING;
}
if (!rc)
{
vlParam.
frameType = MXF_A664_FRAME_TYPE_ARINC664;
}
if (!rc)
{
portParam.
portType = MXF_A664_PORT_TYPE_COM;
portParam.
family = MXF_A664_PORT_FAMILY_IPV4;
portParam.
mode = MXF_A664_PORT_MODE_SAMPLING;
}
if (!rc)
if (!rc)
if (!rc)
if (!rc)
{
if (!rc && (status & MXF_RXSAMPLING_STATUS_RUNNING))
printf("Sampling Running\n");
}
for (count=0; count<10 && !rc; count++)
{
if ((count % 5) == 0)
{
memset(&txRec, 0, sizeof(txRec));
for (dataIdx = 0; dataIdx < TEST_DATASIZE; dataIdx++)
txRec.
data[dataIdx] = (uint8)((dataIdx + ((count*TEST_DATASIZE) & 0xff)));
}
rc = readSamplingData(rxBuffer);
}
if (!rc)
if (!rc)
{
if (!rc && (status & MXF_RXSAMPLING_STATUS_STOPPED))
printf("\nSampling stopped\n");
}
if (!rc)
if (!rc)
if (!rc)
if (!rc)
if (!rc)
printf("\n\nPress a key to terminate rc=0x%08x\n", rc);
getchar();
return rc;
}
uint32 readSamplingData(HMXF_BUFFER rxBuffer)
{
uint64 dataIdx;
uint64 msgCount, bytesCount;
uint32 dataSize;
uint32 rc;
if (!rc)
printf("%llu records received\n\n", msgCount);
if(msgCount)
{
printf("\n data=");
for (dataIdx = 0; dataIdx < dataSize; dataIdx++)
{
printf(
"%02X ", rxRec.
data[dataIdx]);
if (!((dataIdx + 1) % 8) && (dataIdx + 1 < rxRec.
dataSize))
printf("\n ");
}
printf("\n\n");
}
return rc;
}