cookie Types, macros, helper functions and other information

  • C, C++
  • C#
  • Python

Base types

Handles

Macros

Helper functions

Handle HCMSysEntry

Description

HCMSysEntry is a 32-bit value which can be seen as a handle that points to a Product Item, a Firm Item, a CmContainer or a subsystem. Such a handle can be created by CmAccess / CmAccess2.

Function CmSetVersion

Description

CmSetVersion (a, b, c) sets the complete version in a int value.

•a: sets the major version.

•b: sets the minor version.

•c: sets the build version.

Syntax

public static Int32 CmSetVersion(Int32 a, Int32 b, Int32 c)

 

All types are Python types, no macros are defined and helper functions are embedded in classes.

Here you find information on:

•Obtaining version information of the CodeMeter Core API for Python

•Exceptions

•Shortcut functions

Obtaining version information of the CodeMeter Core API for Python

The version of the current Python API can be obtained expanding the constant cmapi.version_info. It contains a tuple consisting of:

•Major version of the API (for example '7')

•Minor version of the API (for example '30')

•Progressive revision number: usually '1'

Example: If there is an API function 'CmFoo' available in CodeMeter 8.13, it is easy to check its availability by executing the following script:

import cmapi
 
if cmapi.version_info < (8, 13, 1):

 raise RuntimeError("CodeMeter Python API 8.13.1 or newer is needed")

Exceptions

There exist several types of exceptions thrown:

In case of failure, CmAccess2() throws a HandleAccessFailedException(). This class offers two methods: errno(), which returns the error code as calling cmapi.CodeMeter().CmGetLastErrorCode() and what(), which returns the associated error string as calling cmapi.CodeMeter().CmGetLastErrorText().

A CodeMeterApiFailedException() is thrown in case of errors by CmCalculateDigest(), CmCalculatePioCoreKey(), CmCalculateSignature(), CmCheckEvents(), CmCrypt2(), CmCryptEcies(), CmCryptSim2(), CmCryptsim(), CmDecryptPioData(), CmExtendedDiscControl(), CmGetInfo(), CmGetLastErrorText(), CmGetPioDataKey(), CmGetPublicKey(), CmGetRemoteContext(), CmGetRemoteContext2(), CmGetRemoteContextBuffer(), CmGetSecureData(), CmGetServers(), CmLtConfirmTransfer(), CmLtCreateContext(), CmLtCreateReceipt(), CmLtDoTransfer(), CmLtImportUpdate(), CmReadProfilingEntry(), CmRelease(), CmSecureDiscRead(), CmSecureDiscWrite(), CmSetCertifiedTimeUpdate(), CmSetRemoteUpdate(), CmSetRemoteUpdate2() and CmSetRemoteUpdateBuffer().
This class offers the same two methods of the previous exception: errno(), which returns the error code as calling cmapi.CodeMeter().CmGetLastErrorCode() and what(), which returns the associated error string as calling cmapi.CodeMeter().CmGetLastErrorText().

In some cases, when a particular functionality is not available in a given function, a CodeMeterApiNotSupportedException() is thrown. Even this class offers the same two methods of the previouses exceptions: errno(), which returns the error code as calling cmapi.CodeMeter().CmGetLastErrorCode() and what(), which returns the associated error string as calling cmapi.CodeMeter().CmGetLastErrorText().

All these exception classes support direct conversion to "str" Python type, that means it is possible to write something like print(str(exception_object)) in the exception handling code.

Shortcut functions

GetAllContainerSerials

Description

GetAllContaierSerials is a shortcut to obtain a list of all boxes serials in the form boxmask-serialnumber. It calls CmGetBoxes(cmapi.CM_GB_ALLPORTS) with a Subsystem Access handle.

Syntax

import cmapi
 
cmapi.CodeMeterLite().GetAllContainerSerials() -> List[str]

Parameter

No parameter needed.

Return

The list of boxes (it may be empty) in the format boxmask-serialnumber.

GetSerialsWithSpecificFirmware

Description

GetSerialsWithSpecificFirmware is a shortcut to obtain a list of all boxes serials in the form boxmask-serialnumber with a specified firmware version. It calls CmGetBoxes(cmapi.CM_GB_ALLPORTS) with a Subsystem Access handle.

Syntax

import cmapi
 
cmapi.CodeMeterLite().GetSerialsWithSpecificFirmware(majorFwVersion: int,
 minorFwVersion: int) -> List[str]

Parameter

The required major and minor firmware versions.

Return

The list of boxes (it may be empty) in the format boxmask-serialnumber.