using System;
using static MAXT.MXFoundation.mxf;
using System.Runtime.InteropServices;
using System.Text;
namespace DevelopmentAPICSharp
{
class ar429_rx_sampling
{
const int BUFFER_SIZE = 4096;
const int LABEL = 3;
const int SDI = 0;
static void Main(string[] args)
{
UInt32 rc;
UInt64 server;
UInt64 device = 0;
UInt64 module = 0;
var rxChannel = new UInt64[1];
var txChannel = new UInt64[1];
UInt64 rxBuffer = 0;
var txBuffer = new UInt64[2];
UInt64 count = 0;
IntPtr hostBuffer = IntPtr.Zero;
IntPtr hostBufferRead = IntPtr.Zero;
UInt64 schedule = 0;
UInt64 msg = 0;
UInt64 i, j;
UInt64 msgsCount, bytesCount, indexBuffer;
UInt64 sdi, data, ssm, parity;
UInt64 allocated = 0;
UInt64[] label = { LABEL };
#if LOCAL
#else
rc =
mxfServerConnect(
"192.168.0.1",
"admin",
"admin", Convert.ToUInt64(
false), out server);
#endif
if (rc != MAXT_SUCCESS)
{
Console.WriteLine("Failed to connect; rc=0x{0:x8}", rc);
Console.WriteLine("Press a key to terminate");
Console.Read();
return;
}
Console.WriteLine("Starting");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if ((rc == MAXT_SUCCESS) && (count != 0))
if ((rc == MAXT_SUCCESS) && (count == 0))
rc = MAXT_ERROR_NOT_FOUND;
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
#if LOOPBACK
if (rc == MAXT_SUCCESS)
#endif
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
try
{
hostBuffer = Marshal.AllocHGlobal(BUFFER_SIZE);
}
catch (OutOfMemoryException)
{
rc = MAXT_ERROR_MEM;
}
}
if (rc == MAXT_SUCCESS)
{
try
{
hostBufferRead = Marshal.AllocHGlobal(BUFFER_SIZE);
}
catch (OutOfMemoryException)
{
rc = MAXT_ERROR_MEM;
}
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
Console.WriteLine("Sampling started");
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
{
if (rc == MAXT_SUCCESS)
{
Marshal.StructureToPtr(rec429, hostBuffer, false);
}
}
if (rc == MAXT_SUCCESS)
{
if (rc == MAXT_SUCCESS)
{
Marshal.StructureToPtr(rec429, hostBuffer, false);
}
}
if (rc == MAXT_SUCCESS)
{
Console.WriteLine("Running periodic transmission, please wait...");
}
for (i = 0; (i < 10) && (rc == MAXT_SUCCESS); i++)
{
rc =
mxfA429RxSamplingRead(rxBuffer, MXF_RXSAMPLING_FLAG_DEFAULT, 0, BUFFER_SIZE, out msgsCount, out bytesCount, hostBufferRead);
IntPtr recPtr = hostBufferRead;
if (rc == MAXT_SUCCESS)
{
Console.WriteLine("Read {0} messages", msgsCount);
for (j = 0; (rc == MAXT_SUCCESS) && (j < msgsCount); j++)
{
if (rc == MAXT_SUCCESS)
{
Console.Write(
"{0:D2}: Timetag {1}", j, recSamp.
timeTag);
Console.WriteLine("- ARINC word=[{0},{1},{2:x5},{3},{4}]", Convert.ToString((int)label[0], 8).PadLeft(3, '0'), sdi, data, ssm, (parity == VMXF_A429_PARITY_ODD) ? "ODD" : "EVEN");
if (rc == MAXT_SUCCESS)
}
}
}
if (rc != MAXT_SUCCESS)
Console.WriteLine("Sampling read failed; rc={0:x8}", rc);
else
}
if (rc == MAXT_SUCCESS)
if (rc == MAXT_SUCCESS)
if (rc != MAXT_SUCCESS)
{
StringBuilder buffer = new StringBuilder(256);
{
buffer.Clear();
buffer.Append(string.Format("ERROR # 0x{0:x8}", rc));
}
Console.Write(buffer + "\n\r");
}
if (rxBuffer != 0)
for (indexBuffer = 0; indexBuffer < 2; indexBuffer++)
{
if (txBuffer[indexBuffer] != 0)
}
if (hostBuffer != IntPtr.Zero)
Marshal.FreeHGlobal(hostBuffer);
if (hostBufferRead != IntPtr.Zero)
Marshal.FreeHGlobal(hostBufferRead);
Console.WriteLine();
Console.WriteLine("Press enter to terminate");
Console.Read();
return;
}
}
}