How to get license status from inside structured language

2023-06-14
2023-06-15
  • rossanoparis

    rossanoparis - 2023-06-14

    I'd like to monitor CODESYS licences used in my automation solution, in particular the runtime licence and the soft motion licence.
    My need is to rise two alarms on the HMI system in case such licences are missing.
    Is that possible ? Could someone suggest a way in order to get that working?

    Best regards
    Rossano

     
  • TimvH

    TimvH - 2023-06-14

    You can read the status of the license from your application through the CmpCodeMeter library.

    See https://forge.codesys.com/forge/talk/Runtime/thread/1c1b00cfc7/

    So the code could be something like (change the numbers according to the licenses you are searching for):

    VAR
        // add CmpCodeMeter library
        xCheckLicense: BOOL;
        xFound: BOOL;
        Handle: CmpCodeMeter.RTS_IEC_HANDLE;
        Result: CmpCodeMeter.RTS_IEC_RESULT;
    END_VAR
    
    // check for valid Raspberry Pi license
    IF xCheckLicense THEN
        xCheckLicense := FALSE;
        xFound := FALSE;
        Handle:= CmpCodeMeter.CodeMOpen(udiFirmCode := 5000304, udiProductCode := 603001, udiFeatureCode := 16#1, Result := Result);
        IF Handle <> CmpCodeMeter.SysTypes.RTS_INVALID_HANDLE AND Result = CmpCodeMeter.Errors.ERR_OK THEN
            xFound := TRUE;
            CmpCodeMeter.CodeMClose(hCodeMeter := Handle);
        END_IF
    END_IF
    

    Maybe also interesting:
    https://faq.codesys.com/display/CDSFAQ/Licensing%3A+Querying+the+Container+Information

     
  • rossanoparis

    rossanoparis - 2023-06-15

    Thank you @TimvH, it was very kind of you

     

Log in to post a comment.