#include "example.h"
#define MAX_TX_SUBFRAMES_TO_TRANSMIT 4 //minimum 4 to have at least one full frame.
uint32 initHandler(HMXF_SERVER server, uint64 deviceIndex, uint64 moduleIndex, uint64 channelIndex, uint64 attrib, uint64* value);
int main(void)
{
uint32 rc;
HMXF_SERVER server=0;
HMXF_DEVICE device=0;
HMXF_MODULE module=0;
HMXF_CHANNEL rxChannels[4];
HMXF_CHANNEL txChannels[4];
HMXF_BUFFER rxBuffer[4];
HMXF_BUFFER txBuffer[4];
uint64 moduleCount=0;
uint64 channelCount=0;
size_t txBufferSize=0;
size_t rxBufferSize=0;
uint64 rxAcqStatus=0;
uint64 msgCount=0;
uint64 byteCount=0;
uint64 data;
uint64 word, subframeSize=128;
uint64 iChannel, indexBuffer;
#ifdef LOCAL
#else
#endif
if(rc!=MAXT_SUCCESS)
{
printf("Failed to connect; rc=0x%08x", rc);
getchar();
return 0;
}
if (!rc)
{
printf("Starting ...\n");
}
if (!rc)
if (!rc)
if(!rc && !moduleCount)
rc = MAXT_ERROR_NOT_FOUND;
if(!rc)
if (!rc && (channelCount == 4))
if(!rc && (channelCount != 4))
rc = MAXT_ERROR_NOT_FOUND;
#ifdef LOOPBACK
for (iChannel = 0; iChannel < 4; iChannel++)
{
if(!rc)
}
#endif
#if (MAX_TX_SUBFRAMES_TO_TRANSMIT < 4)
if(!rc)
printf("Number of subframes to transmit less than 4: synchronization will not occur.\n");
#endif
if(!rc)
{
for (iChannel = 0; iChannel < 4; iChannel++)
{
}
if(!rc)
{
if(!txHostBuffer)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
{
for (iChannel = 0; iChannel < 4; iChannel++)
{
}
if(!rc)
{
if(!rxHostBuffer)
rc = MAXT_ERROR_MEM;
}
}
if(!rc)
for (iChannel = 0; !rc && (iChannel < 4); iChannel++)
{
if(!rc)
if(!rc)
if(!rc)
rc=
mxfAttributeUint64Set(rxChannels[iChannel], KMXF_A717_BIT_ENCODING, VMXF_A717_BIT_ENCODING_BIPOLAR_RZ);
if(!rc)
rc=
mxfAttributeUint64Set(txChannels[iChannel], KMXF_A717_BIT_ENCODING, VMXF_A717_BIT_ENCODING_BIPOLAR_RZ);
if(!rc)
rc=
mxfAttributeUint64Set(rxChannels[iChannel], KMXF_A717_ELECTRICAL_SELECTION, VMXF_A717_ELECTRICAL_SELECT_DEFAULT);
if(!rc)
rc=
mxfAttributeUint64Set(txChannels[iChannel], KMXF_A717_ELECTRICAL_SELECTION, VMXF_A717_ELECTRICAL_SELECT_DEFAULT);
}
for (iChannel = 0; !rc && (iChannel < 4); iChannel++)
rc =
mxfRxAcqStart(rxBuffer[iChannel], MXF_RXACQ_FLAG_DEFAULT, 0, 0);
for (iChannel = 0; !rc && (iChannel < 4); iChannel++)
{
printf("Transmitting on channel %llu ...\n", iChannel);
if(!rc)
{
rec = txHostBuffer;
for(data=0; data<MAX_TX_SUBFRAMES_TO_TRANSMIT; data++)
{
rec->
dataSize = 2 * (uint32)subframeSize;
for(word=0; word < subframeSize ; word++)
{
if (word == 0)
{
switch (data%4)
{
case 0:
break;
case 1:
break;
case 2:
break;
case 3:
break;
default:
break;
}
}
else
rec->
data[word] = (uint16)(0x11*word);
}
}
printf("\n");
}
if(!rc)
rc =
mxfA717TxAperiodicWrite(txBuffer[iChannel], MXF_TXAPERIODIC_FLAG_DEFAULT, 0, MAX_TX_SUBFRAMES_TO_TRANSMIT, txHostBuffer);
}
if(!rc)
mxfSleep((MAX_TX_SUBFRAMES_TO_TRANSMIT+1) * 1000);
for (iChannel = 0; !rc && (iChannel < 4); iChannel++)
{
printf("\nReceiving on channel %llu ...\t", iChannel);
rc =
mxfA717RxAcqRead(rxBuffer[iChannel], 0, rxBufferSize, &rxAcqStatus, &msgCount, &byteCount, rxHostBuffer);
if(!rc)
{
printf("String received count = %llu \n", msgCount);
rec = rxHostBuffer;
for(data=0; data<msgCount && !rc; data++)
{
printf(
"\n%02llu: Timetag=%012llu, Size=%u words\n", data, rec->
timeTag, (rec->
dataSize)/2);
for(word=0; word < subframeSize ; word++)
printf(
"%03X ", rec->
data[word]);
printf("\n");
}
}
if(!rc)
}
for (indexBuffer = 0; indexBuffer < 4; indexBuffer++)
{
if (rxBuffer[indexBuffer])
{
}
if (txBuffer[indexBuffer])
{
}
}
if(txHostBuffer)
free(txHostBuffer);
if(rxHostBuffer)
free(rxHostBuffer);
if(rc)
{
char errorString[200];
sprintf (errorString,"ERROR # 0x%X", rc);
printf("%s\n\r", errorString);
}
printf("Terminating ...\n");
printf("\nPress a key to terminate\n");
getchar();
return rc;
}
uint32 initHandler(HMXF_SERVER server, uint64 deviceIndex, uint64 moduleIndex, uint64 channelIndex, uint64 attrib, uint64* value)
{
HMXF_DEVICE device;
uint32 rc;
channelIndex=channelIndex;
if(attrib == KMXF_CHANNEL_CLASS)
{
if (!rc)
if(!rc && (deviceInfo.
modules[moduleIndex].
type == MXF_MODULE_MULTI_EH))
{
*value = MXF_CLASS_A717;
return TRUE;
}
}
return FALSE;
}