Python comp - Basic usage example

  • zz912
  • zz912's Avatar Topic Author
  • Offline
  • Platinum Member
  • Platinum Member
More
26 Jul 2023 16:58 - 26 Jul 2023 17:01 #276315 by zz912
Python comp - Basic usage example was created by zz912
Hello,

Here's something like "Hello world" for creating your own HAL component in Python:
linuxcnc.org/docs/2.9/html/hal/halmodule..._basic_usage_example

I think it would be good if there was a way to compile other than $PATH. I think many people don't know what $PATH is. Like me before.
forum.linuxcnc.org/38-general-linuxcnc-q...-path?start=0#274842

I suggest changing the text:

"Copy the above listing into a file named "passthrough", make it executable (chmod +x), and place it on your $PATH. Then try it out:"

to:

"Copy the above listing into a file named "passthrough", make it executable (chmod +x), and place it on your $PATH.
Second way copy the above listing into a file named "passthrough.py", run "sudo halcompile --install --userspace passthrough.py"
(
Do not use [sudo] for RIP installation)
Then try it out:"

Or similar change text.

I think it could make it easier for many beginners to get into the HAL component in Python.
 
Last edit: 26 Jul 2023 17:01 by zz912.

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

More
28 Jul 2023 08:28 #276443 by AlexMagToast
Replied by AlexMagToast on topic Python comp - Basic usage example
I also had to learn what $Path is and only found out by lots of trying, so i agree with you.
After i sorted this out however i created a couple of python based components for my CNC Lathe all using this library:
linuxcnc.org/docs/html/hal/halmodule.html (it is the same i guess?)

To install you only have to do 2 steps:

1. make arduino.py executable with chmod +x, delete the suffix .py and copy it to /usr/bin

sudo chmod +x arduino.py
sudo cp arduino-connector.py /usr/bin/arduino-connector


2. add this entry to the end of your hal file: loadusr arduino-connector

putting the files in /usr/bin works very well, for me. Isn't this always the right directory?
Here is a link to my repo, if anyone is interested. github.com/AlexmagToast
Said Components are: arduino_connector, Lubedude and Sauter Head Revolver.
 
The following user(s) said Thank You: zz912, aaronstone

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

Moderators: HansU
Time to create page: 0.053 seconds
Powered by Kunena Forum