My application has been receiving data via serial port C for some time. I now wish to receive data on serial port D at the same time. The receive threads are in seprate costates. Both ports appear to work but I can only fetch one character from each ports buffer at a time. If I send two or more characters into port C the first is displayed then the costate waits until serial port D has received a character then immedetely fetches the next character for port C. I have simplified the code down to the very basics.
#class auto
// two costates are always_on
CoData coSerMain, coSerStandby;
#define CINBUFSIZE 31
#define COUTBUFSIZE 31
#define DINBUFSIZE 31
#define DOUTBUFSIZE 31
const long baud_rate = 9600L;
#define RS232_NOCHARASSYINBRK
/******************************************************************************
Main ‘loop’
******************************************************************************/
int main()
{
unsigned int receivedMain;
unsigned int receivedStandby;
_sysIsSoftReset();
loopinit(); //required for single-user cofunctions to work correctly
serCopen(baud_rate);
serCdatabits(PARAM_8BIT);
serCparity(PARAM_NOPARITY);
serDopen(baud_rate);
serDdatabits(PARAM_8BIT);
serDparity(PARAM_NOPARITY);
serCrdFlush(); // clear any chars in buffers
serDrdFlush();
while (1)
{
loophead(); // also required for single user cofunctions
costate coSerMain always_on //
{
printf("Main
");
waitfordone
{
receivedMain = cof_serCgetc();
}
printf("M R>%03d
",receivedMain);
}
costate coSerStandby always_on //
{
printf("Standby
");
waitfordone
{
receivedStandby = cof_serDgetc();
}
printf("S R>%03d
",receivedStandby);
}
}
}
I am using Dynamic C version 10.11. I have attempted to update to 10.46but this will not program my target (Timeout waiting for response).