I am trying to read data from a device via a .net API. The read function has the following interface definition:
uint32 mxfASCBRxSamplingRead ( HMXF_BUFFER buffer,
uint64 flags,
uint64 maxRecCount,
uint64 maxBytesCount,
uint64 * recCount,
uint64 * byteCount,
MXF_ASCB_SAMPREC * rec
)
MXF_ASCB_SAMPREC Struct Reference
Data Fields:
uint64 timeTag
uint32 control
uint32 rate
uint32 errorCount
uint32 dataSize
uint16 data [256]
The MXF_ASCB_SAMPREC input of mxfASCBRxSamplingRead is giving me trouble. It is left for the caller of this method to allocate memory for the method to place data into for the caller to subsequently access. When I look at that input to the .net invoke method for MXF_ASCB_SAMPREC, it is a reference of this type: "System.IntPtr, mscorlib". I found that function, but it looks to just convert a pointer to an integer. The vendor has no examples of LabVIEW calling their assembly, and does not know how to interface this method into LabVIEW, but they do know that other customers have managed to support this method. The only documentation they can supply is C#. The applicable portions of the C# example are below.
Anyone have an idea of how to connect to this thing?
// allocate buffer
if (rc == MAXT_SUCCESS)
{
rc = mxfRxSamplingBufferAlloc(channel, (UInt64)rxBufferSize, out sampBuf, IntPtr.Zero);
if (rc == MAXT_ERROR_BUFFER_ALLOCATED)
rc = mxfRxSamplingBufferGet(channel, out sampBuf);
}
// Host allocation
if (rc == MAXT_SUCCESS)
{
try
{
rxBuffer = Marshal.AllocHGlobal((int)rxBufferSize);
}
catch (OutOfMemoryException)
{
rc = MAXT_ERROR_MEM;
}
}
// Read and display recv records (1000 times)
while ((rc == MAXT_SUCCESS) && (c < 1000))
{
rc = mxfASCBRxSamplingRead(sampBuf, MXF_RXSAMPLING_FLAG_DEFAULT, 0, rxBufferSize, out msgCount, out byteCount, rxBuffer);
if ((rc == MAXT_SUCCESS) && (msgCount != 0))
{
p = rxBuffer;
for (i = 0; i < (Int32)msgCount; i++)
{
rec = (MXF_ASCB_SAMPREC)Marshal.PtrToStructure(p, typeof(MXF_ASCB_SAMPREC));
/* Extract Data, Log and Display Here */
rc = mxfASCBNextSamplingRecordPtrGet(p, out p);
}
}
}