Best Practices

General

The following chapter may help you to avoid issues in your application.

Preconditions

  • Only devices which support one of the pre-defined protocols are detected by the library.

  • Verify that the FC_Scan function was executed successfully before you use an instance of the function blocks FB_SendCommand/FB_ExtendedSendCommand or the function FC_GetPeerScanData.

  • Wait up to 5 seconds (depending on the number of connected network devices) after the execution of the FC_Scan function has completed before you execute any other function or function block.

  • The input i_udiSearchUniqueID of the function FC_GetPeerScanData must be 0 if you call this function after an execution of the function FC_ClearScanList and FC_Scan before executing the command.

  • There is no syntax verification available for FB_ExtendedSendCommand; therefore use FB_SendCommand defined by the enumeration ET_SendCommandType.

  • Depending on the command, the structure ST_SendCommand (input of FB_SendCommand) contains different parts which are mandatory. The correct MAC address is required.

Examples

The following examples are based on this network topology:

There are two detected devices stored in the internal database (M241 and M251 Logic Controllers).

Examples for FC_GetPeerScanData

Searching for a device by its model name:

Step

Action

1

Set the inputs in the following way:

i_uiSearchUniqueID := 0
i_etSearchTypeFilter := ModelName
// use the enumeration ET_SearchTypeFilter to select a pre-defined filter
i_sSearchTypeValue := 'TM241'

2

Execute the function.

Result: The structure ST_PeerDeviceInfo provides the M241 related information.

NOTE: If there are several M241 Logic Controllers connected to your network, use the unique Id (1 in this example) as input for i_uiSearchUniqueID during the next execution. Repeat this procedure as long as FC_GetPeerScanData is executed successfully to get the information for the M241 Logic Controllers.

Searching for a device by its IPv4 address:

Step

Action

1

Set the inputs in the following way:

i_uiSearchUniqueID := 0
i_etSearchTypeFilter := IPv4
// use the enumeration ET_SearchTypeFilter to select a pre-defined filter
i_sSearchTypeValue := '10.209.177.74'
//IP address of the TM251

2

Execute the function.

Result: The structure ST_PeerDeviceInfo provides the related information of the controller with this IPv4 address.

Examples for FB_SendCommand

  • Locate

    Only the inputs i_etCommandType and i_sMacAddr must be set.

    The execution of this function block makes LEDs on the connected M251 Logic Controller flash for about 10 seconds.

  • IPv4 address

    For changing the IPv4 address of an M251 Logic Controller temporarily (Save = FALSE), all elements of the input structure i_stSendCommand must be set.
    NOTE: Verify if the new configuration is set correctly by executing:
    1. FC_ClearScanList

    2. FC_Scan

    3. FC_GetPeerScanData

    In this example, you get:
  • MAC address

    This example displays an incorrect command syntax (invalid MAC address)
    .

    There is a syntax verification implemented for any structure element, depending on the command.

  • Backup

    To create a backup image of an M251 Logic Controller, the inputs i_etCommandType, i_sMacAddr, i_sExtension1 (FTP user name), and i_sExtension2 (FTP password) must be set.
    NOTE: The execution of this command may take several minutes.
    To verify if (and where) the backup is stored on the SD card (inserted into the M262 Logic Controller), you can open an FTP connection to the M262 Logic Controller.

Example FB_ExtendedSendCommand

There is only one input string defined where to enter the complete command, for example, for locate.

NOTE: There are no syntax or other completeness verifications implemented for the input i_sExtendedSendCommand. You must be aware of the input content and ensure that it is correct. Only lower case characters are taken into account.