Configuration macros updated
This commit is contained in:
parent
05b488c45c
commit
7a43f98f24
6 changed files with 170 additions and 73 deletions
|
|
@ -75,7 +75,7 @@ typedef enum {
|
|||
OD_H1012_COBID_TIME = 0x1012U,/**< Timestamp message cob-id */
|
||||
OD_H1013_HIGH_RES_TIMESTAMP = 0x1013U,/**< High resolution timestamp */
|
||||
OD_H1014_COBID_EMERGENCY = 0x1014U,/**< Emergency message cob-id */
|
||||
OD_H1015_INHIBIT_TIME_MSG = 0x1015U,/**< Inhibit time message */
|
||||
OD_H1015_INHIBIT_TIME_EMCY = 0x1015U,/**< Inhibit time emergency message */
|
||||
OD_H1016_CONSUMER_HB_TIME = 0x1016U,/**< Consumer heartbeat time */
|
||||
OD_H1017_PRODUCER_HB_TIME = 0x1017U,/**< Producer heartbeat time */
|
||||
OD_H1018_IDENTITY_OBJECT = 0x1018U,/**< Identity object */
|
||||
|
|
@ -90,25 +90,18 @@ typedef enum {
|
|||
OD_H1027_MODULE_LIST = 0x1027U,/**< Module list */
|
||||
OD_H1028_EMCY_CONSUMER = 0x1028U,/**< Emergency consumer object */
|
||||
OD_H1029_ERR_BEHAVIOR = 0x1029U,/**< Error behaviour */
|
||||
OD_H1200_SDO_SERVER_PARAM = 0x1200U,/**< SDO server parameters */
|
||||
OD_H1280_SDO_CLIENT_PARAM = 0x1280U,/**< SDO client parameters */
|
||||
OD_H1200_SDO_SERVER_1_PARAM = 0x1200U,/**< SDO server parameter */
|
||||
OD_H1280_SDO_CLIENT_1_PARAM = 0x1280U,/**< SDO client parameter */
|
||||
OD_H1300_GFC_PARAM = 0x1300U,/**< Global fail-safe command param */
|
||||
OD_H1301_SRDO_1_PARAM = 0x1301U,/**< SRDO communication parameter */
|
||||
OD_H1381_SRDO_1_MAPPING = 0x1381U,/**< SRDO mapping parameter */
|
||||
OD_H13FE_SRDO_VALID = 0x13FEU,/**< SRDO Configuration valid */
|
||||
OD_H13FF_SRDO_CHECKSUM = 0x13FFU,/**< SRDO configuration checksum */
|
||||
OD_H1400_RXPDO_1_PARAM = 0x1400U,/**< RXPDO communication parameter */
|
||||
OD_H1401_RXPDO_2_PARAM = 0x1401U,/**< RXPDO communication parameter */
|
||||
OD_H1402_RXPDO_3_PARAM = 0x1402U,/**< RXPDO communication parameter */
|
||||
OD_H1403_RXPDO_4_PARAM = 0x1403U,/**< RXPDO communication parameter */
|
||||
OD_H1600_RXPDO_1_MAPPING = 0x1600U,/**< RXPDO mapping parameters */
|
||||
OD_H1601_RXPDO_2_MAPPING = 0x1601U,/**< RXPDO mapping parameters */
|
||||
OD_H1602_RXPDO_3_MAPPING = 0x1602U,/**< RXPDO mapping parameters */
|
||||
OD_H1603_RXPDO_4_MAPPING = 0x1603U,/**< RXPDO mapping parameters */
|
||||
OD_H1800_TXPDO_1_PARAM = 0x1800U,/**< TXPDO communication parameter */
|
||||
OD_H1801_TXPDO_2_PARAM = 0x1801U,/**< TXPDO communication parameter */
|
||||
OD_H1802_TXPDO_3_PARAM = 0x1802U,/**< TXPDO communication parameter */
|
||||
OD_H1803_TXPDO_4_PARAM = 0x1803U,/**< TXPDO communication parameter */
|
||||
OD_H1A00_TXPDO_1_MAPPING = 0x1A00U,/**< TXPDO mapping parameters */
|
||||
OD_H1A01_TXPDO_2_MAPPING = 0x1A01U,/**< TXPDO mapping parameters */
|
||||
OD_H1A02_TXPDO_3_MAPPING = 0x1A02U,/**< TXPDO mapping parameters */
|
||||
OD_H1A03_TXPDO_4_MAPPING = 0x1A03U /**< TXPDO mapping parameters */
|
||||
} OD_ObjDicId_301_t;
|
||||
} OD_ObjDicId_30x_t;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -369,7 +362,7 @@ typedef struct {
|
|||
/** Number of elements in the list, without last element, which is blank */
|
||||
uint16_t size;
|
||||
/** List OD entries (table of contents), ordered by index */
|
||||
OD_entry_t list[];
|
||||
const OD_entry_t *list;
|
||||
} OD_t;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -153,6 +153,16 @@ extern "C" {
|
|||
#define CO_CONFIG_HB_CONS_CALLBACK_CHANGE 0x02
|
||||
#define CO_CONFIG_HB_CONS_CALLBACK_MULTI 0x04
|
||||
#define CO_CONFIG_HB_CONS_QUERY_FUNCT 0x08
|
||||
|
||||
/**
|
||||
* Number of heartbeat consumer objects, where each object corresponds to one
|
||||
* sub-index in OD object 0x1016, "Consumer heartbeat time".
|
||||
*
|
||||
* If heartbeat consumer is enabled, then valid values are 1 to 127.
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_HB_CONS_SIZE 8
|
||||
#endif
|
||||
/** @} */ /* CO_STACK_CONFIG_NMT_HB */
|
||||
|
||||
|
||||
|
|
@ -172,7 +182,7 @@ extern "C" {
|
|||
* OD object 0x1015.
|
||||
* - CO_CONFIG_EM_HISTORY - Enable error history, OD object 0x1003,
|
||||
* "Pre-defined error field"
|
||||
* - CO_CONFIG_EM_CONSUMER - Enable emergency consumer.
|
||||
* - CO_CONFIG_EM_CONSUMER - Enable simple emergency consumer with callback.
|
||||
* - CO_CONFIG_EM_STATUS_BITS - Access @ref CO_EM_errorStatusBits_t from OD.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* emergency condition by CO_errorReport() or CO_errorReset() call.
|
||||
|
|
@ -215,7 +225,6 @@ extern "C" {
|
|||
#define CO_CONFIG_EM_BUFFER_SIZE 16
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
* Condition for calculating CANopen Error register, "generic" error bit.
|
||||
*
|
||||
|
|
@ -376,6 +385,28 @@ extern "C" {
|
|||
/** @} */ /* CO_STACK_CONFIG_SDO */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_TIME Time producer/consumer
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_TIME
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_TIME_ENABLE - Enable TIME object and TIME consumer.
|
||||
* - CO_CONFIG_TIME_PRODUCER - Enable TIME producer.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received TIME CAN message.
|
||||
* Callback is configured by CO_TIME_initCallbackPre().
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_TIME (0)
|
||||
#endif
|
||||
#define CO_CONFIG_TIME_ENABLE 0x01
|
||||
#define CO_CONFIG_TIME_PRODUCER 0x02
|
||||
/** @} */ /* CO_STACK_CONFIG_TIME */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_SYNC_PDO SYNC and PDO producer/consumer
|
||||
* @{
|
||||
|
|
@ -404,6 +435,7 @@ extern "C" {
|
|||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_RPDO_ENABLE - Enable receive PDO objects.
|
||||
* - CO_CONFIG_TPDO_ENABLE - Enable transmit PDO objects.
|
||||
* - CO_CONFIG_PDO_SYNC_ENABLE - Enable SYNC in PDO objects.
|
||||
* - CO_CONFIG_RPDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
* callbacks when received RPDO CAN message modifies OD entries.
|
||||
* - CO_CONFIG_TPDO_CALLS_EXTENSION - Enable calling configured extension
|
||||
|
|
@ -417,34 +449,14 @@ extern "C" {
|
|||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_PDO (CO_CONFIG_RPDO_ENABLE | CO_CONFIG_TPDO_ENABLE | CO_CONFIG_PDO_SYNC_ENABLE)
|
||||
#endif
|
||||
#define CO_CONFIG_PDO_SYNC_ENABLE 0x01
|
||||
#define CO_CONFIG_RPDO_CALLS_EXTENSION 0x02
|
||||
#define CO_CONFIG_TPDO_CALLS_EXTENSION 0x04
|
||||
#define CO_CONFIG_RPDO_ENABLE 0x01
|
||||
#define CO_CONFIG_TPDO_ENABLE 0x02
|
||||
#define CO_CONFIG_PDO_SYNC_ENABLE 0x04
|
||||
#define CO_CONFIG_RPDO_CALLS_EXTENSION 0x08
|
||||
#define CO_CONFIG_TPDO_CALLS_EXTENSION 0x10
|
||||
/** @} */ /* CO_STACK_CONFIG_SYNC_PDO */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_TIME Time producer/consumer
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* Configuration of @ref CO_TIME
|
||||
*
|
||||
* Possible flags, can be ORed:
|
||||
* - CO_CONFIG_TIME_ENABLE - Enable TIME object and TIME consumer.
|
||||
* - CO_CONFIG_TIME_PRODUCER - Enable TIME producer.
|
||||
* - #CO_CONFIG_FLAG_CALLBACK_PRE - Enable custom callback after preprocessing
|
||||
* received TIME CAN message.
|
||||
* Callback is configured by CO_TIME_initCallbackPre().
|
||||
*/
|
||||
#ifdef CO_DOXYGEN
|
||||
#define CO_CONFIG_TIME (0)
|
||||
#endif
|
||||
#define CO_CONFIG_TIME_ENABLE 0x01
|
||||
#define CO_CONFIG_TIME_PRODUCER 0x02
|
||||
/** @} */ /* CO_STACK_CONFIG_TIME */
|
||||
|
||||
|
||||
/**
|
||||
* @defgroup CO_STACK_CONFIG_LEDS CANopen LED diodes
|
||||
* Specified in standard CiA 303-3
|
||||
|
|
|
|||
|
|
@ -119,9 +119,9 @@ extern ODxyz_0_t ODxyz_0;
|
|||
extern ODxyz_1_t ODxyz_1;
|
||||
extern const OD_t ODxyz;
|
||||
|
||||
#define ODxyz_1000_deviceType &ODxyz.list[0]
|
||||
#define ODxyz_1001_errorRegister &ODxyz.list[1]
|
||||
#define ODxyz_1018_identity &ODxyz.list[2]
|
||||
#define ODxyz_ENTRY_H1000 &ODxyz.list[0]
|
||||
#define ODxyz_ENTRY_H1001 &ODxyz.list[1]
|
||||
#define ODxyz_ENTRY_H1018 &ODxyz.list[2]
|
||||
```
|
||||
|
||||
### Example ODxyz.c file
|
||||
|
|
@ -203,13 +203,17 @@ static const ODxyz_objs_t ODxyz_objs = {
|
|||
}
|
||||
};
|
||||
|
||||
const OD_t ODxyz = {
|
||||
3, {
|
||||
static const OD_entry_t ODxyz_list[] = {
|
||||
{0x1000, 0, 0, ODT_VAR, &ODxyz_objs.o_1000_deviceType},
|
||||
{0x1001, 0, 1, ODT_EVAR, &ODxyz_objs.o_1001_errorRegister},
|
||||
{0x1018, 4, 0, ODT_REC, &ODxyz_objs.o_1018_identity},
|
||||
{0x0000, 0, 0, 0, NULL}
|
||||
}};
|
||||
};
|
||||
|
||||
const OD_t OD = {
|
||||
(sizeof(OD_list) / sizeof(OD_list[0])) - 1,
|
||||
&ODxyz_list[0]
|
||||
};
|
||||
```
|
||||
|
||||
|
||||
|
|
@ -394,7 +398,7 @@ Additional, optional, CANopenNode specific properties, which can be used inside
|
|||
* <property name="CO_storageGroup" value="..."> - group into which the C variable will belong. Variables from specific storage group may then be stored into non-volatile memory, automatically or by SDO command. Valid value is from 0x00 (default - not stored) to 0x7F.
|
||||
* <property name="CO_extensionIO" value="..."> - Valid value is "false" (default) or "true", if IO extension is enabled.
|
||||
* <property name="CO_flagsPDO" value="..."> - Valid value is "false" (default) or "true", if PDO flags are enabled.
|
||||
* <property name="CO_countLabel" value="..."> - Valid value is any string without spaces. OD exporter will generate a macro for each different string. For example, if four OD objects have "CO_countLabel" set to "TPDO", then macro "#define ODxyz_NO_TPDO 4" will be generated by OD exporter.
|
||||
* <property name="CO_countLabel" value="..."> - Valid value is any string without spaces. OD exporter will generate a macro for each different string. For example, if four OD objects have "CO_countLabel" set to "TPDO", then macro "#define ODxyz_CNT_TPDO 4" will be generated by OD exporter.
|
||||
|
||||
Additional, optional, CANopenNode specific property, which can be used inside parameters describing "VAR":
|
||||
* <property name="CO_accessSRDO" value="..."> - Valid values are: "tx", "rx", "trx", "no"(default).
|
||||
|
|
@ -427,3 +431,66 @@ This is optional element and is not required by standard, nor by CANopenNode. Th
|
|||
|
||||
#### Other elements
|
||||
Other elements listed in the above XML example are required by the standard and does not influence the CANopenNode object dictionary generator.
|
||||
|
||||
|
||||
### Object dictionary requirements by CANopenNode
|
||||
* **Used by** column indicates CANopenNode object or its part, which uses the OD object. It also indicates, if OD object is required or optional for actual configuration. For the configuration of the CANopenNode objects see [Stack configuration](301/CO_config.h). If CANopenNode object or its part is disabled in stack configuration, then OD object is not used. Note that OD objects: 1000, 1001 and 1017 and 1018 are mandatory for CANopen.
|
||||
* **CO_extensionIO** column indicates, if OD object must have property "CO_extensionIO" set to true:
|
||||
* "no" - no IO extension used
|
||||
* "optional" - If IO extension is enabled, then writing to the OD parameter will reflect in CANopen run time, otherwise reset communication is required for changes to take effect.
|
||||
* "required" - IO extension is required on OD object and init function will return error if not enabled.
|
||||
* "req if DYNAMIC" - IO extension is required on OD object if CO_CONFIG_FLAG_OD_DYNAMIC is set.
|
||||
* "yes, own data" - OD object don't need own data and IO extension is necessary for OD object to work. Init function will not return error, if OD object does not exist or doesn't have IO extension enabled.
|
||||
* **CO_countLabel** column indicates, which value must have property "CO_countLabel" inside OD object.
|
||||
|
||||
| index | Description | Used by | CO_extensionIO | CO_countLabel |
|
||||
| ----- | ----------------------------- | ---------------------| -------------- | ------------- |
|
||||
| 1000 | Device type | CANopen, req | no | NMT |
|
||||
| 1001 | Error register | CANopen, EM, req | no | EM |
|
||||
| 1002 | Manufacturer status register | | | |
|
||||
| 1003 | Pre-defined error field | EM_HISTORY, opt | yes, own data | |
|
||||
| 1005 | COB-ID SYNC message | SYNC, req | req if DYNAMIC | SYNC |
|
||||
| 1006 | Communication cycle period | SYNC_PRODUCER, req | opt | SYNC_PROD |
|
||||
| 1007 | Synchronous window length | SYNC, opt | opt | |
|
||||
| 1008 | Manufacturer device name | | | |
|
||||
| 1009 | Manufacturer hardware version | | | |
|
||||
| 100A | Manufacturer software version | | | |
|
||||
| 100C | Guard time | | | |
|
||||
| 100D | Life time factor | | | |
|
||||
| 1010 | Store parameters | | | |
|
||||
| 1011 | Restore default parameters | | | |
|
||||
| 1012 | COB-ID time stamp object | TIME, req | required | TIME |
|
||||
| 1013 | High resolution time stamp | | | |
|
||||
| 1014 | COB-ID EMCY | EM_PRODUCER, req | required | EM_PROD |
|
||||
| 1015 | Inhibit time EMCY | EM_PROD_INHIBIT, opt | optional | |
|
||||
| 1016 | Consumer heartbeat time | HB_CONS, req | optional | HB_CONS |
|
||||
| 1017 | Producer heartbeat time | CANopen, NMT, req | optional | HB_PROD |
|
||||
| 1018 | Identity object | CANopen, LSS_SL, req | no | |
|
||||
| 1019 | Synch. counter overflow value | SYNC, opt | no | |
|
||||
| 1020 | Verify configuration | | | |
|
||||
| 1021 | Store EDS | | | |
|
||||
| 1022 | Store format | | | |
|
||||
| 1023 | OS command | | | |
|
||||
| 1024 | OS command mode | | | |
|
||||
| 1025 | OS debugger interface | | | |
|
||||
| 1026 | OS prompt | | | |
|
||||
| 1027 | Module list | | | |
|
||||
| 1028 | Emergency consumer object | | | |
|
||||
| 1029 | Error behavior object | | | |
|
||||
| 1200 | SDO server parameter (first) | SDO optional | required | SDO_SRV |
|
||||
| 1201+ | SDO server parameter | SDO+, req | req if DYNAMIC | SDO_SRV |
|
||||
| 1280+ | SDO client parameter | SDO_CLI, req | req if DYNAMIC | SDO_CLI |
|
||||
| 1300 | Global fail-safe command par | GFC, req | | GFC |
|
||||
| 1301+ | SRDO communication parameter | SRDO, req | | SRDO |
|
||||
| 1381+ | SRDO mapping parameter | SRDO, req | | |
|
||||
| 13FE | Configuration valid | SRDO, req | | |
|
||||
| 13FF | Safety configuration checksum | SRDO, req | | |
|
||||
| 1400+ | RPDO communication parameter | RPDO, req | req if DYNAMIC | RPDO |
|
||||
| 1600+ | RPDO mapping parameter | RPDO, req | req if DYNAMIC | |
|
||||
| 1800+ | TPDO communication parameter | TPDO, req | req if DYNAMIC | TPDO |
|
||||
| 1A00+ | TPDO mapping parameter | TPDO, req | req if DYNAMIC | |
|
||||
| 1FA0+ | Object scanner list | | | |
|
||||
| 1FD0+ | Object dispatching list | | | |
|
||||
| | Custom objects | | | |
|
||||
| any | Error status bits | EM_STATUS_BITS, opt | yes, own data | |
|
||||
| any+ | Trace | TRACE, req | yes, own data | TRACE |
|
||||
|
|
|
|||
|
|
@ -95,6 +95,12 @@ extern "C" {
|
|||
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TIME
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | \
|
||||
CO_CONFIG_TIME_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | \
|
||||
CO_CONFIG_SYNC_PRODUCER | \
|
||||
|
|
@ -112,12 +118,6 @@ extern "C" {
|
|||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TIME
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | \
|
||||
CO_CONFIG_TIME_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LEDS
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
|
|
|
|||
|
|
@ -110,6 +110,12 @@ extern "C" {
|
|||
#define CO_CONFIG_SDO_CLI_BUFFER_SIZE 1000
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TIME
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | \
|
||||
CO_CONFIG_TIME_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE_USED)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_SYNC
|
||||
#define CO_CONFIG_SYNC (CO_CONFIG_SYNC_ENABLE | \
|
||||
CO_CONFIG_SYNC_PRODUCER | \
|
||||
|
|
@ -127,12 +133,6 @@ extern "C" {
|
|||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TIME
|
||||
#define CO_CONFIG_TIME (CO_CONFIG_TIME_ENABLE | \
|
||||
CO_CONFIG_TIME_PRODUCER | \
|
||||
CO_CONFIG_FLAG_CALLBACK_PRE_USED)
|
||||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_LEDS
|
||||
#define CO_CONFIG_LEDS (CO_CONFIG_LEDS_ENABLE | \
|
||||
CO_CONFIG_FLAG_TIMERNEXT)
|
||||
|
|
@ -172,7 +172,7 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
#ifndef CO_CONFIG_TRACE
|
||||
#define CO_CONFIG_TRACE (CO_CONFIG_TRACE_ENABLE)
|
||||
//#define CO_CONFIG_TRACE (CO_CONFIG_TRACE_ENABLE)
|
||||
#endif
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,9 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef CO_OD_STORAGE
|
||||
#define CO_OD_STORAGE 1
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
|
@ -40,9 +43,11 @@
|
|||
#include <sys/reboot.h>
|
||||
|
||||
#include "CANopen.h"
|
||||
#include "CO_OD_storage.h"
|
||||
#include "CO_error.h"
|
||||
#include "CO_epoll_interface.h"
|
||||
#if CO_OD_STORAGE == 1
|
||||
#include "CO_OD_storage.h"
|
||||
#endif
|
||||
|
||||
/* Call external application functions. */
|
||||
#if __has_include("CO_application.h")
|
||||
|
|
@ -51,7 +56,7 @@
|
|||
#endif
|
||||
|
||||
/* Add trace functionality for recording variables over time */
|
||||
#if CO_NO_TRACE > 0
|
||||
#if (CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE
|
||||
#include "CO_time_trace.h"
|
||||
#endif
|
||||
|
||||
|
|
@ -79,11 +84,13 @@ static uint8_t CO_pendingNodeId = 0xFF;/* Use value from Object Dic
|
|||
* or unconfigured=0xFF). Can be changed by LSS slave. */
|
||||
static uint8_t CO_activeNodeId = 0xFF;/* Copied from CO_pendingNodeId in the communication reset section */
|
||||
static uint16_t CO_pendingBitRate = 0; /* CAN bitrate, not used here */
|
||||
#if CO_OD_STORAGE == 1
|
||||
static CO_OD_storage_t odStor; /* Object Dictionary storage object for CO_OD_ROM */
|
||||
static CO_OD_storage_t odStorAuto; /* Object Dictionary storage object for CO_OD_EEPROM */
|
||||
static char *odStorFile_rom = "od_storage"; /* Name of the file */
|
||||
static char *odStorFile_eeprom = "od_storage_auto"; /* Name of the file */
|
||||
#if CO_NO_TRACE > 0
|
||||
#endif
|
||||
#if (CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE
|
||||
static CO_time_t CO_time; /* Object for current time */
|
||||
#endif
|
||||
|
||||
|
|
@ -169,6 +176,7 @@ static void HeartbeatNmtChangedCallback(uint8_t nodeId,
|
|||
nodeId, NmtState2Str(state), state);
|
||||
}
|
||||
|
||||
#if CO_OD_STORAGE == 1
|
||||
/* callback for storing node id and bitrate */
|
||||
static bool_t LSScfgStoreCallback(void *object, uint8_t id, uint16_t bitRate) {
|
||||
(void)object;
|
||||
|
|
@ -176,6 +184,7 @@ static bool_t LSScfgStoreCallback(void *object, uint8_t id, uint16_t bitRate) {
|
|||
OD_CANBitRate = bitRate;
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Print usage */
|
||||
static void printUsage(char *progName) {
|
||||
|
|
@ -192,10 +201,13 @@ printf(
|
|||
" set to -1, then normal scheduler is used for RT thread.\n");
|
||||
#endif
|
||||
printf(
|
||||
" -r Enable reboot on CANopen NMT reset_node command. \n"
|
||||
" -r Enable reboot on CANopen NMT reset_node command. \n");
|
||||
#if CO_OD_STORAGE == 1
|
||||
printf(
|
||||
" -s <ODstorage file> Set Filename for OD storage ('od_storage' is default).\n"
|
||||
" -a <ODstorageAuto> Set Filename for automatic storage variables from\n"
|
||||
" Object dictionary. ('od_storage_auto' is default).\n");
|
||||
#endif
|
||||
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
|
||||
printf(
|
||||
" -c <interface> Enable command interface for master functionality.\n"
|
||||
|
|
@ -227,7 +239,9 @@ int main (int argc, char *argv[]) {
|
|||
#endif
|
||||
CO_NMT_reset_cmd_t reset = CO_RESET_NOT;
|
||||
CO_ReturnError_t err;
|
||||
#if CO_OD_STORAGE == 1
|
||||
CO_ReturnError_t odStorStatus_rom, odStorStatus_eeprom;
|
||||
#endif
|
||||
CO_CANptrSocketCan_t CANptr = {0};
|
||||
int opt;
|
||||
bool_t firstRun = true;
|
||||
|
|
@ -299,10 +313,12 @@ int main (int argc, char *argv[]) {
|
|||
socketTimeout_ms = strtoul(optarg, NULL, 0);
|
||||
break;
|
||||
#endif
|
||||
#if CO_OD_STORAGE == 1
|
||||
case 's': odStorFile_rom = optarg;
|
||||
break;
|
||||
case 'a': odStorFile_eeprom = optarg;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
printUsage(argv[0]);
|
||||
exit(EXIT_FAILURE);
|
||||
|
|
@ -320,8 +336,8 @@ int main (int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
if((CO_pendingNodeId < 1 || CO_pendingNodeId > 127)
|
||||
#if CO_NO_LSS_SLAVE == 1
|
||||
&& CO_pendingNodeId != CO_LSS_NODE_ID_ASSIGNMENT
|
||||
#if (CO_CONFIG_LSS) & CO_CONFIG_LSS_SLAVE
|
||||
&& CO_NO_LSS_SLAVE == 1 && CO_pendingNodeId != CO_LSS_NODE_ID_ASSIGNMENT
|
||||
#endif
|
||||
) {
|
||||
log_printf(LOG_CRIT, DBG_WRONG_NODE_ID, CO_pendingNodeId);
|
||||
|
|
@ -370,10 +386,11 @@ int main (int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
|
||||
#if CO_OD_STORAGE == 1
|
||||
/* initialize Object Dictionary storage */
|
||||
odStorStatus_rom = CO_OD_storage_init(&odStor, (uint8_t*) &CO_OD_ROM, sizeof(CO_OD_ROM), odStorFile_rom);
|
||||
odStorStatus_eeprom = CO_OD_storage_init(&odStorAuto, (uint8_t*) &CO_OD_EEPROM, sizeof(CO_OD_EEPROM), odStorFile_eeprom);
|
||||
|
||||
#endif
|
||||
|
||||
/* Catch signals SIGINT and SIGTERM */
|
||||
if(signal(SIGINT, sigHandler) == SIG_ERR) {
|
||||
|
|
@ -455,13 +472,16 @@ int main (int argc, char *argv[]) {
|
|||
#if (CO_CONFIG_GTW) & CO_CONFIG_GTW_ASCII
|
||||
CO_epoll_initCANopenGtw(&epGtw, CO);
|
||||
#endif
|
||||
#if CO_OD_STORAGE == 1
|
||||
CO_LSSslave_initCfgStoreCallback(CO->LSSslave, NULL,
|
||||
LSScfgStoreCallback);
|
||||
#endif
|
||||
if(!CO->nodeIdUnconfigured) {
|
||||
CO_EM_initCallbackRx(CO->em, EmergencyRxCallback);
|
||||
CO_NMT_initCallbackChanged(CO->NMT, NmtChangedCallback);
|
||||
CO_HBconsumer_initCallbackNmtChanged(CO->HBcons, NULL,
|
||||
HeartbeatNmtChangedCallback);
|
||||
#if CO_OD_STORAGE == 1
|
||||
/* initialize OD objects 1010 and 1011 and verify errors. */
|
||||
CO_OD_configure(CO->SDO[0], OD_H1010_STORE_PARAM_FUNC, CO_ODF_1010, (void*)&odStor, 0, 0U);
|
||||
CO_OD_configure(CO->SDO[0], OD_H1011_REST_PARAM_FUNC, CO_ODF_1011, (void*)&odStor, 0, 0U);
|
||||
|
|
@ -471,8 +491,9 @@ int main (int argc, char *argv[]) {
|
|||
if(odStorStatus_eeprom != CO_ERROR_NO) {
|
||||
CO_errorReport(CO->em, CO_EM_NON_VOLATILE_MEMORY, CO_EMC_HARDWARE, (uint32_t)odStorStatus_eeprom + 1000);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if CO_NO_TRACE > 0
|
||||
#if (CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE
|
||||
/* Initialize time */
|
||||
CO_time_init(&CO_time, CO->SDO[0], &OD_time.epochTimeBaseMs, &OD_time.epochTimeOffsetMs, 0x2130);
|
||||
#endif
|
||||
|
|
@ -538,8 +559,10 @@ int main (int argc, char *argv[]) {
|
|||
app_programAsync(!CO->nodeIdUnconfigured, epMain.timeDifference_us);
|
||||
#endif
|
||||
|
||||
#if CO_OD_STORAGE == 1
|
||||
CO_OD_storage_autoSave(&odStorAuto,
|
||||
epMain.timeDifference_us, 60000000);
|
||||
#endif
|
||||
}
|
||||
} /* while(reset != CO_RESET_APP */
|
||||
|
||||
|
|
@ -558,9 +581,11 @@ int main (int argc, char *argv[]) {
|
|||
app_programEnd();
|
||||
#endif
|
||||
|
||||
#if CO_OD_STORAGE == 1
|
||||
/* Store CO_OD_EEPROM */
|
||||
CO_OD_storage_autoSave(&odStorAuto, 0, 0);
|
||||
CO_OD_storage_autoSaveClose(&odStorAuto);
|
||||
#endif
|
||||
|
||||
/* delete objects from memory */
|
||||
#ifndef CO_SINGLE_THREAD
|
||||
|
|
@ -599,7 +624,7 @@ static void* rt_thread(void* arg) {
|
|||
CO_epoll_processRT(&epRT, CO, true);
|
||||
CO_epoll_processLast(&epRT);
|
||||
|
||||
#if CO_NO_TRACE > 0
|
||||
#if (CO_CONFIG_TRACE) & CO_CONFIG_TRACE_ENABLE
|
||||
/* Monitor variables with trace objects */
|
||||
CO_time_process(&CO_time);
|
||||
for(i=0; i<OD_traceEnable && i<CO_NO_TRACE; i++) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue