...
...
...
...
...
...
...
...
...
...
...
...
...
...
...
Tabelle fehlt
Remote Station Configuration
For each Remote Station station in the network a Remote Station handle must be added. Each Remote Station is represented by an Id. 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, i.e. after the expected Remote Station configuration has been received from the Engineering Tool.
Tabelle fehlt
Starting the CC-Link IE TSN Master Stack
After finishing all settings of the runtime behavior and the expected Remote Station configuration the stack must be started by calling goal_cclIeTsnStart.
...
res = goal_cclIeTsnStart(pCcl);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to start stack");
}
Figure 1.2: Start an instance of the CC-LINK IE TSN master stack
If this function succeeds the stack CC-Link IE TSN Master stack has been started and tries to detect all configured Remote Stations. 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 Master Station.
...
goal_cclIeTsnInputGet
...
Read Input data from the Cyclic Memory Map.
Only Input Link devices can be used. Each Link Device has ist own memory map.
...
goal_cclIeTsnOutputSet
...
Write Output data to the Cyclic Memory Map
Only Output Link devices can be used. Each Link Device has its own 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.
Calling this function will cause all controlled devices in the network to shutdown.
After calling this function the application is expected to halt the device and stop processing cyclic data.
...
goal_cclIeTsnPowerSupplyErrorStopExec
...
Issue an Emergency Stop due to Power supply error.
Calling this function will cause all controlled devices in the network to shutdown.
After calling this function the application is expected to halt the device and stop processing cyclic data.
...
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_cclIeTsnSdoWrite
...
Start a SDO Write operation for a Remote Station.
...
goal_cclIeTsnSdoRead
...
Start a SDO Read operation for a Remote Station.
...
goal_cclIeTsnNmtUpload
...
Get the NMT state of a CANopen Remote Station.
...
goal_cclIeTsnNmtDownload
...
Set the NMT state of a CANopen Remote Station.
...
goal_cclIeTsnSlaveProcTypeRead
...
Request processor Type information from a Remote Station
Table 1‑5: Functions used during Run phase
Application Callback
During initialization, the application can register a callback handler with the function goal_cclIeTsnNew.
The callback handler uses the following arguments:
...
Argument data type
...
Description
...
GOAL_CCL_HANDLE_T *
...
CC-Link IE TSN stack instance reference
...
GOAL_CCL_CB_ID_T
...
callback ID indicating callback type
...
GOAL_CCL_CD_DATA_T *
...
callback data, actual meaning depends on callback ID
Table 1‑6: Arguments of the Application Callback Handler
Some callback ID also evaluate the return value of the handler to decide how to proceed.
...
Callback ID
...
Description
...
Callback data
...
Return value
...
GOAL_CCL_CB_DETECTION_MISMATCH
...
mismatch in detected Remote Stations and configuration from engineering tool
...
NULL
...
don't care
...
GOAL_CCL_CB_NETCFG_MISMATCH
...
mismatch in network configuration
...
pNetConfigMismatchId
(Id of Remote Station with mismatching network configuration)
...
GOAL_OK: continue operation
other: go to Error state
...
GOAL_CCL_CB_MASTERCFG_MISMATCH
...
mismatch in configuration of a Control Master
...
NULL
...
don't care
...
GOAL_CCL_CB_ERROR_STATE
...
device entered Error state
...
NULL
...
don't care
...
GOAL_CCL_CB_UNKNOWN_SLAVE
...
detected a Remote Station that was not set by the engineering tool
...
pUnknownSlaveIpAddr
(IP Address of unknown Remote Station)
...
don't care
...
GOAL_CCL_CB_SLAVE_UNDETECTED
...
Remote Station was not detected in the network
...
pUndetectedSlaveId
(ID of Remote Station Handle)
...
GOAL_OK: continue operation
other: go to Error state
...
GOAL_CCL_CB_SLAVE_WRONG_IP_ADDR
...
Remote Station has wrong IP address (not in the same subnet)
...
pWrongIpAddrSlaveId
(ID of Remote Station Handle)
...
GOAL_OK: continue operation
other: go to Error state
...
GOAL_CCL_CB_SLAVE_IP_ADDR_DUPL
...
Remote Station has a duplicate IP address
...
pDuplicateIpAddrSlaveId
(ID of Remote Station Handle)
...
GOAL_OK: continue operation
other: go to Error state
...
GOAL_CCL_CB_SLMP_ERROR
...
SLMP error received from station
...
pSlmpErrorInfo->slaveId
(ID of Remote Station Handle)
pSlmpErrorInfo->cmd
(SLMP command)
pSlmpErrorInfo->subCmd
(SLMP subcommand)
pSlmpErrorInfo->endCode
(end code indicating error)
...
don't care
...
GOAL_CCL_CB_CM_UNCONFIGURED
...
Control Master is not configured
...
pUnconfiguredMasterId
(ID of Control Master handle)
...
GOAL_OK: continue operation
other: go to Error state
...
GOAL_CCL_CB_SLAVE_UNCONTROLLED
...
Remote Station not controlled by its Control Master
...
pUncontrolledSlaveId
(ID of Remote Station Handle)
...
GOAL_OK: continue operation
other: go to Error state
...
GOAL_CCL_CB_WRONG_GRANDMASTER
...
Remote Station has a different Grandmaster
...
pWrongGrandmasterSlaveId
(ID of Remote Station Handle)
...
don't care
...
GOAL_CCL_CB_RSV_TRANSIENT_DONE
...
reserved transient transmission done
...
NULL
...
don't care
...
GOAL_CCL_CB_RESERVED_STATION_ON
...
device entered Reserved Station mode
...
NULL
...
don't care
...
GOAL_CCL_CB_RESERVED_STATION_OFF
...
device left Reserved Station mode
...
NULL
...
don't care
...
GOAL_CCL_CB_CYCLIC_STOP_ON
...
cyclic communication stopped
...
NULL
...
don't care
...
GOAL_CCL_CB_CYCLIC_STOP_OFF
...
cyclic communication restarted
...
NULL
...
don't care
...
GOAL_CCL_CB_OWN_STATION_EMG_STOP
...
device received Emergency Stop request
...
pEmgGroup
(EMG group causing stop)
...
don't care
...
GOAL_CCL_CB_CYCLIC_ERROR_ON
...
other station causes cyclic error
...
pCyclicErrIpAddr
(IP address of Remote Station)
...
don't care
...
GOAL_CCL_CB_CYCLIC_ERROR_OFF
...
other station fixed cyclic error
...
pCyclicErrIpAddr
(IP address of Remote Station)
...
don't care
...
GOAL_CCL_CB_OTHER_STATION_EMG_STOP
...
Emergency stop for an Emergency Group
...
pEmgGroup
(EMG group that will be stopped)
...
don't care
...
GOAL_CCL_CB_OTHER_STATION_GOF_STOP
...
Emergency stop for a GOF Group
...
pGofGroup
(GOF group that will be stopped)
...
don't care
...
GOAL_CCL_CB_SLAVE_INVALID_CFG
...
expected configuration of Remote Station is not valid
...
pInvalidCfgSlaveId
(ID of Remote Station Handle)
...
GOAL_OK: continue operation
other: go to Error state
...
GOAL_CCL_CB_SLAVE_INVALID_DATA_ON
...
received invalid control data from Remote Station
...
pInvalidCycDataSlaveId
(ID of Remote Station Handle)
...
don't care
...
GOAL_CCL_CB_SLAVE_INVALID_DATA_OFF
...
control data from Remote Station is valid again
...
pInvalidCycDataSlaveId
(ID of Remote Station Handle)
...
don't care
...
GOAL_CCL_CB_CYC_COM_ENABLED
...
station started to send and receive process data
...
NULL
...
don't care
...
GOAL_CCL_CB_CYC_COM_DISABLED
...
...
...
station’s IP address is also used by another station
...
NULL
...
don’t care
...
GOAL_CCL_CB_READPROCTYPE_RES
...
received a ReadProcType response
...
pReadProcTypeRes
(ReadProcType response data)
...
don’t care
Table 1‑7: Handling of Application Callback IDs
static GOAL_STATUS_T appl_goalCclCb(
GOAL_CCL_HANDLE_T *pCclm, /**< GOAL CCL handle */
...
...
...
...
)
{
GOAL_STATUS_T res = GOAL_OK; /* result */
switch (cbId) {
/* ... */
...
...
goal_logInfo("slave 0x%04x has unexpected IP address",
*(pCbData->pWrongIpAddrSlaveId));
/* abort initialization */
res = GOAL_ERROR;
break;
/* ... */
}
return res;
}
Figure 1.3: Sample implementation of the application callback
Configuration of CANopen Remote Stations
CANopen Remote Stations are configured with the same functions as Link Device Remote Stations. Additionally, there is the function goal_cclIeTsnSlaveCanOpenConfigSet to set CANopen specific properties of the Remote Station.
...
static uint16_t slave2RpdoMapObj = 0x1601; /**< Slave2: RPDO Mapping object */
static uint16_t slave2TpdoMapObj = 0x1A01; /**< Slave2: TPDO Mapping object */
static GOAL_CCL_CO_STARTUP_T slave2StartUpCmds[] = {
{GOAL_TRUE, 0x1C00, 1, sizeof(uint16_t), (uint8_t *) &slave2RpdoMapObj},
{GOAL_TRUE, 0x1C01, 1, sizeof(uint16_t), (uint8_t *) &slave2TpdoMapObj},
};
static uint16_t slave2TpdoCfgTbl[] = {
0x1C01,
};
static uint16_t slave2RpdoCfgTbl[] = {
0x1C00,
};
res = goal_cclIeTsnSlaveCanOpenConfigSet(pCcl, slaveId,
slave2StartUpCmds, ARRAY_ELEMENTS(slave2StartUpCmds),
slave2TpdoCfgTbl, ARRAY_ELEMENTS(slave2TpdoCfgTbl),
slave2RpdoCfgTbl, ARRAY_ELEMENTS(slave2RpdoCfgTbl));
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to configure CANopen properties of slave %u", slaveId);
}
Figure 1.4: Configuration of a CANopen remote station
An entry in the startup command table has the following fields:
...
typedef struct {
GOAL_BOOL_T wrFlag; /**< write or read access */
uint16_t index; /**< object index */
uint16_t subIndex; /**< object subindex */
uint16_t dataLen; /**< size of data to be written or read */
uint8_t *pData; /**< write data buffer */
} GOAL_CCL_CO_STARTUP_T;
Figure 1.5: CANopen startup command table entry
The other two tables contain lists of TPDO Config Objects and RPDO Config objects that must be enabled for cyclic communication.
In the RUN phase the application can use the functions goal_cclIeTsnSdoWrite and goal_cclIeTsnSdoRead to start SDO write or read operations.
CANopen Data Callback
The application can use the function goal_cclIeTsnCanOpenCallbackSet to register a callback handler for CANopen object access.
...
res = goal_cclIeTsnCanOpenCallbackSet(pCcl, appl_goalCclCanOpenCb);
if (GOAL_RES_ERR(res)) {
goal_logErr("Failed to register CANopen callback");
}
Figure 1.6: Register a CANopen callback handler
The handler is called by the protocol stack every time a SDO Read or Write response was received, including those of the startup commands.
The callback handler uses the callback IDs GOAL_CCL_CO_CB_SDO_READ_RES or GOAL_CCL_CO_CB_SDO_WRITE_RES to indicate if the callback data refers to a read response or a write response.
The callback IDs GOAL_CCL_CO_CB_NMT_UPL_RES and GOAL_CCL_CO_CB_NMT_DNL_RES are used to indicate results of an NMT Upload or Download request.
...
Member
...
Data type
...
Description
...
slaveId
...
uint16_t
...
Remote Station id
...
endCode
...
uint16_t
...
SLMP end code (status of operation)
...
index
...
uint16_t
...
object index (only valid during startup or if endCode == 0x0000)
...
subIndex
...
uint8_t
...
object subindex (only valid during startup or if endCode == 0x0000)
...
dataLen
...
uint16_t
...
object data length (only valid for read access and if endCode == 0x0000)
...
pData
...
uint8_t *
...
object data (only valid for read access and if endCode == 0x0000) or
current NMT state of responder (as a uint8_t variable)
Table 1‑8: Members of callback data of CANopen data callback
1.1 Supported Platforms
Since the CC-Link IE TSN Protocol stack runs on GOAL, it can run on any platform supported by GOAL. However, to fullfill the requirements of a 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 development is constantly ongoing, the following table should not be seen as complete.
...
Confirmed Supported Hardware
...
Features
...
NXP LS1028A
...
Conformance Class B
Hardware Qbv Support
IEEE1588v2 and IEEE802.1AS
100Mbit/1000Mbit
...
...
...
...
Table 1‑9: Confirmed Supported Hardware for the Master SDK
NXP LS1028A
The NXP LS1028A is a SoC that fullfills the hardware requirements for a Class B device.
There is an evaluation board called LS1028ARDB.
Building the firmware
The LS1028ARDB uses OpenIL, a Linux distribution for industrial automation with Realtime support. The distribution can be built with Buildroot.
git clone https://github.com/openil/openil.git
cd openil
git checkout OpenIL-v1.9-202009
make nxp_ls1028ardb-64b_defconfig
make 2>&1 | tee build.log
Flashing the firmware
Once the firmware has been built it must be copied to the SD-Card of the LS1028ARDB.
insert SD-Card into Linux P
card is listed as /dev/sdX [e.g. /dev/sdc]
see log via dmesg
in directory openil:
sudo dd if=output/images/sdcard.img of=/dev/sdc bs=1024
ATTENTION: choosing the wrong output device will overwrite sections of the PC’s HDD/SDD
causing data loss
insert SD-Card into LS1028ARD and start device
Debug Interface
A serial console is available on UART1.
Use the following parameters: 115,200 baud/s, 8 data bits, no parity, 1 stop bit.
Configuration of the LS1028ARDB
It is possible to configure the number of ports used for CC-Link IE TSN. By default each port of the integrated TSN Switch is independent, i.e. there is no forwarding between these ports.
The interfaces representing these ports are called swp0 to swp3. In order to enable forwarding between two or more ports the following script could be executed:
#!/bin/sh
# create a bridge device
ip link add name switch type bridge
ip link set switch up
# add 1st port
ip link set swp0 master switch
ip link set swp0 up
# add 2nd port
ip link set swp1 master switch
ip link set swp1 up
# uncomment to add 3rd port
#ip link set swp2 master switch
#ip link set swp2 up
# uncomment to add 4th port
#ip link set swp3 master switch
#ip link set swp3 up
# add a route for this interface (subnet address might need to adjusted)
ip route add 192.168.3.0/24 dev switch
This will create a new interface called “switch”.
By default, the OpenIL image runs netopeer2, a NETCONF server. This server interfers with the Realtime behaviour of the GOAL process. Therefore, the server must be removed from the initialization scripts:
rm /etc/init.d/S91netopeer2-server
Building the CC-Link IE TSN Master Application
The application can be built with aarch64-linux-gnu-gcc.
Navigate to the project folder of a sample application, e.g. “projects/goal_ccl_ie_tsn/03_master_ct/gcc”.
Select the target platform (only required once)
make select
enter the number of “linux_nxp_ls1028a”
build sample application
make
The binary is located at
“projects/goal_ccl_ie_tsn/03_master_ct/gcc/linux_nxp_ls1028a/goal_ linux_nxp_ls1028a.bin”.
The file must be copied to the LS1028ARDB, e.g. via scp.
On the LS1028ARDB:
reduce kernel log messages to only critical ones
echo 1 > /proc/sys/kernel/printk
disable memory overcommitting
echo 2 > /proc/sys/vm/overcommit_memory
make application ecutable
chmod +x goal_ linux_nxp_ls1028a.bin
start application (adjust Ethernet port if necessary)
./goal_ linux_nxp_ls1028a.bin -i <IFACE>
Note:
<IFACE> is the ethernet interface that GOAL should use. This is either the bridge device “switch” or a standalone port, e.g. “swp0”.
Start CC-Link IE TSN Master application automatically
In order to start the Master SDK automatically after boot up, a script must be created in the directory /etc/init.d, e.g. S99GOAL.
The script should have the following content:
#!/bin/sh
#
# CC-Link IE TSN Master SDK
#
GOAL=/root/goal_linux_nxp_ls1028a.bin
start() {
echo 1 > /proc/sys/kernel/printk
echo 2 > /proc/sys/vm/overcommit_memory
printf "Starting CC-Link IE TSN Master SDK: "
${GOAL} -i swp0 &
echo "OK"
}
stop() {
printf "Stopping CC-Link IE TSN Master SDK: "
killall $(basename ${GOAL})
echo "OK"
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
restart
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
esac
Please make sure that the script is executable:
...
...
...
...
...