How to configurate Ethernet parameters for Anybus CompactCom 40 through Host Application

20 Aug 2023

This article introduces object,instances and attributes these are about Ethernet parameters and how to configurate Ethernet parameters through command sequencer in host application.

Ethernet parameter include  IP Address、Subnet Mask、Gateway Address、 DHCP. 

 

APPLICABLE PRODUCTS 

AB6605、AB6675、AB6603、AB6673、AB6604、AB6674

 

PRE-REQUISITES 

This article simply introduces how to configurate Ethernet parameters. More information about ethernet parameters can refer to user manual.

《Anybus CompactCom 40 - Software Design Guide》

《Anybus CompactCom 40 - Host Application Implementation Guide》

《Anybus CompactCom 40 - PROFINET IRT Network Guide》

  • Set Ethernet parameters after ABCC 40 Module initialization process finished. Value is used after module reset.

IN THIS ARTICLE

  • Introduce Network Configuration Object(0x04)
  • Create a command sequence to set values of Ethernet parameters  
  • Use the command sequence in Host Application 

 

Introduce Network Configuration Object(0x04)

This object holds network specific configuration parameters, Ethernet parameters are included in the object ,Each Ethernet parameter correspond to a instance of this object. More information can refer to  manual《Anybus CompactCom 40 - PROFINET IRT Network Guide》 section 5 of unit 13. 

Create a command sequence to set values of Ethernet parameters  

To change value of attribute need to send messages and commands these are contained in command sequencer to CompactCom40 device,for example As shown in the following figure:
The command sequencer API is described in abcc_drv\inc\abcc_cmd_seq.h,An array of ABCC_CmdSeqType's is provided and defines the command sequence to be executed. More information can refer to manual《Anybus CompactCom 40 - Host Application Implementation Guide》.
  1. User need to create functions that's to set value of attribute before to create command  sequencer,the function has a fixed return value.Taking "UpdateIpAddress()" as an example(that's used to set IPaddress).
    • static ABCC_CmdSeqCmdStatusType UpdateIpAddress( ABP_MsgType* psMsg )
      {
      if( ( !appl_fNwSupportsNodeId ) &&
      ( appl_fSetAddr ) )//execute condition
      {
      ABCC_SetMsgHeader( psMsg,
      ABP_OBJ_NUM_NC,//Network Configuration Object Code(0x04)
      appl_sIpSettings.sAddress.iInstance,//Instance Code
      ABP_NC_VAR_IA_VALUE, //Attribute Code
      ABP_CMD_SET_ATTR, //Command code
      4,//the length of IP address value in bytes
      ABCC_GetNewSourceId() );
      ABCC_SetMsgString( psMsg, (char*)appl_sIpSettings.sAddress.uValue.abValue, 4, 0 );
      return( ABCC_SEND_COMMAND );
      }
      return( ABCC_SKIP_COMMAND );
      }
  2. ABCC_CmdSeqCmdStatusType is a datatype of enum that's command function return value.

    • typedef enum ABCC_CmdSeqCmdStatus
      {
      ABCC_SEND_COMMAND,//Execute this command
      ABCC_SKIP_COMMAND,//Skip this command
      ABCC_CMD_ABORT_SEQ//Abort the command sequencer
      }
      ABCC_CmdSeqCmdStatusType;    
  3. "UpdateIpAddress()"、"UpdateNetmask()"、”UpdateGateway()“、"UpdateDhcp()" were defined in \example_app\appl_abcc_handler.c to set Ethernet parameter. User need to define a command sequence to contain these commands.for example:

    • static const ABCC_CmdSeqType appl_setIP_InProcess[] =
      {
      ABCC_CMD_SEQ( UpdateIpAddress, NULL ),
      ABCC_CMD_SEQ( UpdateNetmask, NULL ),
      ABCC_CMD_SEQ( UpdateGateway, NULL ),
      ABCC_CMD_SEQ( UpdateDhcp, NULL ),
      ABCC_CMD_SEQ_END()
      };
  4. Initial value of all attribute are defined in \example_app\appl_abcc_handler.c and are used in appl_sIpSettings.
    • static appl_IpSettingsType appl_sIpSettings =
      {
      { 3, { APPL_DEFAULT_IP_NETWORK_ADDRESS } },//1、Instance code 2、initial Value
      { 4, { APPL_DEFAULT_NETMASK } },
      { 5, { APPL_DEFAULT_GATEWAY } },
      { 6, { APPL_DEFAULT_DHCP_ENABLE } }
      };
  5. To define a function is used to call command sequencer
    • void Set_IP_InProcess( void )
      {
      /*
      **add some operations before the command sequence is executed
      */
      /*
      ** Start Set IP command sequence
      */
      ABCC_AddCmdSeq( appl_setIP_InProcess, NULL );
      }
  6. To define a function  enable executed conditions of the command sequencer and is called in main();
    • void APPL_SetIP_InProcess(UINT8 bSwitchValue,BOOL bSwitchDHCP)
      {
      appl_fSetAddr = TRUE;
      if( appl_fUserInitDone == TRUE )//init done
      {
      appl_sIpSettings.sAddress.uValue.abValue[ 3 ] = bSwitchValue;
      appl_sIpSettings.sDhcp.uValue.fValue=bSwitchDHCP;
      Set_IP_InProcess();
      }
      }

Use the command sequence in Host Application 

In this example, the execution command is determined by simulating external conditions triggering (such as HMI, device configuration of upper computer software, etc.). The external triggering condition in this example is to receive the triggering command through a serial port (users can implement the triggering method according to their needs).
  • while(eAbccHandlerStatus == APPL_MODULE_NO_ERROR )
    {
    eAbccHandlerStatus = APPL_HandleAbcc(); 
    //set attribute after abbc init through UART1 Command protocal further information in usart.c
    if(appl_fUserInitDone==TRUE&&Sdef_NewCommandFlag==1) 

    switch(Sdef_setcommand)
    {
    case Sdef_SetIP_Cmd://set IP Mask GateWay
      APPL_SetIP_InProcess(9,FALSE);
    Sdef_NewCommandFlag=0;
    break;
    default:
    Sdef_NewCommandFlag=0;
    break;
  • Reset Anybus CompactCom 40 device.

 

ADDITIONAL INFO (Optional)

The example code are for reference only,not as the final functional implementation standard.More information can refer to user maunal.

User manual download link:Anybus Files and Documentation

If there is expectation that Ethernet parameters is set during initialization, you can refer another article which give method to set parameters during initialization.

The link is as follows : How to change a parameter in an Anybus CompactCom during initialization? – HMS Support Portal (hms-networks.com)