diff --git a/src/emc/task/emctaskmain.cc b/src/emc/task/emctaskmain.cc --- a/src/emc/task/emctaskmain.cc +++ b/src/emc/task/emctaskmain.cc @@ -3490,4 +3490,9 @@ int main(int argc, char *argv[]) // since emcStatus was passed to the WM init functions, it // will be updated in the _update() functions above. There's // no need to call the individual functions on all WM items. + // EMC_TASK_STAT_MSG::heartbeat is the native task-cycle oracle used by + // external clients. Keep it monotonic and publish it with this cycle's + // status image so a reader can identify every task tick without relying on + // wall-clock sampling. + emcStatus->task.heartbeat++; emcStatusBuffer->write(emcStatus); diff --git a/src/emc/usr_intf/axis/extensions/emcmodule.cc b/src/emc/usr_intf/axis/extensions/emcmodule.cc --- a/src/emc/usr_intf/axis/extensions/emcmodule.cc +++ b/src/emc/usr_intf/axis/extensions/emcmodule.cc @@ -409,4 +409,7 @@ static PyMemberDef Stat_members[] = { {(char*)"echo_serial_number", T_INT, O(echo_serial_number), READONLY}, {(char*)"echo_serial_number", T_INT, O(echo_serial_number), READONLY}, {(char*)"state", T_INT, O(status), READONLY}, + {(char*)"task_heartbeat", T_UINT, O(task.heartbeat), READONLY, + "Native EMC task-loop heartbeat. This counter is incremented by the " + "LinuxCNC task thread and is suitable for identifying native status ticks."}, // task