PLC function blocks relating to the storage function of the license dongles

PLC function blocks relating to the storage function of the license dongles 1:

At least TwinCAT 3.1 Build 4022 and PLC Lib: Tc2_Utilities Version 3.3.26.0

The functionalities described require at least TwinCAT 3.1 Build 4022 and the PLC Lib: Tc2_Utilities Version 3.3.26.0

Attention: In order to be able to save a License Response File in a TwinCAT 3 license dongle, the file name must be 32 characters long or less.

Reading the StorageInfo and the file directory of a license dongle

FUNCTION_BLOCK FB_LicFileGetStorageInfo

The function block reads the StorageInfo of the license dongle and the file directory.

The StorageInfo contains administrative data of the storage medium (such as capacity, number of free bytes, number of files,…) and an array of the individual file entries (name, size, attributes,… of the file).

VAR_INPUT
    sNetId           : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort            : UINT;      (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    bExecute         : BOOL;      (* Rising edge on this input activates the fb execution *)
    dwPassCode       : DWORD;     (* Passcode for file access *)
    tTimeout         : TIME       := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy            : BOOL;      (* True as long as the FB is busy *)
    bError           : BOOL;      (* True in case of an error *)
    nErrorId         : UDINT;     (* Error code in case of an error *)
    nFileEntries     : UDINT;     (* Amount of files on dongle *)
END_VAR
VAR_IN_OUT
    stStorageInfo    : ST_LicStorageInfo;   (* Header + files infos from dongle *)
END_VAR

Creating a file on a license dongle

FUNCTION_BLOCK FB_LicFileCreate

The function block creates a file on the license dongle. A rising edge at bExecute writes the data from the buffer (pWriteBuff and cbWriteLen) directly onto a new file on the dongle.

VAR_INPUT
    sNetId      : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort       : UINT;     (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFileName   : STRING;   (* File name to write to dongle *)
    pWriteBuff  : PVOID;    (* Buffer address for write *)
    cbWriteLen  : UDINT;    (* Count of bytes for write *)
    bExecute    : BOOL;     (* Rising edge on this input activates the fb execution *)
    dwPassCode  : DWORD;    (* Passcode for file access *)
    tTimeout    : TIME := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy       : BOOL;     (* True as long as the FB is busy *)
    bError      : BOOL;     (* True in case of an error *)
    nErrorId    : UDINT;    (* Error code in case of an error *)
END_VAR

Deleting a file from a license dongle

FUNCTION_BLOCK FB_LicFileDelete

The function block deletes a file from the license dongle. The file name and file length are zeroed, and the data bytes of the file to be deleted are released on the dongle but not overwritten.

VAR_INPUT
    sNetId      : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort       : UINT;     (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFileName   : STRING;   (* File name to delete from dongle *)
    bExecute    : BOOL;     (* Rising edge on this input activates the fb execution *)
    dwPassCode  : DWORD;    (* Passcode for file access *)
    tTimeout    : TIME       := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy       : BOOL;     (* True as long as the FB is busy *)
    bError      : BOOL;     (* True in case of an error *)
    nErrorId    : UDINT;    (* Error code in case of an error *)
END_VAR

Reading a file from the terminal/USB dongle

FUNCTION_BLOCK FB_LicFileRead

The function block reads a file from the license dongle to a buffer (pDestBuff and cbReadLen) via a positive edge at bExecute. The buffer must be large enough for the file, otherwise only the first part of the file is read.

VAR_INPUT
    sNetId      : T_AmsNetId;(* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPort       : UINT;     (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFileName   : STRING;   (* File name to write to dongle *)
    pDestBuff   : PVOID;    (* Buffer address for read *)
    cbReadLen   : UDINT;    (* Count of bytes for read *)
    bExecute    : BOOL;     (* Rising edge on this input activates the fb execution *)
    dwPassCode  : DWORD;    (* Passcode for file access *)
    tTimeout    : TIME       := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy       : BOOL;     (* True as long as the FB is busy *)
    bError      : BOOL;     (* True in case of an error *)
    nErrorId    : UDINT;    (* Error code in case of an error *)
END_VAR

Copying a file from the hard disk to the terminal/USB dongle

FUNCTION_BLOCK FB_LicFileCopyToDongle

The function block copies a file from the hard disk to the license dongle. If the file is larger than the buffer (cbCopyLen), the file copying procedure is automatically split into several read and write operations until the whole file is copied. Only then does bBusy switch to FALSE.

VAR_INPUT
    sNetIdSrc         : T_AmsNetId;    (* Ams net id of PC ('' is local PC) *)
    sNetIdDest        : T_AmsNetId;    (* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPortDest         : UINT;          (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sFilePathNameSrc : T_MaxString;    (* File path name on disk *)
    sFileNameDest     : STRING;        (* File name for file on dongle *)
    pCopyBuff         : PVOID;         (* Buffer address for write *)
    cbCopyLen         : UDINT;         (* Count of bytes for write *)
    bExecute          : BOOL;          (* Rising edge on this input activates the fb execution *)
    dwPassCode        : DWORD;         (* Passcode for file access *)
    tTimeout          : TIME := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy             : BOOL;          (* True as long as the FB is busy *)
    bError            : BOOL;          (* True in case of an error *)
    nErrorId          : UDINT;         (* Error code in case of an error *)
END_VAR

Copying a file from the terminal/USB dongle to the HDD

FUNCTION_BLOCK FB_LicFileCopyFromDongle

The function block copies a file from the license dongle to the hard disk. If the file is larger than the buffer (cbCopyLen), the file copying procedure is automatically split into several read and write operations until the whole file is copied. Only then does bBusy switch to FALSE.

VAR_INPUT
    sNetIdSrc         : T_AmsNetId;    (* Ams net id of dongle (USB: of PC ('' is local PC); EL6070: of EtherCAT Master (info data of terminal)) *)
    nPortSrc          : UINT;          (* Ams port of dongle (USB: ADS Port of ESB Device (e.g. 16#7100); EL6070: ADS Port of EtherCAT terminal (info data)) *)
    sNetIdDest        : T_AmsNetId;    (* Ams net id of PC ('' is local PC) *)
    sFileNameSrc      : STRING;        (* File name for file on dongle *)
    sFilePathNameDest : T_MaxString;   (* File path name on disk *)
    pCopyBuff         : PVOID;         (* Buffer address for write *)
    cbCopyLen         : UDINT;         (* Count of bytes for write *)
    bExecute          : BOOL;          (* Rising edge on this input activates the fb execution *)
    dwPassCode        : DWORD;         (* Passcode for file access *)
    tTimeout          : TIME            := DEFAULT_ADS_TIMEOUT;(* ADS timeout *)
END_VAR
VAR_OUTPUT
    bBusy             : BOOL;          (* True as long as the FB is busy *)
    bError            : BOOL;          (* True in case of an error *)
    nErrorId          : UDINT;         (* Error code in case of an error *)
END_VAR

See also: