...
Writing an Application for the Remote Station SDK
Overview
...
Overview
An application for the Remote Station SDK is a GOAL application. It consists of three functions that are called by GOAL: appl_init, appl_setup, appl_loop.
Additionally, the application can register a callback that is called by the CC-Link IE TSN Remote Station stack to inform the application about events.
The function appl_init is used to register components in GOAL, e.g. the CC-Link IE TSN protocol stack. The actual initialization of the application happens in appl_setup.
The application must include goal_includes.h and goal_ccl_ie_tsn.h.
...
The function appl_setup is called by GOAL during initialization. Within this function all functions listed in this chapter can be used to configure the behavior of the Remote Station. All Functions must be called before calling goal_cclIeTsnNew.
All functions return a status code indicating whether the operation succeeded or not.
...
Creating a new instance of the CC-Link IE TSN protocol stack
...
After the stack has been configured the function goal_cclIeTsnNew must be invoked to create a new instance of the protocol stack. It is also used to register a callback handler for processing events from the stack. The callback handler will be explained in detail in a later chapter.
...
Code Block | ||
---|---|---|
| ||
GOAL_STATUS_T |
...
static GOAL_CCL_HANDLE_T *pCcl = NULL; /**< GOAL CCL handle */
/* create instance of CC-Link IE TSN stack */
...
res; /* result */ static GOAL_CCL_HANDLE_T *pCcl = NULL; /**< GOAL CCL handle */ /* create instance of CC-Link IE TSN stack */ res = goal_cclIeTsnNew(&pCcl, GOAL_CCL_INSTANCE_DEFAULT, appl_goalCclCb); |
...
if (GOAL_RES_ERR(res)) |
...
{ goal_logErr("Failed to instantiate CC-Link IE TSN stack"); |
...
return res;
}
return res;
}
|
Figure 2.1: Creating a new instance of the Remote Station stack
...
Runtime behavior of the CC-Link IE TSN Remote Station stack
...
The functions in this chapter influence the runtime behaviour of the CC-Link IE TSN Remote Station. The functions must be called after goal_cclIeTsnNew returned successfully and before goal_cclIeTsnStart is called. These functions can be directly called within appl_setup or at a later point in time.
...
Starting the CC-Link IE TSN Remote Station Stack
After finishing all settings of the runtime behavior and the expected Remote Station configuration the stack must be started by calling goal_cclIeTsnStart.
...
Code Block | ||
---|---|---|
| ||
res = goal_cclIeTsnStart(pCcl); |
...
if (GOAL_RES_ERR(res)) |
...
{ goal_logErr("Failed to start stack"); |
...
} |
Figure 2.2: Start an instance of the Remote Station stack
...
If this function succeeds the stack CC-Link IE TSN Remote Station stack has been started and will now wait for a configuration by a master device. All functions described in previous chapters cannot be used anymore.
Functions used during Run phase
After sucessfulling starting the stack. The application can use the following functions to access cyclic data and to influence the stack’s behaviour.
Function | Description |
goal_cclIeTsnCyclicStopSet | Enable or Disable Cyclic Stop for the Remote Station. |
goal_cclIeTsnInputGet | Read Input data from the Cyclic Memory Map. |
goal_cclIeTsnOutputSet | Write Output data to the Cyclic Memory Map |
goal_cclIeTsnAppStopSet | Enable or Disable Application Stop mode for this station. |
goal_cclIeTsnAppErrorStopSet | Enable or Disable Application Error Stop mode for this station. |
goal_cclIeTsnEmergencyStopExec | Issue an Emergency Stop due to internal error. |
goal_cclIeTsnPowerSupplyErrorStopExec | Issue an Emergency Stop due to Power supply error. |
goal_cclIeTsnOutputDevGet | Get data from an Output Link Device (data received via Master-to-Master communication). |
goal_cclIeTsnInputDevSet | Set data of an Input Link Device (data transmitted for Master-to-Master communication). |
goal_cclIeTsnNmtUpload | Get the NMT state of a CANopen Remote Station. |
goal_cclIeTsnSlaveProcTypeRead | Request processor Type information from a Remote Station |
Table 2‑4: Functions used during Run phase in the Remote Station SDK
Application CallbackCallback
During initialization, the application can register a callback handler with the function goal_cclIeTsnNew.
The callback handler uses the following arguments:
...
Table 2‑6: Handling of Application Callback IDs in the Remote Station SDK
Code Block | ||
---|---|---|
| ||
static GOAL_STATUS_T appl_goalCclCb( |
...
GOAL_CCL_HANDLE_T *pCclm, |
...
/**< GOAL CCL handle */ |
...
GOAL_CCL_CB_ID_T cbId, |
...
/**< callback ID */ |
...
GOAL_CCL_CD_DATA_T |
...
)
{
...
*pCbData /**< callback data */ ) { GOAL_STATUS_T res = GOAL_OK; |
...
/* result */ |
...
...
switch (cbId) |
...
{ /* ... */ |
...
...
case GOAL_CCL_CB_SLAVE_WRONG_IP_ADDR: |
...
goal_logInfo("slave 0x%04x has unexpected IP address", |
...
*(pCbData- |
...
>pWrongIpAddrSlaveId)); |
...
/* abort initialization |
...
*/ res = GOAL_ERROR; |
...
break;
...
break; /* ... */ |
...
}
return res;
} return res; } |
Figure 2.3: Sample implementation of the application callback
Data Access with CANopen
...
CANopen
The Remote Station SDK can be extended with a CANopen package which provides an additional approach to configure the data transfer, using methods known originally adapted from the CANopen specification. Specifically, this uses the concepts of RPDO and TPDO configuration and PDO or SDO data transfer.
To set up this operation mode, the station mode needs to be marked as CANopen. Instead of Word link devices, CANopen link devices must be initialized. Additionally, this mode requires an object dictionary and a CANopen configuration file. It is recommended to use the port ICC tool to interactively create them. (See chapter 3 ICC Support in this document.)
When accessing the CANopen link devices, the general access function will not work. Instead, the following functions will address CANopen objects by index and subindex directly:
Function | Description |
goal_cclIeTsnInputDevSetCANopen | Write to object in object dictionary |
goal_cclIeTsnInputDevGetCANopen | Read from object in object dictionary |
|
|
|
|
Table 2‑7: CANopen Data Access Functions
Tabelle fehlt
object in object dictionary |
Table 2‑7: CANopen Data Access Functions
Code Block | ||
---|---|---|
| ||
/* set the station mode */
res = goal_cclIeTsnStationModeAdd(pCcl, GOAL_APPL_STATION_MODE_CANOPEN);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to set station mode");
return res;
}
/* this is a CANopen station mode */
res = goal_cclIeTsnStationModeSetCANopen(pCcl, GOAL_APPL_STATION_MODE_CANOPEN);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to set station mode to CANopen mode");
return res;
}
/* Statusword communication linkdevice */
res = goal_cclIeTsnLinkDevAdd(pCcl, GOAL_APPL_STATION_MODE_CANOPEN, GOAL_CCL_LINK_DEV_STSW, 0x60, 8);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to set local linkDev");
return res;
}
/* CANopen In -- CANopen uses a virtual address */
res = goal_cclIeTsnLinkDevAdd(pCcl, GOAL_APPL_STATION_MODE_CANOPEN, GOAL_CCL_LINK_DEV_CANOPEN_IN, 0x00004000, 1000);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to set local linkDev");
return res;
}
/* CANopen Out -- CANopen uses a virtual address */
res = goal_cclIeTsnLinkDevAdd(pCcl, GOAL_APPL_STATION_MODE_CANOPEN, GOAL_CCL_LINK_DEV_CANOPEN_OUT, 0x00008000, 1000);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to set local linkDev");
return res;
} |
Figure 2.4: Sample of CANopen Remote Station Setup
Supported Platforms
Since the CC-Link IE TSN Protocol stack runs on GOAL, it can run on any platform supported by GOAL.
In the less strict Conformance Class A, the time sensitive sending of ethernet frames can be supported by the included SoftwareQbv package. The hardware only has to support timestamping of the frames.
To fullfill the requirements of a Conformance Class B device, special hardware support is needed. The hardware must support timestamping of Ethernet frames as defined by IEEE 1588v2 or IEEE 802.1AS. Additionally, it must support time aware queuing of Ethernet frames as defined by IEEE 802.1Qbv.
As As development is constantly ongoing, the following table should not be seen as complete.
Confirmed Supported Hardware | Features
|
STM32F429ZI Nucleo Discovery Board | Conformance Class A Software Qbv IEEE1588v2 and IEEE802.1AS 100Mbit |
|
|
|
|
Table 2‑8: Confirmed Supported Hardware of the Remote Station SDK
Conformance Test
...
To perform the conformance test, several configurations must be tested. All of them where tested with the example application appl/goal_ccl_ie_tsn/02_slave. The respective master device or PLC is responsible for setting up the remote station for a specific test.