Python interface states of the home switches?

More
24 Jun 2019 00:59 #137684 by cmorley
Do you have a suggestion we could add to he docs to make this clearer?

Chris M

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

More
24 Jun 2019 02:01 #137692 by lorenzn
The biggest stumbling block for me was not the docs but the error message:

AttributeError: Pin 'panelinterface.pyvcp.rapid-machine-zero' does not exist

This pin does actually exist so the message is not accurate. The message was issued because I was incorrectly testing the pin from the Python hal component.
    # wrong usage results in error message above:
    print(pc.h['panelinterface.pyvcp.rapid-machine-zero'])

    # correct (pc.h is the 'panelinterface' component):
    print(pc.h['pyvcp.rapid-machine-zero'])


As far as the docs I have a few ideas for improvements. Embarrassingly when debugging this I was referencing the 2.7 docs although I have the 2.8 docs bookmarked and built the 2.8 docs locally. So I missed the existence of get_value until coming to the forum but my initial trouble was with accessing the pin value from the hal component.

1. We could add an example of the hal.get_value() usage in the "Reading and writing pins and parameters" section to contrast accessing the pin value from the component.


2. In the examples, add information about where "h" comes from and remind the user what that refers to. I'm referring to the current example:
    h.out = h.in 

and
    h['out'] = h['in']

See the Python 3 documentation of pathlib for example. Every snippet starts with defining "p". Good to remind the user that "h" here refers to the hal component (even though it is shown in a previous section). I can look into writing something up and making a pull request for a doc update.

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

More
24 Jun 2019 05:21 #137701 by cmorley
AttributeError: Pin 'panelinterface.pyvcp.rapid-machine-zero' does not exist

maybe:

AttributeError: Pin 'panelinterface.pyvcp.rapid-machine-zero' does not exist in the component panelinterface.

would be better?

Chris M
The following user(s) said Thank You: lorenzn

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

More
24 Jun 2019 11:23 #137724 by lorenzn
I agree - that error message is better. I think that would have been enough for me to realize my mistake earlier.

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

More
24 Jun 2019 12:00 #137726 by rodw

AttributeError: Pin 'panelinterface.pyvcp.rapid-machine-zero' does not exist

maybe:

AttributeError: Pin 'panelinterface.pyvcp.rapid-machine-zero' does not exist in the component panelinterface.

would be better?

Chris M


I've not really followed this thread, but to me, you are adding verbosity for no reason. Doesn't:
panelinterface.pyvcp.rapid-machine-zero
Say the same thing? It clearly identifies the component where the pin lives.
The following user(s) said Thank You: lorenzn

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

More
24 Jun 2019 12:04 #137727 by andypugh

I've not really followed this thread, but to me, you are adding verbosity for no reason. Doesn't:
panelinterface.pyvcp.rapid-machine-zero
Say the same thing? It clearly identifies the component where the pin lives.


That's the point. It's clear to you, but it wasn't clear to the original poster.
The new phrasing would be clear to both you _and_ the OP. So I think that's a win.

Bear in mind, rodw, that you are now a LinuxCNC expert and what is obvious to you now wasn't always so.
The following user(s) said Thank You: lorenzn

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

More
24 Jun 2019 12:12 #137728 by lorenzn
Yes 'panelinterface.pyvcp.rapid-machine-zero' does identify where the component lives.

The issue is that the error message says the pin doesn't exist (actually it does exist if we consider the full path to the pin).

I would have better understood the error message if it was something like:

SomeError: Pin 'panelinterface.panelinterface.pyvcp.rapid-machine-zero' does not exist

When you check the status of a pin from inside a Python component you must not provide the component name itself.

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

More
24 Jun 2019 12:20 #137729 by lorenzn
More verbosity in error messages is not typically a bad thing. Sure more verbosity in API usage is bad as it's more work for the user to get something done. Verbosity in error messages can be good in order to help the user overcome the error. There are other software products that I work with that enforce error message standards that say you must not only tell the user what went wrong but must also provide the 'why' and suggestions to overcome the error.
The following user(s) said Thank You: rodw

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

More
24 Jun 2019 12:20 #137730 by rodw

Bear in mind, rodw, that you are now a LinuxCNC expert and what is obvious to you now wasn't always so.


Maybe so, but I learnt very quickly how to identify missing pins because I took the time to study the error messages and look for clues. No offence to the OP but sometimes I think people on this forum want solutions laid out on a platter and don't stop, analyse and think for themselves.

Sure I still get stuck and ask for help but not before I've had a go at it myself, just like I did in my early days. I still use hal code, Todd wrote for me right at the beginning when I was trying something cool but could not get it working. I was blown away by his generosity.

And I'm only an expert on a very small corner of the LinuxCNC ecosystem. So much more to learn. Whats a spindle for instance!

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

More
24 Jun 2019 13:23 #137735 by Clive S

Whats a spindle for instance!


Here you go: spindle. The definition of a spindle is a thin rod used for spinning, or a yarn measurement. An example of a spindle is what sewing thread is spun around. An example of a spindle is 15,120 yards of cotton yarn.
:evil:

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

Time to create page: 0.089 seconds
Powered by Kunena Forum