#include "example.h"
#define FILE_SIZE 256*1024*1024 // 256 MB
#define MAX_TX_SUBFRAMES_TO_TRANSMIT 6 //minimum 4 to have at least one full frame.
#define SUBFRAMESIZE 1024
uint32 read717RecordsFromEmbeddedFlash(HMXF_NVSTORAGE flash, uint64 fileIdx);
uint32 initHandler(HMXF_SERVER server, uint64 deviceIndex, uint64 moduleIndex, uint64 channelIndex, uint64 attrib, uint64* value);
uint64 deviceIdx = 0;
uint64 moduleIdx = 0;
int main(void)
{
uint32 rc;
HMXF_SERVER server;
HMXF_DEVICE device=0;
HMXF_MODULE module=0;
HMXF_CHANNEL tx717=0, rx717=0;
HMXF_BUFFER txBuffer717=0;
HMXF_NVSTORAGE flash=0;
uint64 count=0;
uint64 fileIdx=0, fileSize;
uint32 needUnmount=FALSE;
uint64 channelIdx=0;
#ifdef LOCAL
#else
#endif
if(rc!=MAXT_SUCCESS)
{
printf("Failed to connect; rc=0x%08x", rc);
printf("\nPress a key to terminate\n");
getchar();
return 0;
}
printf("Starting\n");
if (!rc)
rc =
mxfChannelAllGet(server, MXF_CLASS_ALL, MXF_SCLASS_ALL, MXF_MODULE_MULTI_EH, 1, &count, &tx717);
if (!rc && !count)
rc = MAXT_ERROR_NOT_FOUND;
if (!rc)
if(!rc)
if(!rc)
if(!rc)
if (!rc)
if(!rc && count)
if (!rc && count)
if (!rc && count)
if(!rc && !count)
rc = MAXT_ERROR_NOT_FOUND;
if (!rc)
if(!rc)
{
if(!txHostBuffer)
rc = MAXT_ERROR_MEM;
}
if(!rc)
#ifdef LOOPBACK
if (!rc)
#endif
#if (MAX_TX_SUBFRAMES_TO_TRANSMIT < 4)
if(!rc)
printf("\nNumber of subframes to transmit less than 4: synchronization will not occur.\n\n");
#endif
if(!rc)
if(!rc)
if(!rc)
if(!rc)
if(!rc)
if(!rc)
if(!rc)
if (!rc)
if (!rc && (nvInfo.
type == MXF_EMBEDDED_NVSTORAGE_TYPE_EMMC))
{
needUnmount = TRUE;
}
if(!rc)
{
if (rc == MAXT_ERROR_NVSTORAGE_NOT_FORMATTED)
{
printf("Formatting...\n");
printf("Done\n");
count = 0;
}
}
if(!rc)
{
if(count)
{
if(!rc)
{
{
fileIdx = 0;
if(!rc)
printf("File #%llu reset\n", fileIdx);
}
else
{
printf("Formatting...\n");
printf("Done\n");
if(!rc)
if(!rc)
printf("File #%llu allocated\n", fileIdx);
}
}
}
else
{
if(!rc)
if(!rc)
printf("File #%llu allocated\n", fileIdx);
}
}
if (!rc)
if(!rc)
rc = writeMsgs(txBuffer717, txHostBuffer);
if (!rc)
rc = read717RecordsFromEmbeddedFlash(flash, fileIdx);
if(!rc)
if (needUnmount)
if(rc)
{
char buffer[256];
sprintf (buffer,"ERROR # 0x%08X", rc);
printf("%s\n\r", buffer);
}
if (txBuffer717)
printf("\nPress enter to terminate\n");
getchar();
return rc;
}
{
uint32 rc=0;
uint32 i;
uint64 word;
for(i=0; !rc && i<MAX_TX_SUBFRAMES_TO_TRANSMIT; i++)
{
recPtr->
dataSize = 2 * (uint32)SUBFRAMESIZE;
for(word=0; word < SUBFRAMESIZE ; word++)
{
if (word == 0)
{
switch (i%4)
{
case 0:
recPtr->
data[word] = 0x247;
break;
case 1:
recPtr->
data[word] = 0x5B8;
break;
case 2:
recPtr->
data[word] = 0xA47;
break;
case 3:
recPtr->
data[word] = 0xDB8;
break;
default:
break;
}
}
else
recPtr->
data[word] = (uint16)(0x11*word);
}
if(!rc)
}
if(!rc)
{
printf("Transmitting ...\n");
}
if (!rc)
mxfSleep((MAX_TX_SUBFRAMES_TO_TRANSMIT+2) * 1000);
if(rc)
printf("Transmit failed; rc=0x%08x\n", rc);
else
printf("\nWriting %d records\n", i);
return rc;
}
uint32 read717RecordsFromEmbeddedFlash(HMXF_NVSTORAGE flash, uint64 fileIdx)
{
uint64 msgReadCnt, byteReadCnt;
uint64 word, data;
uint32 rc=0;
if (!rec717)
rc = MAXT_ERROR_MEM;
if(!rc)
{
if(!p)
rc = MAXT_ERROR_MEM;
}
printf("Reading from flash\n\n");
if(!rc)
{
do
{
if(!rc)
printf("String received count = %llu \n", msgReadCnt);
if(!rc)
{
rec717 = p;
for(data=0; data<msgReadCnt && !rc; data++)
{
printf(
"\n%02llu: Timetag=%012llu, Size=%u words\n", data, rec717->
timeTag, (rec717->
dataSize)/2);
for(word=0; word < SUBFRAMESIZE ; word++)
printf(
"%03X ", rec717->
data[word]);
printf("\n");
}
}
if(rc)
printf("Acquisition read failed; rc=0x%08x\n", rc);
}while(!rc && msgReadCnt);
}
if (rec717)
free(rec717);
return rc;
}
uint32 initHandler(HMXF_SERVER server, uint64 deviceIndex, uint64 moduleIndex, uint64 channelIndex, uint64 attrib, uint64* value)
{
HMXF_DEVICE device;
uint32 rc;
server=server;
deviceIndex=deviceIndex;
if(attrib == KMXF_CHANNEL_CLASS)
{
if (!rc)
if(!rc && (deviceInfo.
modules[moduleIndex].
type == MXF_MODULE_MULTI_EH))
{
if ((channelIndex == 0) || (channelIndex == deviceInfo.
modules[moduleIndex].
txCount))
{
*value = MXF_CLASS_A717;
return TRUE;
}
}
}
return FALSE;
}