Working with TwinCAT 3 license dongles 4.3.3 PLC function blocks relating to the storage function of the license dongles 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 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. TwinCAT 3 40 Version: 1.20.7