hal_create_thread for own project

  • TheRoslyak
  • TheRoslyak's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
24 Jul 2023 20:24 #276172 by TheRoslyak
hal_create_thread for own project was created by TheRoslyak
Hi everyone. I have returned again to developing my application with the HAL library. The thing is that I am trying to use the hal_create_thread function. The problem is that the library (LIBS+= -llinuxcnchal) does not contain this function, although it is in the Hal.h header. And, correspondingly, it is used in LinuxCNC to create a scheduler and interpolator (motmod). Therefore, I want to control several objects through different motion tasks from one computer. But I do not know how to connect the hal_create_thread function. It is linked in Qt Creator itself, but it does not work because it is not in the linuxcnchal library. Perhaps it is in another library, but I did not find it, or LinuxCNC needs to be compiled in a non-standard way, but I do not know how yet. I also tried to use the HAL library from Machinekit-HAL. But it seems I have built everything without errors, but I didn't find the *.so in which you can use HAL functions like hal_init. If anyone knows how to specify the library generated by Machinekit-HAL, please give me a hint. Also, there is a bonus function hal_create_xthread which allows you to create a thread for each processor core (this would be very useful). There is nothing about this function in the LinuxCNC files. In general, if anyone knows how to use the hal_create_thread function for their projects, please help. Tomorrow, for an example, I will share a simple project.

Please Log in or Create an account to join the conversation.

  • TheRoslyak
  • TheRoslyak's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
24 Jul 2023 20:45 #276174 by TheRoslyak
Replied by TheRoslyak on topic hal_create_thread for own project
It simpleĀ  project "Hello world" for hal_create_thread
Attachments:

Please Log in or Create an account to join the conversation.

  • TheRoslyak
  • TheRoslyak's Avatar Topic Author
  • Offline
  • Elite Member
  • Elite Member
More
25 Jul 2023 16:43 - 25 Jul 2023 16:44 #276235 by TheRoslyak
Replied by TheRoslyak on topic hal_create_thread for own project
Hello everyone. I've made a bit of progress on the issue. I managed to launch the function. I did this using the machinekit hal library. I did it not quite correctly. Specifically, I added a strict path to the *.so files. But at least it compiles. However, an error occurs at the function launch stage. Before this function is launched, hal_init() takes place. The program reaches a line where the error occurs: HAL: ERROR: create_thread called before init. Even though the initialization itself goes successfully before this. I tried to change the arguments, but as I understand it, everything is fine with them. I thought that after initialization it's necessary to create a couple of hal variables. In the end, I created them and they are displayed in the halmeter. But the error still pops up. I also tried to create a function "init_comm_buffers()", seemed to have written it in a hacky way. But still an error. Maybe I wrote this function wrong for my case, or maybe it's not needed at all and the error occurs for a different reason. If anyone has any ideas, please suggest them. I will post the assembly variant. Just in case, I get logs like these:
hal_init returned: 2
HAL: ERROR: create_thread calledĀ  before init
hal_create_thread returned: -22
HAL thread creation failed.
Attachments:
Last edit: 25 Jul 2023 16:44 by TheRoslyak.

Please Log in or Create an account to join the conversation.

Time to create page: 0.053 seconds
Powered by Kunena Forum