Git Product home page Git Product logo

Comments (13)

satiowadahc avatar satiowadahc commented on June 7, 2024

I think I've narrowed it down to:

pyhalitem * pypin = PyObject_New(pyhalitem, &halpin_type);

It seems its a struct up until this point, after this function it becomes a standard python type.

from linuxcnc.

satiowadahc avatar satiowadahc commented on June 7, 2024
>>> import hal
>>> h = hal.c
hal.component(           hal.component_exists(    hal.component_is_ready(  hal.connect(             hal.ctypes               
>>> h = hal.component("asdf")
>>> pin = h.newpin("out", hal.HAL_U32, hal.HAL_OUT)
>>> pin.get_dir()
32
>>> pin.get_dir() == hal.HAL_OUT
True
>>> pin.get_dir() == hal.HAL_IN
False
>>> type(h.out)
<class 'int'>
>>> type(pin)
<class 'hal.Pin'>
>>> 

So it seems its not adding the struct but the type of hal component to the main class.

from linuxcnc.

satiowadahc avatar satiowadahc commented on June 7, 2024

So there is two documentations for this:
http://linuxcnc.org/docs/stable/html/config/python-hal-interface.html
http://linuxcnc.org/docs/html/hal/halmodule.html

Does it make sense to have both?
The first is for import hal.py the second is for _hal.py

from linuxcnc.

jethornton avatar jethornton commented on June 7, 2024

They appear to be the same thing to me

john@cave:~$ python3
Python 3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import _hal
>>> dir(_hal)
['HAL_BIT', 'HAL_FLOAT', 'HAL_IN', 'HAL_IO', 'HAL_OUT', 'HAL_RO', 'HAL_RW', 'HAL_S32', 'HAL_U32', 'MSG_ALL', 'MSG_DBG', 'MSG_ERR', 'MSG_INFO', 'MSG_NONE', 'MSG_WARN', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'component', 'component_exists', 'component_is_ready', 'connect', 'disconnect', 'error', 'get_info_params', 'get_info_pins', 'get_info_signals', 'get_msg_level', 'get_value', 'is_kernelspace', 'is_rt', 'is_sim', 'is_userspace', 'item', 'kernel_version', 'new_sig', 'pin_has_writer', 'sampler_base', 'set_msg_level', 'set_p', 'shm', 'stream', 'streamer_base']
>>> import hal
>>> dir(hal)
['HAL_BIT', 'HAL_FLOAT', 'HAL_IN', 'HAL_IO', 'HAL_OUT', 'HAL_RO', 'HAL_RW', 'HAL_S32', 'HAL_U32', 'MSG_ALL', 'MSG_DBG', 'MSG_ERR', 'MSG_INFO', 'MSG_NONE', 'MSG_WARN', 'Param', 'Pin', '_ItemWrap', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', '_hal', 'component', 'component_exists', 'component_is_ready', 'connect', 'disconnect', 'error', 'get_info_params', 'get_info_pins', 'get_info_signals', 'get_msg_level', 'get_value', 'is_kernelspace', 'is_rt', 'is_sim', 'is_userspace', 'item', 'kernel_version', 'new_sig', 'pin_has_writer', 'sampler_base', 'set_msg_level', 'set_p', 'shm', 'stream', 'streamer_base']
>>> 

Nothing every makes any sense to have it in two places. I worked for years on the docs to eliminate that...

from linuxcnc.

satiowadahc avatar satiowadahc commented on June 7, 2024

One does inherit from the other. But there should at least be a link

from linuxcnc.

satiowadahc avatar satiowadahc commented on June 7, 2024

Could look at moving functions from hal.py into the boost module. Then it's a single implementation as well?

from linuxcnc.

andypugh avatar andypugh commented on June 7, 2024

Does it make sense to have both? The first is for import hal.py the second is for _hal.py

I think that they are different things. One describes the actual hal module (what you get when you "import hal") the other describes how to write non-realtime components in Python, which tends to use the halmodule library.

from linuxcnc.

rene-dev avatar rene-dev commented on June 7, 2024

I have a branch which ports halmodule to pybind11, which eliminates all of this issues, and removes 95% of the code.

from linuxcnc.

rene-dev avatar rene-dev commented on June 7, 2024

master...rene-dev:linuxcnc:pybind11

from linuxcnc.

andypugh avatar andypugh commented on June 7, 2024

Are ou suggesting that someone should merge this, or is it presented just for info?

from linuxcnc.

rene-dev avatar rene-dev commented on June 7, 2024

I would love to continue working on pybind11, but anything prior to bookworm doesnt have packages for it.

from linuxcnc.

andypugh avatar andypugh commented on June 7, 2024

We have the ability to do our own backports, if that would help.

from linuxcnc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.