LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Serial Port Callback Stops Responding

I have a PXI system running Pharlap.  I have an 16 port serial card PXI-8430.  This is one of 12 systems with very similar configuration.

 

One of those systems randomly loses connection to one particular serial device, but I am communicating with three of these devices on three different ports.  I am also communicating to two other different devices on different ports and those devices do not lose connection.  The ports that disconnect are no adjacent.  Why would those ports stop responding to the callback? 

 

I have installed a serial port sniffer and I can see the request and response in both directions so I know the traffic is there.  The callback has simply stopped calling back.

 

The only way to fix it is to cycle PXI power.  Disconnecting from it and killing the callback is not sufficient.

 

Is it necessary to destroy a ComCallback when one is Installed? 

 

int Timer_Port_Open(int CurrentTimer)
{
	// Open and configure the port
	HWTimers[CurrentTimer].gBaud		= 38400;
	HWTimers[CurrentTimer].gParity	= 0;	// no parity checking
	HWTimers[CurrentTimer].gDataBits	= 8;	// 8-bit characters
	HWTimers[CurrentTimer].gStopBits	= 1;	// 1 stop bit
	HWTimers[CurrentTimer].gInQSize	= 512;	// 512-byte input queue
	HWTimers[CurrentTimer].gOutQSize	= -1;	// disable the output queue (synchronous writes)	
	
	// Initialize members
	HWTimers[CurrentTimer].TimerValue	= 0;	//

	if (OpenComConfig (HWTimers[CurrentTimer].gPortNum, NULL, HWTimers[CurrentTimer].gBaud, HWTimers[CurrentTimer].gParity, HWTimers[CurrentTimer].gDataBits, HWTimers[CurrentTimer].gStopBits, HWTimers[CurrentTimer].gInQSize, HWTimers[CurrentTimer].gOutQSize) < 0)
		return -1;
	
	InstallComCallback (HWTimers[CurrentTimer].gPortNum, LWRS_RXFLAG, -1, TERM_CHAR, Timer_Message_Received, NULL);
	
	Timer_Port_SendMessage(CurrentTimer);
	
	return 0;
}

 

extern void CVICALLBACK Timer_Message_Received (int COMPort, int eventMask, void *callbackData)
{
	static char receivedMsg[64];
	float	TimerValue = 0;
	int TempPort = -1;
	
	do
	{
		TempPort++;
	} while (HWTimers[TempPort].gPortNum != COMPort);
	
	if (ComRdTerm (HWTimers[TempPort].gPortNum, receivedMsg, sizeof(receivedMsg) - 1, TERM_CHAR) > 0)
	{
		if (strlen(receivedMsg) < 20)
			strncpy(HWTimers[TempPort].msg, receivedMsg+10,39);

		//DebugPrintf("%s\n\n", receivedMsg);  
	}
		
	HWTimers[TempPort].TimerValue = atof(HWTimers[TempPort].msg);
	
	return;
}

  

Programming Data Acquisition and Control in Measurement Studio and Labwindows/CVI
0 Kudos
Message 1 of 1
(76 Views)