CmEmbedded_4c_transp CmProgram

Description

CmProgram programs entries.

  • C, C++

Syntax

int CMAPIENTRY CmProgram(HCMSysEntry hcmse, CMULONG flCtrl, void *pvCtrl, CMUINT cbCtrl, void *pvVerify, CMUINT cbVerify)

Parameter

hcmse contains a handle opened by CmAccess2. The access mode can be Box Access, Firm Item Access or Entry Access. The required access mode depends on the operation set in flCtrl. The handle is connected to a CmLocal subsystem with a connected CmDongle. This CmDongle will be used for programming.

flCtrl contains one of the following commands:

nav_open CM_GF_ADD_FIRMITEM adds a Firm Item into a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_ADD_FIRMITEM structure. hcmse must be Box Access.

nav_open CM_GF_UPDATE_FIRMITEM updates a Firm Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_UPDATE_FIRMITEM structure. hcmse must be Firm Item Access or Entry Access.

nav_open CM_GF_DELETE_FIRMITEM deletes a Firm Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_DELETE_FIRMITEM structure. hcmse must be Firm Item Access or Entry Access.

nav_open CM_GF_ADD_PRODUCTITEM adds a Product Item into a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_ADD_PRODUCTITEM structure. hcmse must be Entry Access.

nav_open CM_GF_UPDATE_PRODUCTITEM updates a Product Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_UPDATE_PRODUCTITEM structure. hcmse must be Entry Access.

nav_open CM_GF_DELETE_PRODUCTITEM deletes a Product Item in a CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_DELETE_PRODUCTITEM structure. hcmse must be Entry Access.

nav_open CM_GF_SET_BOXCONTROL sets the control flag of the CmDongle. pvCtrl is pointing to a hmtoggle_plus1 CMPROGRAM_BOXCONTROL structure.

nav_open CM_GF_SET_FIRMKEY programs a Firm Key into an already programmed FSB entry in a CmDongle. pvCtrl is pointing to a 32 element byte array. hcmse must be Entry Access.

nav_open CM_GF_ADD_ENABLEBLOCK adds a new Enable Block Item to a Firm Item. The input parameters are stored in a hmtoggle_plus1 CMENABLING_WRITEADD structure. The return value of the function is the index of the created Enable Block Item in the Enable Block Table. If no Enable Block Item is created, then 0 is returned and an error code is set.

nav_open CM_GF_UPDATE_ENABLEBLOCK updates the content of an existing Enable Block Item. The input parameters are stored in a byte array (pointer to unsigned char). The return value for this flag is 1 (TRUE), if no error occurred, else 0 (FALSE).

nav_open CM_GF_DELETE_ENABLEBLOCK deletes an existing Enable Block Item in a Firm Item. The input parameters are stored in a hmtoggle_plus1 CMENABLING_WRITEDELETE structure. The return value for this flag is 1 (TRUE), if no error occurred, else 0 (FALSE).

nav_open CM_GF_ATTACH_ENABLEBLOCK attaches an existing Enable Block Item to a Firm Item or Product Item. The input parameters are stored in a hmtoggle_plus1 CMENABLING_WRITEATTACHDETACH structure. The return value for this flag is 1 (TRUE), if if no error occurred, else 0 (FALSE).

nav_open CM_GF_DETACH_ENABLEBLOCK detaches an existing Enable Block Item from a Firm Item or Product Item. The input parameters are stored in a CMENABLING_WRITEATTACHDETACH structure. The return value for this flag is 1 (TRUE), if no error occurred, else 0 (FALSE).

nav_openCM_GF_ENABLEITEM enables the Enabling Block Item defined in hmtoggle_plus1 CMENABLING_CONTEXT

nav_open CM_GF_DISABLEITEM disables the Enabling Block Item defined in CMENABLING_CONTEXT.

nav_open CM_GF_TEMPENABLEITEM enables temporarily the Enabling Block Item defined in CMENABLING_CONTEXT.

pvCtrl contains a structure depending on the flCtrl flag (see above).

cbCtrl contains the number of bytes of the pvCtrl byte buffer/structure.

pvVerify contains a byte buffer receiving the verification sequence for the programmer. Except of the CM_GF_DELETE_FIRMITEM command this is a signed list command of the added/updated/deleted Firm Item (Signed List of the whole Firm Item). CM_GF_DELETE_FIRMITEM handles the creation of a verification sequence in the CmDongle internally. A hmtoggle_plus1 CMVALIDATE_DELETEFI structure must be passed here. If the parameter is NULL (==>> cbVerify = 0), no verification sequence is returned. If the buffer is to small for the verification sequence, the return value is larger than the cbVerify value and the error code CMERROR_BUFFER_OVERFLOW is set.

cbVerify contains the number of bytes of the byte buffer/structure stored in pvVerify.

Return

If the programming task is executed successfully and if pvVerify is NULL, then TRUE is returned, else FALSE is returned. If pvVerify contains enough memory, the length of the signed list or a CMVALIDATE_DELETEFI structure is returned. If pvVerify does not contain enough memory, the number of required bytes will be returned. In this case the return value is larger than the cbVerify parameter and error code CMERROR_BUFFER_OVERFLOW is set.

The following flags (and the corresponding functionality) are only available since CodeMeter Version 4.30:

•CM_GF_ENABLEITEM

•CM_GF_DISABLEITEM

•CM_GF_TEMPENABLEITEM