This chapter lists the API functions that are provided by irj45.
...
Purpose:
Register irj45 API in GOAL (appl_init) Anchor _Toc534961860 _Toc534961860
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:
GOAL_STATUS_T goal_ddRpcInit(
void
);
Example:
/****************************************************************************/
/** 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;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose:
Enable firmware update in the Communication Controller Anchor _Toc534961861 _Toc534961861
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
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).
...
Purpose:
Disable firmware update in the Communication Controller Anchor _Toc534961862 _Toc534961862
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.
Function Prototype:
GOAL_STATUS_T appl_ccmUpdateDeny(
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).
...
Function Prototype:
GOAL_STATUS_T appl_ccmInfo(
char *strVersion, /*< target string for version /
uint8_t lenStrVersion, /*< length of str buffer /
GOAL_ETH_MAC_ADDR_T *macAddress, /*< mac address buffer /
uint16_t *pDevType /**< irj45 device type */
);
Example:
/* get version and information of ccm */
if (GOAL_RES_OK(res)) {
res = appl_ccmInfo(strVersion, APPL_VERSION_LEN, &mac, &devType);
}
if (GOAL_RES_OK(res)) {
goal_logInfo("ccm version : %s", strVersion);
goal_logInfo("ccm device : %u", devType);
goal_logInfo("ccm Serial : %02x:%02x:%02x:%02x:%02x:%02x",
mac[0], mac[1], mac[2], mac[3], mac[4], mac[5]);
}
...
Pupose:
Anchor | ||||
---|---|---|---|---|
|
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:
GOAL_STATUS_T appl_ccmFaultStateSet(
APPL_CCM_FAULT_STATE_T faultState /*< fault state to enter /
);
Example:
/ set fault state behaviour /
if (GOAL_RES_OK(res)) {
res = appl_ccmFaultStateSet(APPL_CCM_FAULT_STATE_ENTER);
}
...
Pupose:
Anchor | ||||
---|---|---|---|---|
|
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:
GOAL_STATUS_T appl_ccmCommResetSet(
uint8_t value /*< option value /
);
Example:
/ set sync reset behaviour /
if (GOAL_RES_OK(res)) {
/ enable reset on sync reset request from AC /
res = appl_ccmCommResetSet(1);
}
...
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:
GOAL_STATUS_T appl_ccmLogEnable(
void
);
Example:
/ enable logging to CC /
if (GOAL_RES_OK(res)) {
res = appl_ccmLogEnable();
}
...
Minimal ccm firware 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:
GOAL_STATUS_T appl_ccmLogToAcEnable(
void
);
Example:
/ enable logging from CC to AC/
if (GOAL_RES_OK(res)) {
res = appl_ccmLogToAcEnable();
}
...
Minimal ccm firware version: 2.0.0.0
Pupose: 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:
GOAL_STATUS_T appl_ccmEcatSsiUpdate(
unsigned char *pData, /*< SSI data /
uint32_t dataLen, /*< SSI data length /
GOAL_BOOL_T flgEmptyCheck /*< empty check before writing /
);
Example:
/ configure SII in EEPROM before creating the EtherCAT instance /
res = appl_ccmEcatSsiUpdate(
&__09_ecat_slave_eeprom_bin[0], / data buffer /
__09_ecat_slave_eeprom_bin_len, / data buffer length /
GOAL_FALSE); / always overwrite ssi data /
if (GOAL_RES_ERR(res)) {
goal_logErr("failed to configure EEPROM ssi data");
}
Note:
There are some functions available for manipulating the provided example sii data. Usage can be found in the example 09_ecat_slave, file goal_appl.c. Usage must be enabled using the define ECAT_SSI_INIT.
...
Minimal ccm firware 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.
Function Prototype:
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 /
);
Example:
/ get signature of firmware /
if (GOAL_RES_OK(res)) {
res = appl_ccmCfgVarGet(
37, / module id /
0, / variable id /
&fwSignature[0],
sizeof(fwSignature),
NULL, NULL
);
}
...
Minimal ccm firware 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.
Function Prototype:
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 /
);
Example:
/ 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)
);
}
...
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:
GOAL_STATUS_T goal_ddInit (
void
);
Example:
GOAL_STATUS_T appl_init( void
)
{
GOAL_STATUS_T res; /*< GOAL result /
/ initialize GOAL dd API /
res = goal_ddInit();
if (GOAL_RES_ERR(res)) {
goal_logErr("failed to initialize GOAL dd API");
}
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
...
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:
GOAL_STATUS_T goal_ddNew(
GOAL_DD_T **ppHdlDd, /*< DD handle /
uint32_t bitmaskFeatures /*< initial features /
);
Example:
static GOAL_DD_T *pHdlDd; /*< GOAL dd handle /
GOAL_STATUS_T appl_setup(
void
)
{
GOAL_STATUS_T res; /*< GOAL result /
/ create GOAL dd instance /
res = goal_ddNew(&pHdlDd, GOAL_DD_FEAT_ALL);
if (GOAL_RES_ERR(res)) {
goal_logErr("failed to create GOAL dd instance");
}
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
...
Parameter | Description |
GOAL_DD_T *pHdl | GOAL dd instance handle |
uint32_t customerId | instance customer Id |
Table 31 goal_ddCustomerIdSet parameters
Function Prototype:
GOAL_STATUS_T goal_ddCustomerIdSet(
GOAL_DD_T *pHdlDd, /*< dd handle /
uint32_t cid /*< customer ID /
);
Example:
/ configure DD properties /
res = goal_ddCustomerIdSet(pHdlDd, APPL_DD_CUSTOMER_ID);
if (GOAL_RES_ERR(res)) {
goal_logErr("failed to configure DD customer id");
}
...
Parameter | Description |
GOAL_DD_T *pHdl | GOAL dd instance handle |
uint8_t *str | instance module name |
Table 32 goal_ddModuleNameSet parameters
Function Prototype:
GOAL_STATUS_T goal_ddModuleNameSet(
GOAL_DD_T *pHdlDd, /*< dd handle /
uint8_t *str /*< module name /
);
Example:
res = goal_ddModuleNameSet(pHdlDd, APPL_DD_MODULE_NAME);
if (GOAL_RES_ERR(res)) {
goal_logErr("failed to configure DD module name");
}
...
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".
Function Prototype:
GOAL_STATUS_T goal_ddFeaturesSet(
GOAL_DD_T *pHdlDd, /*< dd handle /
uint32_t bitmaskFeatures /*< bitmask with feature disable bits set /
);
Example:
res = goal_ddFeaturesSet(pHdlDd, APPL_DD_FEATURES);
if (GOAL_RES_ERR(res)) {
goal_logErr("failed to configure DD features");
}
...
Purpose: Configure callback for GOAL dd instance
This function registers a callback to the given GOAL dd instance.
Type of the callback:
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 /
);
Function Prototype:
static GOAL_STATUS_T ddCallback(
GOAL_DD_T *pHdlDd, /*< dd handle /
GOAL_DD_CB_ID_T cbId, /*< callback ID /
GOAL_DD_CB_DATA_T *pCbData /*< callback data /
);
Example:
/****************************************************************************/
/** Application Setup
*
* This function must setup all used protocol stacks.
*
*/
GOAL_STATUS_T appl_setup(
void
)
{
GOAL_STATUS_T res; / result /
res = goal_ddCallbackReg(pHdlDd, (GOAL_DD_FUNC_CB_T) ddCallback);
return res;
}
/****************************************************************************/
/** goal dd callback
*
*/
static GOAL_STATUS_T ddCallback(
GOAL_DD_T pHdlDd, /< dd handle /
GOAL_DD_CB_ID_T cbId, /*< callback ID /
GOAL_DD_CB_DATA_T pCbData /< callback data /
)
{
UNUSEDARG(pHdlDd);
UNUSEDARG(pCbData);
switch (cbId) {
case GOAL_DD_CB_ID_WINK:
goal_logInfo("Blink command received");
break;
default:
break;
}
return GOAL_OK;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
...
Parameter | Description |
GOAL_DD_T *pHdl | GOAL dd instance handle |
uint32_t bitmaskFeatures | instance features bitmask |
Table 34 goal_ddSessionFeatureActivation parameters
ATTENTION: The parameter bitmaskFeatures here is used iverted to the function for permanent configuration of the features, thus a bit set here, enabled the given feature.
Function Prototype:
GOAL_STATUS_T goal_ddSessionFeatureActivate(
GOAL_DD_T *pHdlDd, /*< dd handle /
uint32_t bitmaskFeatures /*< bitmask with feature enable bits set /
);
Example:
/* temporarily enable capability to respond to hello requests (device detection) */
res = goal_ddSessionFeatureActipHdlDd, GOAL_DD_FEAT_HELLO);
...
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 | Filter Actions | Purpose |
0 | Full access granted to all variables | Development |
1 | Read Access to all variables of the NET module | Production Code with minimal support of the Management Tool |
2 | Disables read access to the web server | Production Code |
Table 36 goal_ddFilterAdd predefined filters
definition of filter GOAL_DD_ACCESS_FILTER_SET_ALL
/*< complete access /
static GOAL_DD_VAR_T ddAccessAll[] = {
{
.pNext = NULL,
.modId = GOAL_DD_VAR_ALL,
.varId = GOAL_DD_VAR_ALL,
.access = (1 << GOAL_DD_ACCESS_READ) | (1 << GOAL_DD_ACCESS_WRITE)
}
};
...
/*< list of variables that are required for basic functionality /
static GOAL_DD_VAR_T ddAccessListBasic[] = {
{ / read access to network settings /
.pNext = (struct GOAL_DD_VAR_T *) &ddAccessListBasic[1],
.modId = GOAL_ID_NET,
.varId = GOAL_DD_VAR_ALL,
.access = (1 << GOAL_DD_ACCESS_READ)
},
{ / read access to ethernet properties /
.pNext = (struct GOAL_DD_VAR_T *) &ddAccessListBasic[2],
.modId = GOAL_ID_ETH,
.varId = GOAL_DD_VAR_ALL,
.access = (1 << GOAL_DD_ACCESS_READ)
},
{ / access to logs /
.pNext = NULL,
.modId = GOAL_ID_LM,
.varId = GOAL_DD_VAR_ALL,
.access = (1 << GOAL_DD_ACCESS_READ) | (1 << GOAL_DD_ACCESS_WRITE)
}
};
definition of filter GOAL_DD_ACCESS_FILTER_SET_HIDDEN
static GOAL_DD_VAR_T ddAccessListHidden[] = {
{ / disable read access to HTTP user level 0 /
.pNext = (struct GOAL_DD_VAR_T *) &ddAccessListHidden[1],
.modId = GOAL_ID_HTTP,
.varId = 2, / USERLEVEL0 /
.access = (1 << GOAL_DD_ACCESS_WRITE)
},
{ / disable read access to HTTP user level 1 /
.pNext = (struct GOAL_DD_VAR_T *) &ddAccessListHidden[2],
.modId = GOAL_ID_HTTP,
.varId = 3, / USERLEVEL1 /
.access = (1 << GOAL_DD_ACCESS_WRITE)
},
{ / disable read access to HTTP user level 2 /
.pNext = (struct GOAL_DD_VAR_T *) &ddAccessListHidden[3],
.modId = GOAL_ID_HTTP,
.varId = 4, / USERLEVEL2 /
.access = (1 << GOAL_DD_ACCESS_WRITE)
},
{ / disable read access to HTTP user level 3 /
.pNext = NULL,
.modId = GOAL_ID_HTTP,
.varId = 5, / USERLEVEL3 /
.access = (1 << GOAL_DD_ACCESS_WRITE)
},
};
Function Prototype:
GOAL_STATUS_T goal_ddFilterAdd(
GOAL_DD_T *pHdlDd, /*< dd handle /
GOAL_DD_ACCESS_FILTER_SET_T setId /*< set id /
);
Example:
/ enable for full access /
#if 0
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");
}
...
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:
GOAL_STATUS_T goal_netRpcInit(
uint32_t id /*< id for MA instance /
)
Example:
/****************************************************************************/
/** Application Init
*
* Initialize the net stack
*/
GOAL_STATUS_T appl_init(
void
)
{
GOAL_STATUS_T res; / result /
/ initialize goal net /
res = goal_netRpcInit(GOAL_NET_ID_DEFAULT);
if (GOAL_RES_ERR(res)) {
goal_logErr("Initialization of goal net RPC failed");
}
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose:
Open the network media adapter for usage.
Function Prototype:
GOAL_STATUS_T goal_maNetOpen(
uint32_t id, /*< id of NET handler to use /
GOAL_MA_NET_T **ppNetHdl /*< pointer to store NET handler /
);
Example:
/****************************************************************************/
/** Application Setup
*
* This function is called by the GOAL init-stage system to open UDP channels.
*
* API functions from earlier stages are allowed to be used here.
*/
GOAL_STATUS_T appl_setup(
void
)
{
GOAL_STATUS_T res; / result /
GOAL_MA_NET_T pMaNet; / net ma handle */
res = goal_maNetOpen(GOAL_NET_ID_DEFAULT, &pMaNet);
if (GOAL_RES_ERR(res)) {
goal_logErr("error opening network MA");
}
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose:
Close the network MA
Function Prototype:
GOAL_STATUS_T goal_maNetClose(
GOAL_MA_NET_T *pNetHdl /*< pointer to store NET handler /
);
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Get the network MA handle which was previously open for usage
Function Prototype:
GOAL_STATUS_T goal_maNetGetById(
GOAL_MA_NET_T **ppHdlMaNet, /*< NET handle ref ptr /
uint32_t id /*< MA id /
);
Example:
res = goal_maNetGetById(&pMaNet, GOAL_NET_ID_DEFAULT);
if (GOAL_RES_ERR(res)) {
goal_logErr("error getting network MA");
}
...
Purpose: Set the network interface IP address
Function Prototype:
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 /
);
Example:
/ set IP address /
ip = MAIN_APPL_IP;
nm = MAIN_APPL_NM;
gw = MAIN_APPL_GW;
res = goal_maNetIpSet(pMaNet, ip, nm, gw, GOAL_FALSE);
if (GOAL_RES_ERR(res)) {
goal_logErr("error while setting IP address");
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
...
Purpose: Opens the networking MA for further usage. This needs to be done once at application startup.
Function Prototype:
GOAL_STATUS_T goal_maChanTcpOpen(
uint32_t id, /*< MA id /
GOAL_MA_CHAN_TCP_T **ppHdlMaChanTcp /*< CHAN_TCP handle ref ptr /
);
Example:
res = goal_maChanTcpOpen(GOAL_NET_ID_DEFAULT, &pMaTcp);
if (GOAL_RES_ERR(res)) {
goal_logErr("error getting tcp MA");
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: This function creates a new tcp channel.
Function Prototype:
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 /
);
Example:
/ register TCP server /
GOAL_MEMSET(&addr, 0, sizeof(GOAL_NET_ADDR_T));
addr.localPort = (uint16_t) (MAIN_APPL_TCP_PORT + cnt);
res = goal_maChanTcpNew(pMaTcp, &pChan, NULL, &addr, GOAL_NET_TCP_LISTENER,
tcpCallback);
if (GOAL_OK != res) {
goal_logErr("error while opening TCP server channel on port %"FMT_u32,
(uint32_t) MAIN_APPL_TCP_PORT + cnt);
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Activate a previously created tcp channel. Once it is activated, it established connection or accepts incoming connection requests.
Function Prototype:
GOAL_STATUS_T goal_maChanTcpActivate(
GOAL_MA_CHAN_TCP_T *pChanTcpHdl, /*< pointer to store CHAN_TCP handler /
GOAL_NET_CHAN_T *pChanHandle /*< channel handle /
);
Example:
/ activate channel /
res = goal_maChanTcpActivate(pMaTcp, pChanTcp);
if (GOAL_OK != res) {
goal_logErr("error while enabling TCP channel");
return;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Set socket to non blocking mode for reading
Function Prototype:
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 /
);
Example:
/ set TCP channel to non-blocking /
res = goal_maChanTcpSetNonBlocking(pMaTcp, pChanTcp, GOAL_TRUE);
if (GOAL_OK != res) {
goal_logErr("error while setting TCP channel to non-blocking");
return;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Get the ip address of the remote end point of the tcp channel.
Function Prototype:
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 /
);
Example:
/ get IP Address of remote node /
res = goal_maChanTcpGetRemoteAddr(pMaTcpHdl, pChan, &remote);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to get Remote Address for socket %p", (void *) pChan);
return;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Send data to a previously opened TCP channel.
Function Prototype:
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 /
);
Example:
/ echo message /
goal_maChanTcpSend(pMaTcpHdl, pChan, pBuf);
...
Purpose: Open the udp channel ma. This needs to be done once at application startup.
Function Prototype:
GOAL_STATUS_T goal_maChanUdpOpen(
uint32_t id, /*< MA id /
GOAL_MA_CHAN_UDP_T **ppHdlMaChanUdp /*< CHAN_UDP handle ref ptr /
);
Example:
/ open udp channel MA and create new channel /
res = goal_maChanUdpOpen(GOAL_NET_ID_DEFAULT, &pMaChanUdp);
if (GOAL_RES_OK(res)) {
GOAL_MEMSET(&addr, 0, sizeof(GOAL_NET_ADDR_T));
addr.localPort = MAIN_APPL_UDP_PORT_1;
res = goal_maChanUdpNew(pMaChanUdp, &pChan1, NULL, &addr, GOAL_NET_UDP_SERVER, udpCallback);
}
...
Purpose: This function gets the handle of the udp channel ma which was previously opened.
Function Prototype:
GOAL_STATUS_T goal_maChanUdpGetById(
GOAL_MA_CHAN_UDP_T **ppHdlMaChanUdp, /*< CHAN_UDP handle ref ptr /
uint32_t id /*< MA id /
);
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Create a new udp channel.
Function Prototype:
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 /
);
Example:
if (GOAL_RES_OK(res)) {
GOAL_MEMSET(&addr, 0, sizeof(GOAL_NET_ADDR_T));
addr.localPort = MAIN_APPL_UDP_PORT_1;
res = goal_maChanUdpNew(pMaChanUdp, &pChan1, NULL, &addr, GOAL_NET_UDP_SERVER,
udpCallback);
}
...
Purpose: Close an existing channel
Function Prototype:
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 /
);
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Set a channel to non blocking operation.
Function Prototype:
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 /
);
Example:
res = goal_maChanUdpSetNonBlocking(pMaChanUdp, pChan2, GOAL_TRUE);
if (GOAL_OK != res) {
goal_logErr("error while setting UDP channel to non-blocking");
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Set a channel to broadcast.
Function Prototype:
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 /
);
Example:
/ enable broadcast reception /
res = goal_maChanUdpSetBroadcast(pMaChanUdp, pChan1, GOAL_TRUE);
if (GOAL_RES_ERR(res)) {
goal_logErr("error while setting UDP channel to receive broadcasts");
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Get the remote address of a udp channel, thus the address it received data from.
Function Prototype:
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 /
);
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Activate a channel
Function Prototype:
GOAL_STATUS_T goal_maChanUdpActivate(
GOAL_MA_CHAN_UDP_T *pChanUdpHdl, /*< pointer to store CHAN_UDP handler /
GOAL_NET_CHAN_T *pChanHandle /*< channel handle /
);
Example:
res = goal_maChanUdpActivate(pMaChanUdp, pChan2);
if (GOAL_RES_ERR(res)) {
goal_logErr("error while enabling UDP channel");
return res;
}
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Anchor | ||||
---|---|---|---|---|
|
Purpose: Send data to an open udp channel.
Function Prototype:
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 /
);
Example:
/ echo message /
goal_maChanUdpSend(pMaChanUdp, pChan, pBuf);