WIP: rtapi_app no autostart#4206
Conversation
|
I'm not sure I like it that the raster test needs to call realtime start. It seems to be performed on the wrong level. |
Raster will most probably fail in RTAI the way it is implemented. |
|
Hmm, Is there a way to keep it running until the test is finished? Looks like the raster test does some non-standard things, that's why it breaks when I use manual start. |
|
The real clue is that the test program builds a component that the raster.hal connects to and then starts the realtime from within. This is a legitimate construct as .hal files are just lines executed by halcmd. This construct is expected to work. Therefore, auto-start is a requirement, whereas auto-stop should not be. (One very important thing is the line |
|
@BsAtHome makes the call for me: if a userspace component plus a That actually points at a smaller fix than this PR: keep autostart, drop only autostop. That preserves the raster construct with zero test edits, fixes the "debug value lost, master restarts on every loadrt" example from the PR description since the master now persists, and keeps The one review point that still stands regardless of which way you go: the |
It is not legal as long as RTAI exists. As predicted, this test fails with RTAI. RTAI has no autostart: With this PR, the test still fails but with a different reason: |
|
Regarding auto-start... I'm not worried about the LCNC code base. I'm worried about external installations. |
That's a point. Most people probably us uspace, not RTAI, so they never noticed that their setup will not work with RTAI due to they use halcmd instead of halrun. Even the actual tests are already broken... ;-) I have to think about how to solve this issue in a way that does not break the whole concept behind. Main issue: If you have autostart, the chance is high you forget stop. However, this will probably show issues already due to when you don't do stop, halcmd will complain about already loaded components and you will use There is just the case left where you unload all rt components and expect rtapi_app to exit, which won't happen. I already added a warning when you use start while rtapi_app is already running, so it should show up. |
|
On the residual you flagged (unload all rt components and rtapi_app stays running): that is actually consistent, not a regression. On RTAI, unloading all components does not stop the RT base either, you And the leak risk is bounded: halrun ( |
RTAI does also not do auto-start. Each linuxcnc application, including Expecting that most people use uspace and some of them probably use
Agreed. However, I don't like to re-add all this goto code and passing arguments to master that are executed immediately used for auto-start. So I might split master / client fully already in this PR and add an auto-start master functionality to the client. Let's see how this goes. Or also just create a start_master() function if splitting gets to cumbersome. |
This gives rtapi_app a deterministic behaivour. No other changes needed exept implementing start / stop in realtime due to all apps run: realtime start at startup realtime stop at exit
ee20601 to
b8b76f2
Compare
Use subprocess.Popen to start halrun and exit at the end.
b8b76f2 to
5fa7f0a
Compare
| #use interactive mode to be have the hal running | ||
| #while needed and exit with writing "exit" at the end | ||
| halrun = subprocess.Popen(["halrun", "-Is", "raster.hal"], stdin=subprocess.PIPE) | ||
| time.sleep(0.5) #Needs a short delay until halrun is up and running |
There was a problem hiding this comment.
This is probably not nice. ToDo: Find an other way to check if halrun is up.
6351c6c to
36269fe
Compare
36269fe to
08465cd
Compare
|
So, the auto-start is back, but in a different way than before that supports easy spit to master / client later. @grandixximo Do you know how I can wait until |
|
Version with master/client as a separate exe: It works but looks like more effort to get it finalized and could create more issues in the future. There is still some duplicated code which has to be moved to uspace_rtapi_common.cc and a library is also missing, just a POC. So I would prefer go forward the single exe way and split it in a future PR. |
|
I think the Maybe it is easier to sync through HAL than stdout here, since the test is already a HAL peer? Something like replacing the halrun = subprocess.Popen(["halrun", "-Is", "raster.hal"], stdin=subprocess.PIPE)
deadline = time.time() + 10
while time.time() < deadline:
if hal.component_exists("raster") and hal.pin_has_writer("test.output"):
break
time.sleep(0.01)
else:
raise RuntimeError("raster.hal did not come up within 10s")
Two small things I noticed in the teardown: |
|
A different solution: Why not encapsulate the test in a and rename Hal test files are run using |
Actual behavior:
This doesn't really allow to use hal.get_realtime_type() when there is no rt component loaded: #4205
This has other side effects, one example:
This PR changes the behavior to:
realtime startrealtime stopThis makes the behavior identical to RTAPI where
realtime start/realtime stopis needed and makes the behavior of rtapi_app more deterministic.Downside: Before, you where able to use
halcmd loadrt sum2on uspace without first starting realtime due to autostart. This does not work any more and it anyway never worked with RTAPI.However, I don't like having autostart without autostop, this will for sure create issues.
TBD