Skip to content

New ini-file parser breaks hm2_eth config on master #3946

Closed

Description

@hdiethelm

The reason is probably this PR:
#3921

It took me some time and bisecting to figure out the reason. With added some debug printf's:
Before:
rtapi_app load hm2_eth board_ip=192.168.1.121 config="num_encoders=0 num_pwmgens=1 num_stepgens=4"
After:
rtapi_app load hm2_eth board_ip=192.168.1.121 config=num_encoders=0 num_pwmgens=1 num_stepgens=4
Note the missing "

The error message is quite usless:

hm2: loading Mesa HostMot2 driver version 0.15
./hm2-stepper-eth.hal:38: waitpid failed /home/hannes/linuxcnc-src/bin/rtapi_app hm2_eth
./hm2-stepper-eth.hal:38: /home/hannes/linuxcnc-src/bin/rtapi_app exited without becoming ready
./hm2-stepper-eth.hal:38: insmod for hm2_eth failed, returned -1

Relevant section of the ini file:

[HOSTMOT2]
DRIVER=hm2_eth
BOARD_IP=192.168.1.121
BOARD=7i96s
CONFIG="num_encoders=0 num_pwmgens=1 num_stepgens=4"

And the hal file:

# load low-level driver
loadrt [HOSTMOT2](DRIVER) board_ip=[HOSTMOT2](BOARD_IP) config=[HOSTMOT2](CONFIG)

@BsAtHome I can work around it by just placing the config directly in the hal file for now.

Activity

  1. BsAtHome commented on Apr 18, 2026

    @BsAtHome
    Contributor

    The "breaks..." is more like "I probably intentionally broke..." ;-)

    The problem is that double quotes no longer are a literal part of a value but are now interpreted. This is, of course, unfortunate for existing configs. But is does add consistency for the future.

    The simple fix is enclose the double quoted string in single quotes in the INI-file entry to:

    [HOSTMOT2]
    ...
    CONFIG='"num_encoders=0 num_pwmgens=1 num_stepgens=4"'
    ...

    Alternative is to escape the double quotes in a double quoted string:

    [HOSTMOT2]
    ...
    CONFIG="\"num_encoders=0 num_pwmgens=1 num_stepgens=4\""
    ...

    However, I'd prefer using a single quoted string with embedded double quotes.

  2. hdiethelm commented on Apr 18, 2026

    @hdiethelm
    ContributorAuthor

    Thanks for the info. So more like a breaking change needing users to update their config together with hm2_eth not generating useful error messages.

    There are a lot of examples and might be also doc that need updating in this case. Just one example that is broken now: configs/by_interface/mesa/hm2-stepper/4i68.ini

    It would make sense to add some checks and give a proper error in hm2_eth, it took me some time to resolve it and others will have the same issue for sure.

  3. BsAtHome commented on Apr 18, 2026

    @BsAtHome
    Contributor

    Already going through all configs' ini-files.

    It was unknown to be breaking this particular use... However, there was anticipated some fallout.

  4. hdiethelm commented on Apr 18, 2026

    @hdiethelm
    ContributorAuthor

    Ok, all fine.

    This parameter parsing also happens in uspace_rtapi_app.cc. It looks like the warning about unknown parameters is broken on master. On 2.9, I have a warning when I add a parameter that is not used.

    I can look into that but only after #3919 got merged.

  5. BsAtHome commented on Apr 18, 2026

    @BsAtHome
    Contributor

    Fix in #3947 for in-tree configs.

  6. hdiethelm commented on Apr 18, 2026

    @hdiethelm
    ContributorAuthor

    That was fast! Meanwhile, I traced the missing error message. There is one, it is just not shown in master: #3948

  7. andypugh commented on Apr 19, 2026

    @andypugh
    Collaborator

    You seem to have taken the position that the existing configs are wrong. I don't think that is necessarily reasonable.
    I would guess that the majority of configs use a Mesa card, and you have broken all of them.
    (This problem won't be limited to hm2_eth, all the Mesa cards take configuration strings.)

    The quotes are needed so that the handlers get a list of config parameters without them being broken up by the Linux parameter parser.

    Considering our user base, I don't like expecting them all to start using nested or escaped quotes, the parser should pass-through quoted string including quotes.

  8. BsAtHome commented on Apr 19, 2026

    @BsAtHome
    Contributor

    You cannot both pass quotes in values and interpret content. Neither can you do string collection if you do not interpret quotes.

    And, yes, the idea that bare quotes in values are allowed is wrong IMO. The compromise is that strings with quotes, when not the first character, are left as is. But you cannot detect the difference between a quoted string and a literal string in quotes.

    There may be an alternative in the mesa config string in that the target expansion in the HAL file can be quoted. That may very well be the better solution than quoting the quotes.

    But is you want to interpret values in ini-files as bare text, then you also have to re-instate comment characters as a part of the value (and cannot have a comment on a value line).

  9. hdiethelm commented on Apr 19, 2026

    @hdiethelm
    ContributorAuthor

    One thing to consider:
    CONFIG='"num_encoders=0 num_pwmgens=1 num_stepgens=4"'
    doesn't work in 2.9. So you need different ini files for 2.9 and master from now on.

    On one side, this is what master is for, break things to make the whole system better. On the other side, breaking changes are often hard on the users, even if properly documented.

  10. andypugh commented on Apr 19, 2026

    @andypugh
    Collaborator

    The INI file documentation specifically permits quoted strings.
    I feel that any updated INI file parser should work at least as well as the old parser.

    https://linuxcnc.org/docs/master/html/config/ini-config.html#sub:ini:variables

  11. BsAtHome commented on Apr 19, 2026

    @BsAtHome
    Contributor

    Don't worry, #3947 has been changed so that quotes are no longer treated as special but just part of the string.

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

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