Skip to content

Nml cleanup - #4627

Merged
rene-dev merged 10 commits into
LinuxCNC:masterfrom
rene-dev:nml-cleanup2
Oct 6, 2026
Merged

rene-dev merged 10 commits into
LinuxCNC:masterfrom
rene-dev:nml-cleanup2

Conversation

@rene-dev

@rene-dev rene-dev commented Oct 4, 2026

Copy link
Copy Markdown
Member

this is the first step of removing NML: getting rid of dependencies, where it really isn't needed.
This should not affect any user facing things, so it can go straight in.

@grandixximo grandixximo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good to me. The dependency reductions build cleanly across the CI matrix, the new libnml defaults (STDOUT, PRINT_RCS_ERRORS) match the removed setup, and I checked the etime() wall-to-monotonic switch against every call site: only linuxcncrsh TIME and the Tcl emc_time report a wall timestamp to a client, and both correctly use wall_etime(); everything else measures local intervals. The emcOperatorErrorNoEcho() replacement for the RCS_PRINT_TO_NULL dance in emcMotionUpdate() is a nice cleanup.

One spot outside this diff: linuxcnc_check_ini.py still validates [EMC]RCS_DEBUG_DEST (line 178 and lines 212-214). Since nothing reads that variable anymore, should the check be dropped so the validator does not keep blessing a setting that does nothing?

Inline are mostly questions. The only real bug I found is the %g in initraj.cc.

Comment thread src/emc/ini/initraj.cc Outdated
if (planner_type == 1 && jerk < 1.0) {
rcs_print_error("[TRAJ]PLANNER_TYPE = 1 (S-curve) requires "
fmt::print(stderr, "[TRAJ]PLANNER_TYPE = 1 (S-curve) requires "
"[TRAJ]MAX_LINEAR_JERK >= 1.0 (got %g); "

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This format string kept its printf %g, but the call is now fmt::print, where % is not a specifier. Won't this print the literal text (got %g) and silently drop the jerk argument? Should it be (got {})?

Comment thread src/emc/usr_intf/shcom.cc
set_rcs_print_flag((long)*dbg);
}
// output infinite RCS errors by default
max_rcs_errors_to_print = -1;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropping this leaves libnml's built-in default of 30 in every client process (same in the emcsvr, milltask and halui copies of this block). So after 30 RCS errors, further errors stop being reported, where before the default was unbounded. Is that cap deliberate? If yes, could the commit message say so? It is a user visible change, while the PR description says there are none.

Comment thread src/emc/usr_intf/shcom.cc
// enable all debug messages by default if RCS or NML debugging is enabled
if ((emc_debug & EMC_DEBUG_RCS) || (emc_debug & EMC_DEBUG_NML)) {
// output all RCS debug messages
set_rcs_print_flag(PRINT_EVERYTHING);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this hook (and -rcsdebug in emcGetArgs) gone, is there any way left to switch on libnml's rcs_print_debug() output? EMC_DEBUG_RCS and EMC_DEBUG_NML are still documented in debugflags.h but no longer reach PRINT_EVERYTHING anywhere. If NML debugging is intentionally retired, should those debugflags.h entries go with it?

Comment thread src/emc/task/emctaskmain.cc Outdated

#include "config.h"
#include "libnml/rcs/rcs.hh" // NML classes, nmlErrorFormat()
#include "rcs_status.hh" // NML classes, nmlErrorFormat()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this comment still fit? // NML classes, nmlErrorFormat() described the old rcs.hh include; rcs_status.hh only provides the RCS_STATUS enum, no?

Comment thread src/emc/task/taskclass.cc Outdated
#include "libnml/rcs/rcs.hh" // RCS_CMD_CHANNEL, etc.
#include "libnml/rcs/rcs_print.hh"
#include "libnml/os_intf/timer.hh" // esleep, etc.
#include "rcs_status.hh" // RCS_CMD_CHANNEL, etc.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here: // RCS_CMD_CHANNEL, etc. described rcs.hh. What does a reader learn from it on rcs_status.hh?

enum ANGULAR_UNIT_CONVERSION : int;

std::optional<RCS_PRINT_DESTINATION_TYPE> mapRcsDestination(const linuxcnc::IniFile &ini,
const std::string &var, const std::string &sec);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this gone, is the forward declaration of RCS_PRINT_DESTINATION_TYPE at the top of the file still needed?

@rene-dev

rene-dev commented Oct 4, 2026

Copy link
Copy Markdown
Member Author

I doubt anyone uses RCS_DEBUG_DEST or RCS_PRINT_DESTINATION_TYPE. google only has 2 results on this string.

@rmu75

rmu75 commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

I somewhat don't like replacing rcs_print_... directly with fmt::print because it looses "debug-level" information. At some point we might introduce a standard logging facility like spdlog and then it would be nice to have that information still available.

@grandixximo

Copy link
Copy Markdown
Contributor

I doubt anyone uses RCS_DEBUG_DEST or RCS_PRINT_DESTINATION_TYPE. google only has 2 results on this string.

The Google count does not settle it either way; ini files live on private machines, so usage barely shows up in a web index. But if usage really is that close to zero, isn't that all the more reason to finish the removal: drop the dead validation in linuxcnc_check_ini.py (lines 178 and 212-214) and the forward declaration in mapini.hh? Independently of that, the one thing that does need fixing is the %g in initraj.cc.

I somewhat don't like replacing rcs_print_... directly with fmt::print because it looses "debug-level" information. At some point we might introduce a standard logging facility like spdlog and then it would be nice to have that information still available.

I agree the severity is worth keeping, and there is a cheap way to keep it with fmt: route the prints through small named wrappers instead of calling fmt::print directly, for example a header-only shim in the style of this PR's strutil.hh/timeutil.hh:

template <typename... T>
void log_error(fmt::format_string<T...> f, T&&... args) {
    fmt::vprint(stderr, f, fmt::make_format_args(args...));
}

template <typename... T>
void log_info(fmt::format_string<T...> f, T&&... args) {
    fmt::vprint(f, fmt::make_format_args(args...));
}

Call sites then read log_error(...) / log_info(...), so severity stays explicit at every call site, and if spdlog ever arrives only these two functions change. A debug-gated variant (log_debug(EMC_DEBUG_..., ...)) would also answer my inline question about EMC_DEBUG_RCS/EMC_DEBUG_NML becoming unreachable, since the gate would live in one place again.

@BsAtHome

BsAtHome commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

I somewhat don't like replacing rcs_print_...

I agree. We should instead introduce a proper channelized logging facility where we can use runtime config to enable/disable classes and individual messages.

@rmu75

rmu75 commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

I agree. We should instead introduce a proper channelized logging facility where we can use runtime config to enable/disable classes and individual messages.

#4638

rene-dev and others added 2 commits October 6, 2026 13:40
Nothing in LinuxCNC reaches any of these; linking every libnml user
with --gc-sections discards all of it.

- cms/cmssvrp.cc, os_intf/inetnull.cc, os_intf/inetfile.hh: never
  built.
- os_intf/timer.cc: RCS_TIMER, replaced by linuxcnc::CyclicTimer.
  timer.hh keeps the etime()/esleep() declarations libnml still uses.
- cms/cms_pm.cc: CMS::update() for the POSEMATH types. The only one
  any message uses is PM_CARTESIAN (EMC_TRAJ_CIRCULAR_MOVE), which
  moves to cms.cc.
- nml/nmldiag.cc, nml/nmldiag.hh: NML_DIAGNOSTICS_INFO::print() and
  nml_print_diag_list(), reachable only through the equally unused
  NML::get_diagnostics_info(), which goes too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Nothing in the tree sends any of these:

- EMC_TOOL_HALT had no handler either.
- EMC_TOOL_UNLOAD, EMC_TRAJ_ABORT, EMC_TRAJ_PAUSE and EMC_TRAJ_RESUME
  were handled by task, but no GUI, halui, linuxcncrsh or the Python
  and Tcl bindings ever sends them. GUIs pause and resume through
  EMC_TASK_PLAN_PAUSE/RESUME and abort through EMC_TASK_ABORT.

emcTrajPause(), emcTrajResume() and emcTrajAbort() stay, task calls
them itself. emcToolUnload() was only reachable through
EMC_TOOL_UNLOAD and goes with it.

An external program speaking NML directly that sends one of these will
now get "ignoring issue of unknown command".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rene-dev
rene-dev merged commit 7f67ef2 into LinuxCNC:master Oct 6, 2026
17 checks passed
@BsAtHome

BsAtHome commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

This should have been discussed more thoroughly before being merged.

The logging question has not been answered adequately IMO.

@rene-dev

rene-dev commented Oct 6, 2026 •

Copy link
Copy Markdown
Member Author

logging is now in its own file, and can be dealt with in a single place, and debug flags have been restored.
only thing lost is the redirection, which I doubt was ever used for anything.
https://github.com/LinuxCNC/linuxcnc/blob/master/src/emc/logutil.hh

@BsAtHome

BsAtHome commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

That isn't the issue. You merged it without consensus about the direction it needs to go. There were open questions here about logging. There are multiple things in logging that need to be fixed. You changed it single handed into this version and just merged it. That is the real problem, technical issues aside.

@rene-dev

rene-dev commented Oct 6, 2026

Copy link
Copy Markdown
Member Author

which question is still open? I addressed the things that were mentioned. I asked on emc-users who used redirection, and why. google results in nothing. forum results in nothing.
there is also a discussion on which lib to use, and how. #4638
for sure we dont want to use rcs for logging.

@snowgoer540

Copy link
Copy Markdown
Contributor

That isn't the issue. You merged it without consensus about the direction it needs to go. There were open questions here about logging. There are multiple things in logging that need to be fixed. You changed it single handed into this version and just merged it. That is the real problem, technical issues aside.

This has been my experience with @rene-dev throughout my involvement in the project. Rene tends to make big changes, with seemingly little discussion, usually dropped out of nowhere, and then move on and let everyone else fix the associated issues.

Also, there seems to be a bunch of AI written code getting merged into the project, but this is the first time I've seen "and Claude" in our commit history. Is the project OK with this? This project is not perfect, but it's been slop free until recently. Are we sure that all of these commits are getting reviewed properly, by actual human beings, or are we just accepting the AI generated stuff as "good enough"? The rate of change here has been staggering lately. It certainly has me nervous.

One of these commits has caused this warning to show in my terminal:

* * * * * * * * * * - - - - - WARNING - - - - - * * * * * * * * * *
*    CMS_DISPLAY_ASCII_UPDATER may not function properly due      *
*    to range limitations of some of the update() functions.      *
* * * * * * * * * * - - - - - WARNING - - - - - * * * * * * * * * *

I can bisect if we really need to know the specific commit, but I did check out the last commit before @rene-dev merged this, and the warning is not there.

@rmu75

rmu75 commented Oct 7, 2026

Copy link
Copy Markdown
Collaborator

Also, there seems to be a bunch of AI written code getting merged into the project, but this is the first time I've seen "and Claude" in our commit history. Is the project OK with this? This project is not perfect, but it's been slop free until recently. Are we sure that all of these commits are getting reviewed properly, by actual human beings, or are we just accepting the AI generated stuff as "good enough"? The rate of change here has been staggering lately. It certainly has me nervous.

There is a whole bunch of AI generated / assisted stuff going on in linuxcnc recently. Consensus seems to be that everything has to be human reviewed and as far as I have looked the AI stuff indeed looks correct. It's like a very powerful reactoring tool.

The warning you see was introduced while bugfixing around NML/CMS and has nothing to do with AI. It just says that 64bit values can't be properly "serialized" by the CMS DISPLAY_ASCII transport, and that is not fixable without breaking the output format. I wonder how you triggered that warning...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants