02-17-2021 03:04 AM
Hi Roberto,
I'm trying to install the callback, but I it seems to me that it is not possible to put in OR with LWRS_RXFLAG in the eventMask the timeout condition, set with SetComTime () after OpenComConfig().
Just because I need to be advised if I don't receive anything within the timeout.
Can you help me again?
02-17-2021 06:44 PM
Yes, SetComTime will only work with variants of ComRd function and will not be fired in case of com callbacks. I suppose you can use a separate timer to handle the timeout event.
02-17-2021 10:34 PM
The best final solution I found was to implement MyComRdTerm, as follows:
static int MyComRdTerm (int portNumber, char buffer[], size_t count, int terminationByte)
{
int rec_num = 0;
unsigned char single = (unsigned char)(terminationByte+1);
int i=0;
while ((single !=terminationByte)&&(i<count))
{
rec_num = ComRd (portNumber, &single, 1); /* timeout is set after opening the serial com */
if (rec_num == 1)
buffer[i++] = single;
else
{
i=0;
single = (unsigned char)terminationByte;
}
}
return i;
}