The Cython bindings do not support Params. I do not know about the original python bindings that came from the LCNC fork.
If you have a pin (not param), then you can set it with hal.Pin(‘pinname’).set(value)
If the params are needed in a python program, the best way would be to change the params to pins in the components source.
.
Forgot to mention what has cost me a lot of time in the past.
IIRC then in python ‘import hal’ imports the ‘legacy’ LCNC python bindings.
If you use ‘from machinekit import hal’ then you use the Machinekit cython generated bindings.
If I’m not right about this I hope to get corrected.
Snip from a previous project (3 yrs ago) where I used configparser:
import Configparser
# taken out of a class somewhere, adapt as needed, the config will be loaded in self.cfg_hardware
# somewhere setup_ini() is called, which does the actual loading
# in the instance:
self.cfg_hardware = ConfigParser.ConfigParser()
def setup_ini(self):
self.read_hardware_config()
for key, (field, joint) in enumerate(self.joints.iteritems()):
for (key, val) in self.cfg_hardware.items(joint.name):
joint.add_hardware_setting(key, val)
def read_hardware_config(self):
os.chdir(os.path.dirname(os.path.realpath(__file__)))
directory = os.getcwd() + '/config'
configfile = directory + '/hardware.ini'
self.cfg_hardware.read(configfile)
instead of the for loop for (key, val) in self.cfg_hardware.items(joint.name): you would get a value something like so: myval=cfg_hardware[‘SPINDLE’][‘MAXRPM’]
then use myval to set the pin
From: machi...@googlegroups.com <machi...@googlegroups.com> On Behalf Of justin White
Sent: Tuesday, 19 May 2020 17:01
To: Machinekit <machi...@googlegroups.com>
Subject: Re: [Machinekit] Re: halcmd setp equivalent in python
Yeah, I forgot Machinekit is in a perpetual state of "this might work the way it used to".....or "maybe not". I've recompiled components to swap parameters for pins but I don't think I'd try with a hm2 driver.
If all you want to do is set a parameter from an .ini line you don't have to do anything with Python whatsoever (unless there's some reason you really want to). All you need to do is:
In the .ini
[SPINDLE]
MAXRPM = 12000
In the hal file:
setp hm2_5i25.0.pwmgen.00.scale [SPINDLE]MAXRPM
That's the pretty standard usage, or am I missing something?
Yes, we were talking of doing this from python (see subject)