Proper and safe evaluation of realtime capability#4132
Conversation
|
I do think it to be very problematic that getting the RT status is so involved. There should be a simple test that does not involve instantiating larger parts of infrastructure. |
|
:-D The CI has no realtime: It is somewhat a chicken and egg problem. Not involving the RT infrastructure needs separate code and this can always not be in sync with RT. Involving RT runs a lot of stuff. Let's think about this. Exactly the issue here: #4129 What do you think about a parameter / pin? So you can use getp / gets to ask for realtime? Or I could add a new command path to halcmd / rtapi_app that does not start the hal if it is not yet running. |
|
Running non-RT is not an error per se (see CI). Therefore, you cannot and must not "simply" or "blindly" force one or the other. There are use-cases where you want to know the RT status and that does not always mean that you will or will not be running either. Finding out what the RT status is or will be must be lightweight and may be different from where you ask. Doing it in a component or from the cmd-line may be different, depending how you ask and with what intention you ask. |
f1d22a7 to
97bb377
Compare
|
Both CI failures are small:
Two runtime things I noticed while reading:
Minor: |
b73daaf to
5dfd303
Compare
|
Thanks. Fixed. One quirk: RTAI in userspace is called LXRT. I should rename this consistently. |
7f6e60d to
fbf2b81
Compare
|
Hmm, time for a break, to many force pushes, sorry. I will continue tomorrow. So you are OK with the general concept? Then I will polish it up, update the doc and do some more testing in different combinations. Open:
Deferred:
|
|
The CI fixes and the LXRT / fallback handling look good now. On naming, with @BsAtHome's #4099 in mind: For the two open how-tos:
|
Well, I don't own it. However, I agree with the argument to leave the get/set moniker to the hal pin/param data access. |
|
The last few commits are still figuring out ways to solve all issues, not ready for code style review yet. @grandixximo Thanks a lot for the hints. Helps a lot not to have to search everything.
|
6477a97 to
af73e08
Compare
|
And of course, after debian package install, the realtime script is not any more in path. And there was also no define for the path where it is. af73e08 adds one. For scripts, |
|
Due to error handling is annoying not knowing when rtapi_app is running or not: It now works exactly the same as RTAI. And it generated a new ToDo: Cleanup the realtime script. It is a mess. There are a lot of RTAI only parts executed in uspace mode. Like loading an empty list of modules and so on. So far, I just added the things I needed. |
|
Two notes after the latest push. Naming: you're right, I'll withdraw my concern. CI / auto-start: the two failures ( Separately: is dropping the auto-start actually needed for the RT-status goal, or is it a cleanup that could be its own PR? Keeping them decoupled would let the getrt/ |
|
If these test fails due to a missing realtime start, they most probably fail also with RTAI, i have to test it. It is not needed in this PR. However, as soon you like to use I will move it in a separate PR as initialy planned, this one gets already big. |
|
Rebased to master and created a package. Now you can use: from lcnc import realtime
print("realtime.verify " + str(realtime.verify()))
print("realtime.status " + str(realtime.status()))or import lcnc
print("realtime.verify " + str(lcnc.realtime.verify()))
print("realtime.status " + str(lcnc.realtime.status()))I am seeing quite a lot of random files from linuxcnc installed just in top of dist-packages: ^^ looks to me like really bad practice, even if I have basically no clue of python. @grandixximo Do you work more with python? Any insight? Makes my package sens the way I am doing it? At least after installing the deb, I can run the above code directly with python and stepconf also passes the realtime check, so it is can not be to far... ;-) Otherwise, I could also just roll back the package creation and stick to lcnc_realtime.py / realtime.py instead of starting a whole new concept of creating a proper linuxcnc python package. It is not worse than the existing code. realtime.py will never collide with a python implementation of the realtime script, due to it will live in scripts/ or bin/ in the source and under /usr/lib/linuxcnc/realtime after install. The realtime.py module lives under lib/python/realtime.py and under /usr/lib/python3/dist-packages/realtime.py after install. |
|
Your instinct on the pollution is right: That said, for this PR I'd go with the flat
So: ship One thing that matters more than the packaging: And if the package does stay: drop the eager |
Agreed, that's a different project. Adding lcnc_realtime.py and migrating it later to lcnc/realtime.py does adds only minimal overhead to creating a package later. I just created an issue: #4198
At least for me, I rather do it the old fashioned way (lcnc_realtime.py) and do the package right in a different PR.
That would mean digging out the PEP 562 module
Thanks, I will do that. Just a side question. How can I have the package work the following way without an import in import lcnc
print("realtime.verify " + str(lcnc.realtime.verify()))
print("realtime.status " + str(lcnc.realtime.status())) |
|
Sounds good, and thanks for opening #4198. On the shim: yes, exactly. PEP 562 On the side question: with a genuinely empty If you ever did want the def __getattr__(name):
if name == "realtime":
import importlib
return importlib.import_module(".realtime", __name__)
raise AttributeError(name)That imports on first access only. But since you're dropping the package for now, none of that applies, |
|
Right, it seems that we've settled on the (color)name of the shed ;-) |
|
Till we decide to rename it tomorrow... |
|
So, I reverted the package, added doc and added the deprecation of is_sim / is_rt. I'd like to stick with Anything more except final testing? |
d9528f4 to
2951ecc
Compare
|
Coming out of draft? |
|
Yes, why not. I tested stepconf / pnyconf and retested a few parts. So I call it ready. |
|
Of course, my own test complained, fixed. |
The same checks are performed always the same now. If something is not properly checked, makeApp() fill fail instead of just chosing a different RT implementation by itsself. New function: rtapi_realtime_type_t rtapi_get_realtime_type(void)
rtapi_is_realtime() was always unreliable and broken for user components for some time. It is fixed but only available for rt components now. hal_get_realtime_type() returns the true running realtime type through the HAL for user and realtime components. This function is also exposed through python hal. rtapi_app now unloads hal_lib at exit, so everything is cleaned up properly and realtime_type is set back to REALTIME_TYPE_UNINITIALIZED.
REALTIME_TYPE_UNKNOWN / REALTIME_TYPE_PREEMPT_DYNAMIC need LINUXCNC_FORCE_REALTIME=1 to be set. These two options are most likely not desired and should not be selected automatically.
lcnc_realtime.verify() should be used instead of hal.is_rt
Instead use FutureWarning which is normaly visible for users
|
Now back to #4107 what does the "you are not running realtime" need look like in the UI? |
Intended to be used with:
#4107
Will fix is_sim / is_rt which is broken: #4129
Two new functionality's for two use-cases:
realtime statuscan be used to check if realtime is running.The realtime script is extended with the
verifycommand returning 0 if RT capable, 1 if not.It is intended to use when not running and running.
rtapi_app getrtand returns the stateThere is the new function
hal_get_realtime_type()returning the type of the actually running realtime system trough the hal.is_sim / is_rt use
realtime verifyat init.rtapi_is_realtime()is deprecated: It works only in real time context since #3964 and was never 100% reliable, also according to the doc.