Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Edit Typo and Style.


This chapter lists the API functions that are provided by irj45.

...

This function registers the irj45 specific API in GOAL and must be called in appl_init. It returns a GOAL_STATUS_T status and has no parameters.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goalappl_ddRpcInitccmRpcInit(  
    void  
);

Example:

Code Block
languagec
/****************************************************************************/  
/** Application Init 
 * 
 * Build up the device structure and initialize the Profinet stack. 
 */  
GOAL_STATUS_T appl_init(  
    void  
)  
{  
    GOAL_STATUS_T res = GOAL_OK;                /* result */  
  
    /* initialize ccm RPC interface */  
    res = appl_ccmRpcInit();  
    if (GOAL_RES_ERR(res)) {  
        goal_logErr("Initialization of ccm RPC failed");  
    }  
  
    return res;  
}  

...


Purpose: Enable firmware update in the Communication Controller

This function enables the possibility to update the firmware of the irj45 CC module. It returns a GOAL_STATUS_T status and has no parameters.

Function Prototype

Code Block
GOAL_STATUS_T appl_ccmUpdateAllow(  
    void  
);

  
Example:
For an example, where firmware update capability can be enabled and disabled using the web server please check example project 01_pnio_io_mirror (chapter 7.1).

appl_ccmUpdateDeny


Purpose: Disable firmware update in the Communication Controller

This function disables the possibility to update the firmware of the irj45 CC module. Possibly use of this function is to disable firmware update possibilities during a cyclic communication relation.
It returns a GOAL_STATUS_T status and has no parameters.

...

Example:
For an example, where firmware update capability can be enabled and disabled using the web server please check example project 01_pnio_io_mirror (chapter 7.1).

appl_ccmInfo


Purpose: Get version and device information

This function reads information from the irj45:

...


Pupose: Set behaviour of fieldbus communication on fault

This function determines the behaviour of the irj45 regarding cyclic communication. By default, a cyclic communication is stopped when communication to the application controller (AC) is lost.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmFaultStateSet(  
    APPL_CCM_FAULT_STATE_T faultState         /*< fault state to enter */  
);   

...


Pupose: Set behaviour of irj45 module on SPI sync reset request

A sync reset request is requested by the AC upon restart, while the CC was previously setup with a running AC application.
This function determines the behaviour of the irj45 regardinging this reset request. By default, no reset is done. If this option is enabled, reset is done.
The state of this setting is stored in non volatile memory on the CC. A value of 0 disables the reset. A value of 1 enables the reset.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmCommResetSet(  
    uint8_t value                               /*< option value */  
); 

...


Pupose: Enable transport of AC log messages to the CC

Once this function is executed, log messages from the AC's logging buffer are continuously transferred to the CC module. Those are then accessible as the CC's own log messages through the management interface.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmLogEnable(  
    void  
);

...

appl_ccmLogToAcEnable


Minimal ccm firware firmware version: 2.0.0.0

Pupose: Enable transport of CC log messages to the AC

Once this function is executed, log messages from the CC's logging buffer are continuously transferred to the AC module. Those are then accessible as the AC's own log messages through the local log mechanism, e.g. serial console or terminal.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T appl_ccmLogToAcEnable(  
    void  
);

...

appl_ccmFwUpdateStart


Minimal ccm firware firmware version: 2.0.0.0

Pupose: Start firmware update of ccm module using rpc

This function transfers the given data buffer, which contains firmware update data, to the communication controller.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmFwUpdateStart(
    uint8_t *pFwData,                           /*< firmware data */
    uint32_t fwSize                             /*< size of firmware data */
); 

...

appl_ccmFwUpdateExecute


Minimal ccm firware firmware version: 2.0.0.0 Pupose

Purpose: Perform actual update of the firmware update

This function performs the actual update of the ccm module. It must be called after transfer of the firmware data. This requires registration for firmware update events using appl_ccmFwUpdateCbReg(). If the application does not register for the events, the function appl_ccmFwUpdateExecute is called by the ccm implicetilyimplicitly.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmFwUpdateExecute(
     void
);

...


Minimal ccm firware version: 2.0.0.0 Pupose

Purpose: Perform update oft he EtherCAT Ssi data in eeprom

This function allows optionally an initialization of the EtherCAT ssi data in EEPROM. This should only be called once, since some EtherCAT masters rely on settings in the eeprom that should not be overwritten (Configured Station Alias).

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmEcatSsiUpdate(
     unsigned char *pData,                       /*< SSI data */
     uint32_t dataLen,                           /*< SSI data length */
     GOAL_BOOL_T flgEmptyCheck                   /*< empty check before writing */
);

...

appl_ccmEthMacAddressSet


Minimal ccm firware firmware version: 2.0.0.0 Pupose

Purpose: Configure a custom mac address for the device

This function allows changing of the mac address of the device. It needs to be called before any network related function (communication stack start, network initialization).

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmEthMacAddressSet(
     uint8_t *pMacAddr
);

...

appl_ccmNetworkDefaultUp


Minimal ccm firware firmware version: 2.0.0.0

Purpose: Start default networking

This function starts the ccm module in standard ethernet mode. It usually is not required to call this function, since protocol stacks automatically start the network in the proper mode.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmNetworkDefaultUp(
     void
);

...

appl_ccmNetworkEoEUp


Minimal ccm firware firmware version: 2.0.0.0

Purpose: Start EtherCAT eoe networking

This function starts the ccm module in EtherCAT mode. It usually is not required to call this function, since the EtherCAT protocol stacks automatically start the network in the proper mode.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmNetworkEoEUp(
     void
);

...


appl_ccmCfgVarGet


Minimal ccm firware firmware version: 2.0.0.0

Purpose: Read any config variable

This function provides a mechanism to read any configuration variable of the ccm module. It required a module id and a variable id, which is documented in chapter 4.9. GOAL Programmer's Manual - chapter goal_cm.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T appl_ccmCfgVarGet(
    uint32_t modId,                              /*< module id */
    uint32_t varId,                              /*< variable id */
    void *pBuf,                                  /*< [out] output buffer */
    uint32_t bufLength,                          /*< buffer length */
    uint32_t *pVarLength,                        /*< [out] variable length */
    uint32_t *pVarType                           /*< [out] variable type */
); 

...

Code Block
/* get signature of firmware */
if (GOAL_RES_OK(res)) {
    res = appl_ccmCfgVarGet(
        37, /* module id */
        0,  /* variable id */
        &fwSignature[0],
        sizeof(fwSignature),
        NULL, NULL
        );
} 

appl_ccmCfgVarSet


Minimal ccm firware firmware version: 2.0.0.0

Purpose: Wrote any config variable

This function provides a mechanism to write any configuration variable of the ccm module. It required a module id and a variable id, which is documented in chapter 4.9 GOAL Programmer's Manual - chapter goal_cm.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T appl_ccmCfgVarSet(
     uint32_t modId,                             /*< module id */
    uint32_t varId,                             /*< variable id */
     void *pBuf,                                 /*< [out] output buffer */
    uint32_t bufLength                          /*< buffer length */
); 

...

Code Block
languagec
/* demonstaration for writing of config variables */
valObj = 0x12345678;
if (GOAL_RES_OK(res)) {
    res = appl_ccmCfgVarSet(
        34, /* module id dd */
        1, /* variable id customer id */
        &valObj,
        sizeof(valObj)
        );
} 

appl_ccmCfgSave


Minimal ccm firware firmware version: 2.0.0.0

Purpose: Store config variable changes permanently

This function provides a mechanism to update the non volatile storage containing the config variables. The current values of the config variables will be stored.

Function Prototype:

Code Block
GOAL_STATUS_T appl_ccmCfgSave(
     void
);

...


Purpose: Initialize usage of dd component

This function registers the GOAL dd specific API in GOAL and must be called in appl_init. It returns a GOAL_STATUS_T status and has no parameters.

Function Prototype:

Code Block
GOAL_STATUS_T goal_ddInit (  
    void  
);

...


Purpose: Create a new goal dd instance

This function creates an instance of GOAL dd in GOAL and must be called in appl_setup. A valid instance is requirement for using the GOAL dd API.
It returns a GOAL_STATUS_T status and has the following parameters.

Parameter

Description

GOAL_DD_T **ppHdl

returned GOAL dd instance handle

uint32_t bitmaskFeatures

initial instance features to be enabled

Table 29 goal_ddNew parameters

The parameter bitmaskFeatures is a bitmask which disables single features of GOAL dd if set:

Bit

Feature

0

disable HELLO request (used for device scan detection)

1

disable WINK command

2

disable GETLIST command (read list of available CM variables)

3

disable GETCONFIG command (read cm variables value)

4

disable SETCONFIG command (write cm variables value)

5

disable SETIP command (configure IP through GOAL dd

Table 30 feature bitmask parameter

Function Prototype:

Code Block
GOAL_STATUS_T goal_ddNew(  
    GOAL_DD_T **ppHdlDd,                        /*< DD handle */  
    uint32_t bitmaskFeatures                    /*< initial features */  
);   

...


Purpose: Configure the customer id of GOAL dd instance

This function configures the customer Id of the given GOAL dd instance. The customer Id is a property of the underlying protocol which is contained in each request using GOAL dd. There is a special customer Id whith value of zero, which causes every request to be processed. If the customer Id is not equal to zero, a request will only be processed if the customer Id of the request equals the customer Id of the GOAL dd instance.

The customer Id is stored in non-volatile memory.

Parameter

Description

GOAL_DD_T *pHdl

GOAL dd instance handle

uint32_t customerId

instance customer Id

Table 31 goal_ddCustomerIdSet parameters

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_ddCustomerIdSet(  
    GOAL_DD_T *pHdlDd,                          /*< dd handle */  
    uint32_t cid                                /*< customer ID */  
); 

...


Purpose: Configure the name of GOAL dd instance

This function configures the module name of the given GOAL dd instance. The module Id is a property of the device stored in non-volatile memory. It is used my the management tool by the Industrial Communication Explorer for device naming. The module name length is limited to 20 bytes.

Parameter

Description

GOAL_DD_T *pHdl

GOAL dd instance handle

uint8_t *str

instance module name

Table 32 goal_ddModuleNameSet parameters

Function Prototype:

Code Block
GOAL_STATUS_T goal_ddModuleNameSet(  
    GOAL_DD_T *pHdlDd,                          /*< dd handle */  
    uint8_t *str                                /*< module name */  
);

...


Purpose: Configure the features of the GOAL dd instance

This function configures the features to be disabled for the given GOAL dd instance. This property is stored in the device stored in non volatile memory.

Parameter

Description

GOAL_DD_T *pHdl

GOAL dd instance handle

uint32_t bitmaskFeatures

instance features bitmask

Table 33 goal_ddFeaturesSet parameters
For parameter description see function "goal_ddNew".

...


Purpose: Configure callback for GOAL dd instance

This function registers a callback to the given GOAL dd instance.
Type of the callback:

Code Block
languagec
typedef GOAL_STATUS_T (* GOAL_DD_FUNC_CB_T)(  
    struct GOAL_DD_T *pHdlDd,                   /*< dd handle */  
    GOAL_DD_CB_ID_T cbId,                       /*< callback id */  
    GOAL_DD_CB_DATA_T *pCbData                  /*< callback data */  
);   

...


Purpose: Temporalily activation of features of GOAL dd instance

This function termporarily enabled features for the given GOAL dd instance. This property is NOT stored in non volatile memory.

Parameter

Description

GOAL_DD_T *pHdl

GOAL dd instance handle

uint32_t bitmaskFeatures

instance features bitmask

Table 34 goal_ddSessionFeatureActivation parameters

Note

...

The parameter bitmaskFeatures here is used

...

inverted to the function for permanent configuration of the features, thus a bit set here, enabled the given feature.


Function Prototype:

Code Block
GOAL_STATUS_T goal_ddSessionFeatureActivate(  
    GOAL_DD_T *pHdlDd,                          /*< dd handle */  
    uint32_t bitmaskFeatures                    /*< bitmask with feature enable bits set */  
);   

...


Purpose: Limit access to cm variables

By default an external application as the Management Tool Industrial Communication Explorer has total access to all CM variables of the device. This is a handy feature for development, but for production purpose one wants to limit access to only the variables that are required for minimal functionality using the Management ToolIndustrial Communication Explorer. Therefore filters were introduced, which do this task. Following filters are predefined:

Filter ID

Filter Name

0

GOAL_DD_ACCESS_FILTER_SET_ALL

1

GOAL_DD_ACCESS_FILTER_SET_BASIC

2

GOAL_DD_ACCESS_FILTER_SET_HIDDEN

Table 35 goal_ddFilterAdd filter sets

Filter
ID

Filter Actions

Purpose

0

Full access granted to all variables

Development

1

Read Access to all variables of the NET module
(IP settings), Read Access to all variables of
the ETH module (MAC, status),
Full access to all variables of the
LM module
(logging)

Production Code with minimal support of the Management ToolIndustrial Communication Explorer

2

Disables read access to the web server
authentication strings

Production Code

Table 36 goal_ddFilterAdd predefined filters

definition of filter GOAL_DD_ACCESS_FILTER_SET_ALL

...

Code Block
#if 0  
    /* enable for full access */  
    res = goal_ddFilterAdd(pHdlDd, GOAL_DD_ACCESS_FILTER_SET_ALL);  
    if (GOAL_RES_ERR(res)) {  
        goal_logErr("failed to set dd access filter");  
    }  
#endif  
  
    res = goal_ddFilterAdd(pHdlDd, GOAL_DD_ACCESS_FILTER_SET_HIDDEN);  
    if (GOAL_RES_ERR(res)) {  
        goal_logErr("failed to set dd access filter");  
    }     

...

PROFINET stack


Please see profinet the PROFINET documentation.

...

EtherNet/IP stack


see ethernet ip documentationPlease see the EtherNet/IP documentation.

EtherCAT stack


See Please see the EtherCAT documentation.

...

Web server


Please see the GOAL programmer's manual.

...

Networking

goal_netRpcInit


Purpose: Initialize RPC functionality for networking.

If networking functionality (IP settings, UDP channel, TCP channel) is required, this function needs to be called during application initialization.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_netRpcInit(  
    uint32_t id                                 /*< id for MA instance */  
)

...

goal_maNetOpen - open network channel


Purpose:
Open the network media adapter for usage.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_maNetOpen(  
    uint32_t id,                                /*< id of NET handler to use */  
    GOAL_MA_NET_T **ppNetHdl                    /*< pointer to store NET handler */  
);   

...

goal_maNetClose - close network


Purpose:
Close the network MA

Function Prototype:

Code Block
GOAL_STATUS_T goal_maNetClose(  
    GOAL_MA_NET_T *pNetHdl                      /*< pointer to store NET handler */  
);  

...


Purpose: Get the network MA handle which was previously open for usage.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maNetGetById(  
    GOAL_MA_NET_T **ppHdlMaNet,                 /*< NET handle ref ptr */  
    uint32_t id                                 /*< MA id */  
);  

...


Purpose: Set the network interface IP address.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maNetIpSet(  
    GOAL_MA_NET_T *pNetHdl,                     /*< pointer to store NET handler */  
    uint32_t addrIp,                            /*< IP address */  
    uint32_t addrMask,                          /*< subnet mask */  
    uint32_t addrGw,                            /*< gateway */  
    GOAL_BOOL_T flgTemp                         /*< temporary IP config flag */  
);   

...


Purpose: Opens the networking MA for further usage. This needs to be done once at application startup.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanTcpOpen(  
    uint32_t id,                                /*< MA id */  
    GOAL_MA_CHAN_TCP_T **ppHdlMaChanTcp         /*< CHAN_TCP handle ref ptr */  
);   

...


Purpose: This function creates a new tcp channel.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_maChanTcpNew(  
    GOAL_MA_CHAN_TCP_T *pChanTcpHdl,            /*< pointer to store CHAN_TCP handler */  
    GOAL_NET_CHAN_T **ppChanHandle,             /*< pointer to channel handle */  
    GOAL_NET_CHAN_T *pChanOut,                  /*< pointer to channel handle for output */  
    GOAL_NET_ADDR_T *pAddr,                     /*< remote address */  
    GOAL_NET_TYPE_T type,                       /*< connection type */  
    GOAL_MA_CHAN_TCP_CB_T callback              /*< channel callback */  
); 

...


Purpose: Activate a previously created tcp channel. Once it is activated, it established connection establish connections or accepts incoming connection requests.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanTcpActivate(  
    GOAL_MA_CHAN_TCP_T *pChanTcpHdl,            /*< pointer to store CHAN_TCP handler */  
    GOAL_NET_CHAN_T *pChanHandle                /*< channel handle */  
);  

...


Purpose: Set socket to non blocking mode for reading.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_maChanTcpSetNonBlocking(  
    GOAL_MA_CHAN_TCP_T *pChanTcpHdl,            /*< pointer to store CHAN_TCP handler */  
    GOAL_NET_CHAN_T *pChanHandle,               /*< channel handle */  
    GOAL_BOOL_T flgOption                       /*< non blocking state */  
); 

...


Purpose: Get the ip address of the remote end point of the tcp channel.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanTcpGetRemoteAddr(  
    GOAL_MA_CHAN_TCP_T *pChanTcpHdl,            /*< pointer to store CHAN_TCP handler */  
    GOAL_NET_CHAN_T *pChanHandle,               /*< channel handle */  
    GOAL_NET_ADDR_T *pAddr                      /*< remote address */  
); 

...


Purpose: Send data to a previously opened TCP channel.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanTcpSend(  
    GOAL_MA_CHAN_TCP_T *pChanTcpHdl,            /*< pointer to store CHAN_TCP handler */  
    GOAL_NET_CHAN_T *pChanHandle,               /*< channel handle */  
    GOAL_BUFFER_T *pBuf                         /*< buffer with data to send */  
);

...


Purpose: Open the udp channel ma. This needs to be done once at application startup.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_maChanUdpOpen(  
    uint32_t id,                                /*< MA id */  
    GOAL_MA_CHAN_UDP_T **ppHdlMaChanUdp         /*< CHAN_UDP handle ref ptr */  
);

...


Purpose: This function gets the handle of the udp channel ma which was previously opened.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanUdpGetById(  
    GOAL_MA_CHAN_UDP_T **ppHdlMaChanUdp,        /*< CHAN_UDP handle ref ptr */  
    uint32_t id                                 /*< MA id */  
); 

...


Purpose: Create a new udp channel.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_maChanUdpNew(  
    GOAL_MA_CHAN_UDP_T *pChanUdpHdl,            /*< pointer to store CHAN_UDP handler */  
    GOAL_NET_CHAN_T **ppChanHandle,             /*< pointer to channel handle */  
    GOAL_NET_CHAN_T *pChanOut,                  /*< pointer to channel handle for output */  
    GOAL_NET_ADDR_T *pAddr,                     /*< remote address */  
    GOAL_NET_TYPE_T type,                       /*< connection type */  
    GOAL_MA_CHAN_UDP_CB_T callback              /*< channel callback */  
);

...


Purpose: Close an existing channel.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanUdpClose(  
    GOAL_MA_CHAN_UDP_T *pChanUdpHdl,            /*< pointer to store CHAN_UDP handler */  
    GOAL_NET_CHAN_T *pChanHandle                /*< pointer to channel handle */  
);    

...


Purpose: Set a channel to non blocking operation.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanUdpSetNonBlocking(  
    GOAL_MA_CHAN_UDP_T pChanUdpHdl,            /*< pointer to store CHAN_UDP handler */  
    GOAL_NET_CHAN_T pChanHandle,               /*< channel handle */  
    GOAL_BOOL_T flgOption                      /*< option value */  
);

...


Purpose: Set a channel to broadcast.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanUdpSetBroadcast(  
    GOAL_MA_CHAN_UDP_T *pChanUdpHdl,            /*< pointer to store CHAN_UDP handler */  
    GOAL_NET_CHAN_T *pChanHandle,               /*< channel handle */  
    GOAL_BOOL_T flgOption                       /*< option value */  
);

...


Purpose: Get the remote address of a udp channel, thus the address it received data from.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_maChanUdpGetRemoteAddr(  
    GOAL_MA_CHAN_UDP_T *pChanUdpHdl,            /*< pointer to store CHAN_UDP handler */  
    GOAL_NET_CHAN_T *pChanHandle,               /*< channel handle */  
    GOAL_NET_ADDR_T *pAddr                      /*< remote address */  
);  

...


Purpose: Activate a channel.

Function Prototype:

Code Block
GOAL_STATUS_T goal_maChanUdpActivate(  
    GOAL_MA_CHAN_UDP_T *pChanUdpHdl,            /*< pointer to store CHAN_UDP handler */  
    GOAL_NET_CHAN_T *pChanHandle                /*< channel handle */  
); 

...


Purpose: Send data to an open udp channel.

Function Prototype:

Code Block
languagec
GOAL_STATUS_T goal_maChanUdpSend(  
    GOAL_MA_CHAN_UDP_T *pChanUdpHdl,            /*< pointer to store CHAN_UDP handler */  
    GOAL_NET_CHAN_T *pChanHandle,               /*< channel handle */  
    GOAL_BUFFER_T *pBuf                         /*< buffer with data to send */  
); 

...