Hello,
In below, you can find my code. I would like to receive, on RS232 port, byte per byte and transmit at the same time this received byte. But there is a big time between the first byte received and the transmited byte. I try several things but I find the same result.
int RT_StartRxTxThread(int iComPort, int iBaudRate, int iMonitorFrameLength, double g_msDelay, int iDoWeDisplay)
{
int iStatus = 0;
int iParity,
iDataBits,
iStopBits,
iInputQueueSize,
iOutputQueueSize;
double dComTimeOut;
double dInitialTimerValue;
int iToRead;
int iCount,iCounter=0;
unsigned char ucRxBuffer[512]={0};
unsigned char ucTxBuffer[512]={0};
unsigned char ucTempBuffer[2];
unsigned int uiCRC=0;
iComPortNumberNormal =iComPort;
iParity =2; // even parity
iDataBits =8;
iStopBits =1;
iInputQueueSize =1;
iOutputQueueSize =1;
dComTimeOut =0,001;
iMonitoringFrameLength = iMonitorFrameLength;
// setup ComPort
iStatus = OpenComConfig ( iComPortNumberNormal,
NULL,
(long)iBaudRate,
iParity,
iDataBits,
iStopBits,
iInputQueueSize,
iOutputQueueSize);
iStatus = OpenComConfig ( 2,
NULL,
(long)iBaudRate,
iParity,
iDataBits,
iStopBits,
iInputQueueSize,
iOutputQueueSize);
//Set timeout limit
iStatus = SetComTime (iComPortNumberNormal, dComTimeOut);
iStatus = SetComTime (2, dComTimeOut);
iStatus = FlushInQ (iComPortNumberNormal);
iStatus = FlushInQ (2);
dInitialTimerValue = Timer();
while(Timer()-dInitialTimerValue < 10.00)
{
iToRead=ComRd (2, (char*)ucRxBuffer, 1);
iStatus = ComWrt(iComPortNumberNormal, (char*)ucRxBuffer, 1);
}
return 0;
}
Then, you can find in attached file the scope screenshot. I don't understand why the transmited data wait the end of 2 received bytes. Because I read byte per byte with function ComRd.
Thanks
Best Regards