Im working on pproject that has NI Chassis with bunch of DAQs and Serial channels:
I have simple code I writen in main ( ) involving two serial com ports and single threaded with exception of CALLBACK to handle rceipts of bytes from one of the com ports. Basic strip down of code involves com 3 sending "Hello World" to com 59.
Basically code set up does the following:
status = OpenComConfig (3, "", 921600, 0, 8, 1, 512, 512);
status = OpenComConfig (59, "", 921600, 0, 8, 1, 512, 512);
FlushInQ (59);
FlushOutQ (3);
status = InstallComCallback (59, LWRS_RECEIVE, NOTIFYCOUNT, 0, readMessages, NULL);
Then I write :
writeError = ComWrt (3, "Hello, World!", 26);
Call Back written in same main module looks something like this:
void CVICALLBACK readMessages()
{
int bytesRead
char msgBuffer[20];
// Reading data sent to COM59
bytesRead = ComRd (59, msgBuffer, sizeof(msgBuffer));
if (bytesRead < 0) {
printf ("ComRd error!!!, Bytes read = %d \n", bytesRead);
return;
}
I also all trimmings of checking and reporting status and errors.
The code works fine....
Then I cut and paste CALLBACK function in another .c module in a much bigger software project and declare CALLBACK prototype in a gloabal header. Everything compiled just fine. I lefteverything else in main. But when I run, the callback never indicated that it happen and nothing gets printed.
The only differences in this bigger project there is a more elaborate thread manager managing a pool of threads that are also running. Is it possible that this other thread system affecting my com experiment?