Repository navigation
interp: get the kinematics and HAL values from the canon - #4899
grandixximo wants to merge 3 commits into
Conversation
The interpreter loaded the machine's kinematics module itself, on a HAL component of its own, and #<_hal[name]> read HAL directly, so librs274 linked liblinuxcnchal and libkinslimits and the interpreter owned a HAL component's lifetime. The canon now answers both. GET_EXTERNAL_KINEMATICS() loads a module for each caller on the canon's HAL component and hands it out with a table of the calls on it, KinematicsUserOps; the interpreter keeps both in its setup and frees the module through the table at exit, before the new EXIT_CANON() lets the component go. GET_EXTERNAL_HAL_VALUE() reads a pin, signal or param through a new hal_get_number(). Task and the preview module answer both; sai has no machine and no HAL. librs274 no longer links liblinuxcnchal or libkinslimits.
The stub lacked 17 canon calls added since the test was disabled, plus the two GET_EXTERNAL_ calls added here. Built against the internal headers it links -lrs274 alone, runs under LD_BIND_NOW and prints what expected holds. It stays skipped until the interpreter headers are exported to include/.
BsAtHome
left a comment
There was a problem hiding this comment.
I think you missed emc/canterp/canterp.cc
| // | ||
| // hal_get_number() - Read a pin, signal or param by name, in that order, as a | ||
| // number, the way the interpreter's #<_hal[name]> does | ||
| // | ||
| // Returns 0 with *value set, -ENOENT when nothing has that name, -EFAULT when | ||
| // HAL is not mapped and -EINVAL for a port. | ||
| // | ||
| int hal_get_number(const char *name, double *value) |
There was a problem hiding this comment.
This does not belong in here. This is a specific case for the interpreter that always wants a floating point answer.
There was a problem hiding this comment.
Agreed, it is out of HAL. Task and the preview module now read the pin, signal or param themselves with hal_get_p() and hal_get_s().
There was a problem hiding this comment.
I think there should be a function that does exactly this. My hal.hh had this, the python interface needs it as well.
There was a problem hiding this comment.
Bertho's point was that hal_lib_query.c is the wrong home for a lookup that always answers a double, which is only what the interpreter wants. hal::get_value() in hal.hh (#4251) is the general one, returning the value in its HAL type, so once that lands both canons call it and convert, and the two copies here go away. Until then I kept the lookup in the canons so this PR does not wait on #4251. Does that work for you?
There was a problem hiding this comment.
Hal_lib contains primitives and abstractions. There are very few specific exceptions in the halcmd/HAL interaction (loadrt), but otherwise we should keep cascading searches and conversions to the upper levels.
hal_get_number() put an interpreter-specific lookup in the HAL query API. Task and the preview module now read the pin, signal or param themselves with hal_get_p() and hal_get_s(). canterp replays EXIT_CANON as it does INIT_CANON.
|
canterp now replays On the headers for |
|
the INIT_CANON and EXIT_CANON should go into constructor/destructor after the canon interface refactor... |
|
can you explain what the kinematics change is about? there is more happening here than the heading suggests. |
|
Agreed. Until then |
A separate PR should be better to keep together what belongs together. I will have a look at these headers and make a PR. |
Kinematics change are about having the interpreter unbound from HAL, the gcode that need kinematics awareness get it from canon, does that answer the question? |
Bertho pointed out on #4891 that the interpreter ties librs274 to HAL: it loaded the machine's kinematics module itself, on a HAL component of its own, and
#<_hal[name]>read HAL directly. Rene suggested on #4852 keeping_hal[]and moving only the HAL access behind a canon call.The canon now answers both:
GET_EXTERNAL_KINEMATICS()loads a module for each caller and hands it out with a table of the calls on it,KinematicsUserOps. The interpreter keeps both in its setup and frees the module at exit, so each interpreter instance has its own and none shares a kinematics type or tool offset with another. Task loads it on the HAL component canon already holds for its joint caps, which the newEXIT_CANON()releases; the preview module loads it fromINI_FILE_NAME; sai has no machine and says so.GET_EXTERNAL_HAL_VALUE()reads the pin, signal or param for#<_hal[name]>; task and the preview module answer it withhal_get_p()andhal_get_s().librs274 no longer links liblinuxcnchal or libkinslimits.
The second commit brings the stub canon in
tests/interp/compileup to date. Built against the internal headers it links-lrs274alone and prints whatexpectedholds. The test stays skipped:rs274ngc.hh,interp_base.hh,interp_fwd.hhandnurbs_math.hhare not exported toinclude/yet. @BsAtHome, how would you like that done?Tested with the ptp, kins (kins-switch reads
_hal[]), twp, interp, gcode-renderer and tool tests,rs274on aG68.3program, andgcode.parse()with HAL up. I added no test, since what the programs see is unchanged.Two choices to look at. Rene floated one
READ_SPECIAL_VARIABLE(name)for INI and HAL values; I kept a HAL-only call, since the interpreter reads the INI file itself. ThelogOwordnotes "no signal connected" and "signal has no writer" went away with the lookup.