.ModelicaADS.Functions.ADS.funAdsDestructor

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);
}  

Interface

function funAdsDestructor
  output Integer ans "Error handling: 0 = OK!, 1 == Error, see simulation tab for info";
end funAdsDestructor;

Revisions


Generated at 2026-04-04T18:18:28Z by OpenModelicaOpenModelica 1.26.3 using GenerateDoc.mos