Skip to content

Boolean INI values are parsed inconsistently #3863

@Sigma1912

Description

@Sigma1912

The values for boolean INI variables are not handled consistently in LinuxCNC.

As per documentation
https://linuxcnc.org/docs/devel/html/config/ini-config.html#sub:ini:variables

Boolean values can be on one of TRUE, YES or 1 for true/enabled and one of FALSE, NO or 0 for false/disabled. The case is ignored.

There are some references in the docs indicating that the above does not apply to all boolean variables.
Examples:

LATHE = 1 - Any non-empty value (including "0") causes axis to use "lathe mode" with a top view and with Radius and Diameter on the DRO.

BACK_TOOL_LATHE = 1 - Any non-empty value (including "0") causes axis to use "back tool lathe mode" with inverted X axis.

FOAM = 1 - Any non-empty value (including "0") causes axis to change the display for foam-cutter mode.

Note though that some parts of the code follow none of the above:

temp = inifile.find("DISPLAY", "LATHE")
self.lathe_option = bool(temp == "1" or temp == "True" or temp == "true" )
self.foam_option = bool(inifile.find("DISPLAY", "FOAM"))

Using ''WRAPPED_ROTARY' with AxisGUI serves as an example of what kind of issues this can lead to:

  1. '#'WRAPPED_ROTARY = 1' (or simply no entry)
    -> Interpreter: not wrapped_rotary
    -> AxisGUI : not wrapped_rotary
    MDI: 'G0 A400' -> A-axis moves to '400'

  2. 'WRAPPED_ROTARY = 1'
    -> Interpreter: wrapped_rotary
    -> AxisGUI : wrapped_rotary
    MDI: 'G0 A400' -> We get the expected interpreter error and no movement

  3. 'WRAPPED_ROTARY = 0' (actually anything other than '1')
    -> Interpreter: not wrapped_rotary
    -> AxisGUI : wrapped_rotary
    MDI command : 'G0 A400' -> We get no error and movement to A: 40

Testing done using 'configs/sim/axis/axis_9axis.ini' in current 2.9 and master

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions