Repository navigation
Nml cleanup - #4627
Nml cleanup#4627
Conversation
grandixximo
left a comment
There was a problem hiding this comment.
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.
| 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); " |
There was a problem hiding this comment.
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 {})?
| set_rcs_print_flag((long)*dbg); | ||
| } | ||
| // output infinite RCS errors by default | ||
| max_rcs_errors_to_print = -1; |
There was a problem hiding this comment.
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.
| // 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); |
There was a problem hiding this comment.
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?
|
|
||
| #include "config.h" | ||
| #include "libnml/rcs/rcs.hh" // NML classes, nmlErrorFormat() | ||
| #include "rcs_status.hh" // NML classes, nmlErrorFormat() |
There was a problem hiding this comment.
Does this comment still fit? // NML classes, nmlErrorFormat() described the old rcs.hh include; rcs_status.hh only provides the RCS_STATUS enum, no?
| #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. |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
With this gone, is the forward declaration of RCS_PRINT_DESTINATION_TYPE at the top of the file still needed?
|
I doubt anyone uses RCS_DEBUG_DEST or RCS_PRINT_DESTINATION_TYPE. google only has 2 results on this string. |
|
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. |
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
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 |
I agree. We should instead introduce a proper channelized logging facility where we can use runtime config to enable/disable classes and individual messages. |
|
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>
|
This should have been discussed more thoroughly before being merged. The logging question has not been answered adequately IMO. |
|
logging is now in its own file, and can be dealt with in a single place, and debug flags have been restored. |
|
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. |
|
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. |
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: 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. |
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... |
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.