This article shows how to read attributes from an Anybus CompactCom (ABCC) Module Object during initialization using user's custom functions.
Anybus CompactCom 30
Anybus CompactCom 40
Anybus CompactCom 30 / 40
Host Application Example Code V3.x
During the SETUP state of the ABCC driver state machine, the Host Application sends commands to the Anybus CompactCom.
You can embed your own custom command and response functions in order to read attributes from the Anybus Module Objects during that SETUP state. In the Host Application Example Code ≥ V3.x, this can be done using a command sequence.
Here are the necessary steps to follow :
- In example_code/appl_abcc_handler.c, write your command and response functions.
- Add your functions to the appl_asUserInitCmdSeq command sequence.
We want to read out the serial number of our ABCC40 module during SETUP.
In Chapter 12 of the ABCC40-Software Design guide, we see that the serial number is the 3rd Attribute of Instance #1 in the Anybus Object (01h).
Now, let’s apply the two steps we saw earlier.
The routines we are going to implement are ReadSerialNumCmd() and ReadSerialNumResp(), therefore those need to be part of our forward declarations, along with the abcc_iSerialNumber variable, used to store the serial number value.
static ABCC_CmdSeqCmdStatusType ReadSerialNumCmd ( ABP_MsgType* psMsg );
static ABCC_CmdSeqRespStatusType ReadSerialNumResp ( ABP_MsgType* psMsg);
static UINT32 abcc_iSerialNumber;
Command function : ReadSerialNumCmd()
static ABCC_CmdSeqRespStatusType ReadSerialNumCmd(ABP_MsgType* psMsg )
ABCC_GetAttribute( psMsg, ABP_OBJ_NUM_ANB, 1,
return( ABCC_SEND_COMMAND );
As you can see in the command function, the command used is the Get_Attribute command (ABCC_GetAttribute), which points to the Anybus object (ABP_OBJ_NUM_ANB), Instance #1, Attribute 3 (ABP_ANB_IA_SERIAL_NUM).
Response handler function : ReadSerialNumResp()
static ABCC_CmdSeqCmdStatusType ReadSerialNumResp(ABP_MsgType* psMsg)
ABCC_ASSERT_ERR(ABCC_VerifyMessage(psMsg) == ABCC_EC_NO_ERROR,
ABCC_GetMsgData32(psMsg, &abcc_iSerialNumber, 0);
ABCC_PORT_DebugPrint(("RSP MSG_GET_MODULE_SERIAL_NUM: %X\n", abcc_iSerialNumber));
The response handler checks the validity of the response data. The data shouldn’t contain any errors and should have the correct type.
Here, we simply add those functions to the appl_asUserInitCmdSeq command sequence. In the code we can see that appl_asUserInitCmdSeq already has a set of routines. We simply need to add ours, following the same format.
static const ABCC_CmdSeqType appl_asUserInitCmdSeq =
Once we reboot our ABCC40, our routines are also run as part of the appl_asUserInitCmdSeq command sequence during the SETUP state, and we’re able to read the serial number of our module.
You will find attached a .txt file containing these routines. In case you want to make use of it, the section titles in example_code/appl_abcc_handler.c have been included in order to direct you better as to where to paste the different declarations and methods in the code.
Based on this example, you can implement your own routines to read other attributes from an ABCC Module Object during initialization.