Skip to content

Commit bcfa300

Browse files
authored
Merge pull request #3809 from BsAtHome/fix_heartbeat
Fix heartbeats from task and motion
2 parents 083b452 + 2001815 commit bcfa300

7 files changed

Lines changed: 20 additions & 8 deletions

File tree

src/emc/motion/motion.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ to another.
6060
#ifndef MOTION_H
6161
#define MOTION_H
6262

63+
#include <stdint.h>
64+
6365
#include "posemath.h" /* PmCartesian, PmPose, pmCartMag() */
6466
#include "emcpos.h" /* EmcPose */
6567
#include "cubic.h" /* CUBIC_STRUCT, CUBIC_COEFF */
@@ -623,7 +625,7 @@ Suggestion: Split this in to an Error and a Status flag register..
623625
/*! \todo FIXME - all structure members beyond this point are in limbo */
624626

625627
/* dynamic status-- changes every cycle */
626-
unsigned int heartbeat;
628+
uint64_t heartbeat; /* Incremented every time the motion controller is done. */
627629
int config_num; /* incremented whenever configuration
628630
changed. */
629631
int id; /* id for executing motion */

src/emc/motion/usrmotintf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ void usrmotPrintEmcmotStatus(emcmot_status_t *s, int which)
370370
);
371371
printf("cmd: \t%d\n", s->commandEcho);
372372
printf("cmd num: \t%d\n", s->commandNumEcho);
373-
printf("heartbeat: \t%u\n", s->heartbeat);
373+
printf("heartbeat: \t%lu\n", s->heartbeat);
374374
/*! \todo Another #if 0 */
375375
#if 0 /*! \todo FIXME - change to work with joint
376376
structures */

src/emc/nml_intf/emc.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ void EMC_AUX_STAT::update(CMS * cms)
881881
*/
882882
void EMC_TASK_STAT_MSG::update(CMS * cms)
883883
{
884-
cms->update(heartbeat);
884+
cms->update(taskbeat);
885885
}
886886

887887
/*
@@ -1847,6 +1847,7 @@ void EMC_MOTION_STAT::update(CMS * cms)
18471847
EmcPose_update(cms, &eoffset_pose);
18481848
cms->update(numExtraJoints);
18491849
cms->update(jogging_active);
1850+
cms->update(heartbeat);
18501851
}
18511852

18521853
/*

src/emc/nml_intf/emc_nml.hh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ class EMC_MOTION_STAT:public EMC_MOTION_STAT_MSG {
11571157
EmcPose eoffset_pose;
11581158
int numExtraJoints;
11591159
bool jogging_active;
1160+
uint64_t heartbeat; // motion controller's heartbeat counter
11601161
};
11611162

11621163
// declarations for EMC_TASK classes
@@ -1422,13 +1423,13 @@ class EMC_TASK_STAT_MSG:public RCS_STAT_MSG {
14221423
public:
14231424
EMC_TASK_STAT_MSG(NMLTYPE t, size_t s)
14241425
: RCS_STAT_MSG(t, s),
1425-
heartbeat(0)
1426+
taskbeat(0)
14261427
{};
14271428

14281429
// For internal NML/CMS use only.
14291430
void update(CMS * cms);
14301431

1431-
uint32_t heartbeat;
1432+
uint64_t taskbeat; // milltask's main loop heartbeat counter
14321433
};
14331434

14341435
class EMC_TASK_STAT:public EMC_TASK_STAT_MSG {

src/emc/task/emctask.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -734,6 +734,9 @@ int emcTaskUpdate(EMC_TASK_STAT * stat)
734734
//update state of block delete
735735
stat->block_delete_state = GET_BLOCK_DELETE();
736736

737+
extern uint64_t task_beat; // Main loop heartbeat in emctaskmain.cc
738+
stat->taskbeat = task_beat;
739+
737740
return 0;
738741
}
739742

src/emc/task/emctaskmain.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ static int emctask_shutdown(void);
138138
extern void backtrace(int signo);
139139
int _task = 1; // control preview behaviour when remapping
140140
static int joints = 0;
141+
uint64_t task_beat = 0; // Task's main loop heartbeat counter
141142

142143
// for operator display on iocontrol signalling a toolchanger fault if io.fault is set
143144
// %d receives io.reason
@@ -3379,6 +3380,8 @@ int main(int argc, char *argv[])
33793380
}
33803381
while (!done) {
33813382
static int gave_soft_limit_message = 0;
3383+
task_beat++; // Task's heartbeat
3384+
33823385
check_ini_hal_items(emcStatus->motion.traj.joints);
33833386
// read command
33843387
if (0 != emcCommandBuffer->read()) {
@@ -3585,11 +3588,11 @@ int main(int argc, char *argv[])
35853588
// end of while (! done)
35863589

35873590
rcs_print(
3588-
"task: %u cycles, min=%.6f, max=%.6f, avg=%.6f, %u latency excursions (> %dx expected cycle time of %.6fs)\n",
3589-
emcStatus->task.heartbeat,
3591+
"task: %lu cycles, min=%.6f, max=%.6f, avg=%.6f, %u latency excursions (> %dx expected cycle time of %.6fs)\n",
3592+
task_beat,
35903593
minTime,
35913594
maxTime,
3592-
(emcStatus->task.heartbeat != 0) ? (endTime - first_start_time) / emcStatus->task.heartbeat : -1.0,
3595+
task_beat ? (endTime - first_start_time) / task_beat : -1.0,
35933596
num_latency_warnings,
35943597
latency_excursion_factor,
35953598
emc_task_cycle_time

src/emc/task/taskintf.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,6 +2095,8 @@ int emcMotionUpdate(EMC_MOTION_STAT * stat)
20952095
stat->echo_serial_number = localMotionEchoSerialNumber;
20962096
stat->debug = emcmotConfig.debug;
20972097

2098+
stat->heartbeat = emcmotStatus.heartbeat; // Motion controller's heartbeat
2099+
20982100
for (dio = 0; dio < EMCMOT_MAX_DIO; dio++) {
20992101
stat->synch_di[dio] = emcmotStatus.synch_di[dio];
21002102
stat->synch_do[dio] = emcmotStatus.synch_do[dio];

0 commit comments

Comments
 (0)