Skip to content

Major overhaul/rewrite of linuxcncrsh#3815

Open
BsAtHome wants to merge 1 commit intoLinuxCNC:masterfrom
BsAtHome:fix_linuxcncrsh
Open

Major overhaul/rewrite of linuxcncrsh#3815
BsAtHome wants to merge 1 commit intoLinuxCNC:masterfrom
BsAtHome:fix_linuxcncrsh

Conversation

@BsAtHome
Copy link
Contributor

This PR addresses the many deficiencies and races in linuxcncrsh. Some of them have been discussed in #3734 and additional fixes have been added in previous PRs (#3809, #3803, #3800, #3791).

The entire linuxcncrsh program is now single-threaded and uses a poll loop to handle input/output. Multiple clients may be connected at the same time and all can be in the ENABLED state and issue SET commands. The limitation is that only one command can be in transit via NML for all clients (i.e. only one SET command can be processed at any given time). There are three exceptions; any enabled client can issue 'SET ABORT', 'SET MACHINE OFF' and 'SET ESTOP ON'. Any client can always issue GET commands.

Fixes and additions:

  • C-style string handling has been replaced with std::string and C-style arrays now use std::vector (that should fix the buffer overflows ;-) ).
  • Many commands have been streamlined in what they allow as arguments so that similar commands use similar arguments (like -1 for 'all' and defaults)
  • Output of commands has been streamlined to use identical format for same type of information
  • Axis and joint indicators are now checked whether they actually are available and result in an error if they are not
  • Error checking is consistently done on arguments and messages returned when something is amiss
  • Heartbeat from the servo-thread (motion controller) is used to prevent RT <--> non-RT races
  • GET INI - now works and you can read any INI file entry
  • GET INIFILE - works and returns path of INI file
  • GET PROBE now issues an MDI G38.2 because it [cw]ould not work otherwise.
  • GET CLIENTS returns who is connected
  • SET DISABLE lets you downgrade own connection from being enabled and also allows other clients to be downgraded
  • SET JOINT_HOME (alias: SET HOME) now works in conjunction with SET JOINT_WAIT_HOMED to wait for completion
  • SET JOINT_UNHOME lets you unhome any joint
  • SET TIMESTAMP lets you enable date+time stamped responses
  • Files read/loaded are now using a functional path (as set by the -d command-line option). The default is $HOME/nc_files. You can pass your own ':' separated list to the -d option

Several GET/SET commands were removed or deprecated:

  • COMM_MODE - removed - the communication is always ASCII.
  • CONFIG - removed - was never implemented
  • SET_WAIT - removed - was already deprecated (replaced by WAIT_MODE)
  • COMM_PROT - deprecated - API versioning is overrated and is non-functional anyway
  • UPDATE - deprecated - emcStatus updates are better left to be automatic
  • UPDATE_STATUS - deprecated - emcStatus updates are better left to be automatic

The man-page has been updated to reflect all changes, removals and additions.

There are probably some more details that I forgot to mention here... Well, c'est la vie.

The diff of the source may be inadequate to look at because essentially every line got changed (and that is not because of whitespace changes). See the entire file: https://github.com/BsAtHome/linuxcnc/blob/fix_linuxcncrsh/src/emc/usr_intf/emcrsh.cc for review.

The new version also uses fmt::format() to do string formatting, as discussed in #3814, because gcc-12 in Debian 12 (bookworm) does not support std::format (need gcc-14 or newer for that). A configure test and package dependency is added.

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.

1 participant

Comments