functionfunAdsDestructor

External C function to close socket and free memory

Information

This is a function to close the connection with a Beckhoff PLC via the ADS protocol. The function utilised from the C API provided by Beckhoff is AdsPortClose(). Errors are reported.

C Source Code of Function

int funAdsDestructor(void)
{
	long nErr; // Variable for error codes from ADS 
	
	// Close communication port
	nErr = AdsPortClose();
			if (DEBUG_FLAG != 0) ModelicaFormatMessage("Call of AdsPortClose(), done!\n");
  	if (nErr != 0)
		{// Error checking
		ModelicaFormatMessage("Error: AdsPortClose(): %i\n",nErr);
		return(1);
		}
	if (DEBUG_FLAG != 0) ModelicaFormatMessage("AdsPortClosed successful!\n");
	
return(0);
}  

Outputs

TypeNameDefaultDescription
IntegeransError handling: 0 = OK!, 1 == Error, see simulation tab for info

Revisions

  • November 01, 2015  by Georg Ferdinand Schneider:
    Implemented
  • January 30, 2016  by Georg Ferdinand Schneider:
    Revised for publishing