Saving parameters after shut down
What happens if Lcnc does not shut down from the UI. On my machine the bios will shut down all open programs when the power button is pressed before it actually does the power down.
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
Why not put "restore" and "save" in the SIGINT and SIGTERM routines?
(I _think_ that the contents of the shared memory are retained until everything has quit)
I had considered something similar, but it was becoming too specific.
I use the signal() function to try to make sure that the user_mainloop finishes cleanly, no matter what the cause was.
If I put write code in it, it would overwrite the file with whatever was in the spin_boxes, even if it was garbage, so I left it as requiring some form of conscious trigger.
It could be done that way, but there might be downsides as well as advantages. Perhaps a component really should be modular and only requiring connections to pins?
Up to you I can do it either way
Please Log in or Create an account to join the conversation.
Am I making sense?
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
It could certainly be made more generic by creating N parameter pins at load time.
I would have to implement it differently, by indexing through an array of pins so that the number does not have to be known initially.
I did something similar recently.
I take it works OK as is for your current requirement?
Please Log in or Create an account to join the conversation.
Debugging these things live is a real challenge and not pleasant at the best of times.
Regards
Marius
www.bluearccnc.com
Please Log in or Create an account to join the conversation.
Well by the time you get to it, I might have finished the generic component.
Just need to ascertain if I can do things the way I want to inside a userspace .comp file or if it would be better to just write a C component from the outset.
The RT module parameter macros don't work for userspace components, so need to see if I can parse the command line before the pins are created.
regards
Please Log in or Create an account to join the conversation.
Just need to ascertain if I can do things the way I want to inside a userspace .comp file or if it would be better to just write a C component from the outset.
If you want to support a variable number of pins, of a variable datatype, then you need to be working in C.
comp doesn't handle variable-sized arrays, and certainly doesn't understand variable arrays of unions.
In the smart-serial code (which has absolutely no idea how many pins it is going to find, of what type, but it could be literally thousands) I couldn't get a Union to work for me. So I use a struct that contains one of each HAL data type. Only one of them is ever mapped to a HAL pin, and the code decides at run-time which one to use.
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...d943aad72448ea5212ed
struct hm2_sserial_pins_t
Please Log in or Create an account to join the conversation.
So far I have found 2 errors in the comp file which stop the userinit(argc, argv); function from working.
argv was being assigned to itself instead of argv_ plus another minor typo, no terminating ; to the function declaration.
I am rewriting the generated C code from comp to allow the userinit function to parse the commandline
and populate static ints, which can then set array sizes within the export() pin creation routine.
It is similar in a way to your solution, because they are declared before the commandline is parsed and may end up containing nothing
and not triggering the creation of an array, or even a single pin.
I may then try to reverse engineer my changes and patch comp, or just keep the file I end up with as a template.
See how it goes.
regards
Please Log in or Create an account to join the conversation.
I may then try to reverse engineer my changes and patch comp
Seb already fixed it, I think:
git.linuxcnc.org/gitweb?p=linuxcnc.git;a...5c1a465260fe0a39e636
Please Log in or Create an account to join the conversation.
Yes he has fixed the same userinit() typos in the master, I was using 2.5.2
I know he has already made a more complete change to the struct __comp_state *inst; visibility issue than I did, but that does not seem to be in the pull of the master I have at present.
The reverse engineering I was referring to was the whole way export() gets it values
The problem is whether I have the interest to try to fix all the possible eventualities, having solved my own
Please Log in or Create an account to join the conversation.