Add CO_NMT_UNKNOWN state for Heartbeat consumer.
This commit is contained in:
parent
794c0f903a
commit
b8e821d0dd
4 changed files with 14 additions and 13 deletions
|
|
@ -119,7 +119,7 @@ CO_ReturnError_t CO_HBconsumer_init(
|
|||
HBcons->monitoredNodes = monitoredNodes;
|
||||
HBcons->numberOfMonitoredNodes = numberOfMonitoredNodes;
|
||||
HBcons->allMonitoredActive = false;
|
||||
HBcons->allMonitoredOperational = CO_NMT_INITIALIZING;
|
||||
HBcons->allMonitoredOperational = CO_NMT_UNKNOWN;
|
||||
HBcons->NMTisPreOrOperationalPrev = false;
|
||||
HBcons->CANdevRx = CANdevRx;
|
||||
HBcons->CANdevRxIdxStart = CANdevRxIdxStart;
|
||||
|
|
@ -182,9 +182,9 @@ CO_ReturnError_t CO_HBconsumer_initEntry(
|
|||
CO_HBconsNode_t * monitoredNode = &HBcons->monitoredNodes[idx];
|
||||
monitoredNode->nodeId = nodeId;
|
||||
monitoredNode->time_us = (int32_t)consumerTime_ms * 1000;
|
||||
monitoredNode->NMTstate = CO_NMT_INITIALIZING;
|
||||
monitoredNode->NMTstate = CO_NMT_UNKNOWN;
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
monitoredNode->NMTstatePrev = CO_NMT_INITIALIZING;
|
||||
monitoredNode->NMTstatePrev = CO_NMT_UNKNOWN;
|
||||
#endif
|
||||
CO_FLAG_CLEAR(monitoredNode->CANrxNew);
|
||||
|
||||
|
|
@ -382,7 +382,7 @@ void CO_HBconsumer_process(
|
|||
#endif
|
||||
CO_errorReport(HBcons->em, CO_EM_HEARTBEAT_CONSUMER,
|
||||
CO_EMC_HEARTBEAT, i);
|
||||
monitoredNode->NMTstate = CO_NMT_INITIALIZING;
|
||||
monitoredNode->NMTstate = CO_NMT_UNKNOWN;
|
||||
monitoredNode->HBstate = CO_HBconsumer_TIMEOUT;
|
||||
}
|
||||
|
||||
|
|
@ -400,7 +400,7 @@ void CO_HBconsumer_process(
|
|||
allMonitoredActiveCurrent = false;
|
||||
}
|
||||
if (monitoredNode->NMTstate != CO_NMT_OPERATIONAL) {
|
||||
allMonitoredOperationalCurrent = CO_NMT_INITIALIZING;
|
||||
allMonitoredOperationalCurrent = CO_NMT_UNKNOWN;
|
||||
}
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
/* Verify, if NMT state of monitored node changed */
|
||||
|
|
@ -419,9 +419,9 @@ void CO_HBconsumer_process(
|
|||
else if (NMTisPreOrOperational || HBcons->NMTisPreOrOperationalPrev) {
|
||||
/* (pre)operational state changed, clear variables */
|
||||
for(i=0; i<HBcons->numberOfMonitoredNodes; i++) {
|
||||
monitoredNode->NMTstate = CO_NMT_INITIALIZING;
|
||||
monitoredNode->NMTstate = CO_NMT_UNKNOWN;
|
||||
#if CO_CONFIG_HB_CONS & CO_CONFIG_HB_CONS_CHANGE_CALLBACK
|
||||
monitoredNode->NMTstatePrev = CO_NMT_INITIALIZING;
|
||||
monitoredNode->NMTstatePrev = CO_NMT_UNKNOWN;
|
||||
#endif
|
||||
CO_FLAG_CLEAR(monitoredNode->CANrxNew);
|
||||
if (monitoredNode->HBstate != CO_HBconsumer_UNCONFIGURED) {
|
||||
|
|
@ -430,7 +430,7 @@ void CO_HBconsumer_process(
|
|||
monitoredNode++;
|
||||
}
|
||||
allMonitoredActiveCurrent = false;
|
||||
allMonitoredOperationalCurrent = CO_NMT_INITIALIZING;
|
||||
allMonitoredOperationalCurrent = CO_NMT_UNKNOWN;
|
||||
}
|
||||
|
||||
/* Clear emergencies when all monitored nodes becomes active.
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ extern "C" {
|
|||
* Internal network state of the CANopen node
|
||||
*/
|
||||
typedef enum{
|
||||
CO_NMT_UNKNOWN = -1, /**< Device state is unknown (for heartbeat consumer) */
|
||||
CO_NMT_INITIALIZING = 0, /**< Device is initializing */
|
||||
CO_NMT_PRE_OPERATIONAL = 127, /**< Device is in pre-operational state */
|
||||
CO_NMT_OPERATIONAL = 5, /**< Device is in operational state */
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ extern "C" {
|
|||
#define DBG_NO_CAN_DEVICE "(%s) Can't find CAN device \"%s\"", __func__
|
||||
#define DBG_OBJECT_DICTIONARY "(%s) Error in Object Dictionary \"%s\"", __func__
|
||||
#define DBG_CAN_OPEN "(%s) CANopen error in %s, err=%d", __func__
|
||||
#define DBG_CAN_OPEN_INFO "(%s) CANopen device, Node ID = %d(0x%02X), %s", __func__
|
||||
#define DBG_CAN_OPEN_INFO "(%s) CANopen device, Node ID = 0x%02X, %s", __func__
|
||||
#define DBG_COMMAND_LOCAL_INFO "(%s) Command interface on socket \"%s\" started", __func__
|
||||
#define DBG_COMMAND_TCP_INFO "(%s) Command interface on tcp port \"%hu\" started", __func__
|
||||
|
||||
|
|
|
|||
|
|
@ -263,7 +263,7 @@ int main (int argc, char *argv[]) {
|
|||
}
|
||||
|
||||
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, CO_ownNodeId, "starting");
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, "starting");
|
||||
|
||||
|
||||
/* Allocate memory for CANopen objects */
|
||||
|
|
@ -308,7 +308,7 @@ int main (int argc, char *argv[]) {
|
|||
while(reset != CO_RESET_APP && reset != CO_RESET_QUIT && CO_endProgram == 0) {
|
||||
/* CANopen communication reset - initialize CANopen objects *******************/
|
||||
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, CO_ownNodeId, "communication reset");
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, "communication reset");
|
||||
|
||||
|
||||
#if CO_CONFIG_309 > 0
|
||||
|
|
@ -439,7 +439,7 @@ int main (int argc, char *argv[]) {
|
|||
|
||||
reset = CO_RESET_NOT;
|
||||
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, CO_ownNodeId, "running ...");
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, "running ...");
|
||||
|
||||
|
||||
while(reset == CO_RESET_NOT && CO_endProgram == 0) {
|
||||
|
|
@ -493,7 +493,7 @@ int main (int argc, char *argv[]) {
|
|||
threadMainWait_close();
|
||||
CO_delete((void *)CANdevice0Index);
|
||||
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, CO_ownNodeId, "finished");
|
||||
log_printf(LOG_INFO, DBG_CAN_OPEN_INFO, CO_ownNodeId, "finished");
|
||||
|
||||
/* Flush all buffers (and reboot) */
|
||||
if(rebootEnable && reset == CO_RESET_APP) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue