What C file is the Python interface?!

More
30 Aug 2017 19:57 #98231 by Moronicsmurf
Been digging around the linuxcnc source. And located a file called emcmodule.cc that seems to compile to a Python-C module that would talk "NML" with HAL layer?!

Am shooting in the dark here or am i right? If one would like to make custom python scripts that just run with hal in the background and interacts with hal, this is the "module" that needs to be imported into the python file?!

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

More
30 Aug 2017 23:26 - 30 Aug 2017 23:27 #98245 by andypugh
Have you seen:
linuxcnc.org/docs/2.7/html/config/python-interface.html

You can also:
import hal
if you want to interact with the HAL layer

Less commonly used, but usable, is
import emccanon

You can see example usage here:
github.com/LinuxCNC/linuxcnc/blob/andypu.../g71/python/remap.py
(only used in line 443 onwards)
Last edit: 30 Aug 2017 23:27 by andypugh.

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

More
31 Aug 2017 08:56 #98268 by Moronicsmurf
yeah i found the python-interface documentation, but it doesnt state what "file" that is actually the interface, what piece of code that compiles into the interface. what im suspecting is that this is the "interface"
github.com/LinuxCNC/linuxcnc/blob/master...ensions/emcmodule.cc

That would be compiled into a python-c library and then can be imported.
I'm toying with the idea if it can be converted to support other languages as well.
Me personally really dislike working with python, mostly because of its top down nature and open ended coding style. (well its the whole mac vs. pc debate so will not get into that).

But thinking it would be neat if one could create multi language support for interacting with the hal layer.
The following user(s) said Thank You: fletch

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

More
31 Aug 2017 09:11 #98269 by andypugh
What languages do you want to use?
I think that Python was chosen for the parts of LinuxCNC that are user-customisable because:

You don't need all the source code and headers
You don't need to compile
It is present as standard on most distributions

How much time do you spend customising your LinuxCNC installation? Is it really worth the trouble of what you describe just to avoid a language you somewhat dislike?

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

More
31 Aug 2017 09:45 #98271 by Moronicsmurf
I wanna support Node.JS primarily, and that would open the door for several other languages as well because translating from JS is alot easier than from Python into codebases like Haskell, LUA, Ruby. And you could move a remote interface onto a handheld device alot easier with JS support and a realtime protocole like WebRTC alot easier as well.
If i can do realtime stock exchange applications in Node.JS i do think it could be a good candidate for this as well.

Regarding pythons "standard" its present but it has so many conflicting versions atm, its a jungle. 2.7 or 3.x or whatever middle ground you need to end up in. My development laptop has 5 versions of python installed just to deal with that problem. Ontop of that all the external repositories and support libraries requires its own local builds or some exotic library to function properly. It was once a good language i guess.

All this is the "mac vs pc" discussion that i wanna avoid. =)

In the end its fun to play around with, if it ends in a broader language support for dealing with interface customization i don't see the harm in it actually. I do like the terminal console "gui" that replaced axis completely and just let me type directly into HAL - finding that made me figure if i could interact with it i could prob. make an android app or similar to interact with it over webrtc or websockets even. No intention of digging myself a hole in the linuxcnc source.. Its for fun. Code is fun. =)

For my personal use, i haven't even swapped out axis so far. It works well over parallell port. I have more problems with getting the hardware working than the software most of the times. (cuz i dont understand the mesa hardware and there is a big gap in the documentation of it between layman and professionals)

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

Time to create page: 0.068 seconds
Powered by Kunena Forum