I am trying to use RTDX to control actions in my target application from a Visual C++ program. I have followed all the instructions in the tutorials, and it is almost working. But I can't seem to get the correct data from the host to the target. I am reading in bytes from the host with the following code:
static int WaitingForRead = 0;
int32_T ReadRTDXByte(int8_T *RcvdData)
{
int8_T data;
int32_T status;
// Request integer data
if (!WaitingForRead) {
status = RTDX_readNB(&ichan, &data, sizeof(data));
if ( status != RTDX_OK )
return 0;
}
// Check to see if channel has read data
WaitingForRead = RTDX_channelBusy( &ichan );
#if RTDX_POLLING_IMPLEMENTATION
// Make sure this is called in polling mode
RTDX_Poll();
#endif
// Check if data is ready and make sure it is the right size
if (!WaitingForRead) {
status = RTDX_sizeofInput(&ichan);
if (status != sizeof(data))
return 0;
*RcvdData = data;
}
// Data has been properly transferred to output parameter
return 1;
}
and in Visual C++ I am using this code to send the byte:
void CRTDXDlg::SendRTDXByte(char Data)
{
long bufferstate; // holds the state of the host's write buffer
m_Rtdx->WriteI1(Data, &bufferstate);
}
I am getting only 0 in the data byte at the target, no matter what I write to the host. The Channel Viewer shows the RReqCount and RByteCount as 1 and the XFRCount increments every time I send a byte, but 0 is the only value I receive. I have double checked the value that is being sent and it is not 0.
Does anyone have any ideas that might help here? Thanks in advance.