LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Pulling Hair Out - CVI CALLBACK Why am I able to Xmit from Com 3 to Com 59 if CALLBACK is in main but not if isn't?

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?

 

0 Kudos
Message 1 of 2
(4,083 Views)

Duplicated post. Discussion follows here



Proud to use LW/CVI from 3.1 on.

My contributions to the Developer Community
________________________________________
If I have helped you, why not giving me a kudos?
0 Kudos
Message 2 of 2
(4,044 Views)