Skip to content

GCode interpreter now depends on emcStatus #4048

@BsAtHome

Description

@BsAtHome

The addition of #3995 has introduced a serious problem. The whole interpreter library is now dependent on emcStatus and by extension, libnml. This is obviously not a good thing.

The addition of the following line is the culprit:

   int machineUnits = (emcStatus->motion.traj.linearUnits > 0.5) ? CANON_UNITS_MM : CANON_UNITS_INCHES;

see: https://github.com/LinuxCNC/linuxcnc/blame/60597ee0718873d2449058c824262a275e5e4bad/src/emc/rs274ngc/interp_convert.cc#L6523

The real killer is that the value is not used in any sensible way at all. The machineUnits variable is used to scale the radius of a circle, but the variable radius is subsequently never used. It is only assigned a value (see lines 6529..6538). The arc_radius field value is written with a calculated value and that is the same call as originally in the assignment in line 6519.

@rodw-au: The question then arises: Why is this code in interp_convert.cc lines 6519..6538 necessary at all? It has no meaningful purpose because its calculations are never used. If scaling is required, then it must be done in the lower layer, but it seems odd that neither X, Y or Z is scaled in that same procedure and suggests that it is superfluous.

Error message when compiled with undefined sanitizing enabled:

Traceback (most recent call last):
  File ".../linuxcnc.git/bin/hal_manualtoolchange", line 87, in <module>
    import nf, rs274.options
  File ".../linuxcnc.git/lib/python/rs274/__init__.py", line 18, in <module>
    from .interpret import Translated, ArcsToSegmentsMixin
  File ".../linuxcnc.git/lib/python/rs274/interpret.py", line 17, in <module>
    import math, gcode
ImportError: .../linuxcnc.git/lib/librs274.so.0: undefined symbol: emcStatus
Found file(REL): ./cooling.hal
Traceback (most recent call last):
  File ".../linuxcnc.git-bsathome/bin/axis", line 61, in <module>
    import gcode
ImportError: .../linuxcnc.git/lib/librs274.so.0: undefined symbol: emcStatus

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions