Does anyone have a good idea to modify HAL?
In my idea, the new logic control layer also includes a data area.
That is nice.
I don’t like using pointers for input and output.
If you look at a standard c++ library. You can use structures like POINT for a passing an x,y,z coordinate from module a to module b or something. Then you could use iterators (kind of pointers) or not. That's to the user. I think a simple thing like i=0; is better to read
then it->... Using c++ template function's are also hard to get trough for new users. I can program quite complex stuff and don't use to complex programming style because i want to keep it readable. If i want to confuse other programmers i will write abracadabra code.
The current function call method is ok
I think a new function style call can better :
stepgenerator(4); //add a stepgenerator for 4 axis.
it depends on the function chain in a thread
It has influence in wich order the functions are called. It you got a incorrect order, you got a output error message.
That's why the postgui.hal file is alway's the last one to start.
Maybe you can give some program examples of how you think it's nice to set up.
Please Log in or Create an account to join the conversation.
thanks for reply. I think you have already a lot of good ideas and are working on it.
I am still thinking hard about the combination and trade-offs of these functions. If I make any progress, I will post the code here, and we can discuss further
Please Log in or Create an account to join the conversation.
- tommylight
- Away
- Moderator
- Posts: 19209
- Thank you received: 6438
Please Log in or Create an account to join the conversation.
I just realized that maybe we are talking about two different things: the HAL layer proper and what is setting up the HAL environment - the HALcmd.
Because the HAL layer is a memory space (where the Pins, Parameters and others live) and threads (where the module's functions are periodically called).
There are programmatic ways how to set the HAL up, the simplest are the .hal files, but then there is the TCL language support or Python support (not currently in LinuxCNC). This is happening all on the non-real-time side of things. I am not sure it would be even possible (very probably yes, but not that simple) to do this on the real-time side. I have a feeling that this is it when you talk about the ST language.
Then there are the real-time scheduled threads with function callback pointers, which are scheduled cyclically. I have few ideas how to create thread pool with waiting threads on some action, I have personally called it observability. I think it could have a nice asynchronous use-cases. But so far it is just an idea.
However, from cyclical real-time thread, you cannot call too many functions or have too demanding logic, otherwise you will miss you timeshare and create a real-time exception.
As cmorley said, Machinekit-HAL has implemented something similar. Maybe you could take a peak and see if you could not get some inspiration from there.In my idea, the new logic control layer also includes a data area, which stores the data of the instantiated module(means there might be many instance of a module, and you need to handle each by their own name) and global variables. I don’t like using pointers for input and output. I hope that each module will allocate space in the data area after instantiation (including input output inout and local variables).
I always like the more general approach to modules which do one thing only and composing them together. Problem is, people like more the focused, all-in-one solution - because it is usually simpler for them.Because the relationship between the control modules is very close, for example, a robot module must be connected to a kinematic module, several Axis module, axis module is connected to one or two servo modules, and each servo is connected to a motor module.
Yes, you can have modules exporting public headers and other modules depending on it. However, you will have to still solve the communication between them. For example the current LinuxCNC's HAL does not support multicore, so you cannot have more than one thread accessing HAL shared memory segment.For module designers, he could use another module’s header to know others variables or functions. I think this should be used for inter-module communication.
It's probably translation error, but I don't understand what is meant by this.I think a fixed code area is needed to store functions, mainly for adding compilers in the future.
Yes, you understand it right.The current function call method is ok, if I understand it correctly, it depends on the function chain in a thread.
Well, you can connect two functions with input/output by way of HAL Pins. Of course, if the consumer is before producer in the call order, it will see the change only in the next iteration of HAL thread.you cant just do operation like robot.x=axis1.pos.
Again, maybe we don't understand each other (there is a problem in translation), but each HAL thread already has a "main" function, it is the infinite loop from which all the HAL functions callbacks are called.I think it is better to add a single main function directly to the thread, which has already been compiled.
From HAL module function you can call all the (C) functions you want, of course you have to make sure that they will not create a real-time exception (for example syscalls are a no-go operation).The way i think each function or module should be designed is that they all all functions that returns void, and the parameter has only one pvoid pointing to the parameter structure actually used.
I think you are getting the hang of things nicely. But you must realize that for the things you want to implement, you will have to do a really deep changes to the current implementation of HAL. Which will (very) probably not fly in LinuxCNC, so be prepared to create your own fork.Just some ideas that are just beginning to be realized. Please correct me if there is an error
Please Log in or Create an account to join the conversation.
My initial idea was to keep the hal thread and sharememory and modify the others. My vision has been basically written, maybe it's just not well expressed. An important part of it is the compiler. The compiled language is not c language, but...hal language. In fact, I just want to use the registered functions and assigned variables in hal, and then complete some logic control. The classicladder is fine, but not enough. I think hal still needs a compiler. The compiled binary code will be loaded into an area of hal shm, and these function pointers will also be registered to hal. In fact, I just want hal to complete the logic and process control by itself, without using c to complete it.
I know that many people have the same problems as me. The solution for many of them is to leave cnc and cut off hal. I like hal very much, it has potential, and it gives me a lot of inspiration. I am now very motivated to modify it. Thank you for your support (this time I used Google to translate the full text, it should be much better than my crappy English)
Please Log in or Create an account to join the conversation.
regards
bkt
Please Log in or Create an account to join the conversation.