Bash M1## how to use the P word

More
14 Sep 2021 10:19 #220571 by my1987toyota
That unfortunately didn't work. I have a feeling I have misunderstood how the M1## bash system works. 
if I enter this M170 in linuxcnc it works
#!/bin/bash
halcmd setp classicladder.0.in-50 true
exit 0 ;

however this M170 P01 code doesn't
#!/bin/bash
case $1 in
         01)
         halcmd setp classicladder.0.in-50 true
         ;;
esac
exit 0 ;

their must be alot of things going on behind the scenes in linuxcnc that I can't
see,  know about,  or probably don't understand.
I do have a theory that I may need to come up with a hal component to make
use of the P## as a varriable and the hal component determines what pins
to switch high or low instead of it happening in the M170 bash command.

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

More
14 Sep 2021 10:57 - 14 Sep 2021 11:00 #220574 by anfänger
Run LinuxCNC from command line

And change the script to:

however this M170 P01 code doesn't
#!/bin/bash
echo „P:“
echo $1
case $1 in
01)
echo „case true“
halcmd setp classicladder.0.in-50 true ;;
esac
exit 0

There you should see what the P value is
Last edit: 14 Sep 2021 11:00 by anfänger.
The following user(s) said Thank You: my1987toyota

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

More
14 Sep 2021 11:58 #220578 by my1987toyota
terminal responds
1.000000

I am unfortunately still very much a noob. Not just on Linuxcnc but also to Linux in general.

How did you make the upside down double quotes or ".  I couldn't duplicate that.

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

More
14 Sep 2021 12:08 - 14 Sep 2021 12:23 #220580 by Aciera
I believe the quotes depend on the location setting.
It should work with either ' ' or " " quotes.

[edit]
To get rid of all the zeros you could try:

echo ${1%.*}
case ${1%.*}
Last edit: 14 Sep 2021 12:23 by Aciera.
The following user(s) said Thank You: my1987toyota

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

More
14 Sep 2021 12:12 #220582 by my1987toyota

Aciera post=220580 userid=25994I believe the quotes depend on the location setting.
It should work with either ' ' or " " quotes.

Okay. That makes sense.
 

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

More
14 Sep 2021 13:49 - 14 Sep 2021 13:52 #220595 by anfänger
Yes I am in Germany sorry for the strange quotation marks.
, and as I pointed out this looks like a float int problem. You try to compare an intern with a float, and that doesn‘t work
Aciera already pointed you into the right direction try this

#!/bin/bash
P = ${1%.*}
Q = ${2%.*} # in case you want to use the second parameter to
echo " P: ${P} Q: ${Q}";

case $P in
1) echo „case true“
halcmd setp classicladder.0.in-50 true ;;
esac
exit 0

as soon as everything work you can remove or comment the echos. This is my stupid way of debugging
Last edit: 14 Sep 2021 13:52 by anfänger.

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

More
15 Sep 2021 21:58 #220742 by my1987toyota
I tried the new suggested code  and unfortunately it didn't work for me.
I think Linuxcnc has the M100 through M199 specifically coded to just
pass through the P and Q floats to a hal component and wont let you
use them in case, or if statement arguments.

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

More
16 Sep 2021 05:19 #220765 by anfänger
I use around 20 different bash written m codes with if or case statements it works.

I also have a debug m code that uses zenity to show the p and q.

I don’t have Access to my machines now. So I can’t attach them. But if can read german you’ll find some at barn.works in my blog entries for the mill conversion
The following user(s) said Thank You: my1987toyota

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

More
16 Sep 2021 06:41 #220770 by Aciera
I think it doesn't like the space after the variable name.

So try:

P=${1%.*}
Q=${2%.*}
The following user(s) said Thank You: my1987toyota

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

More
16 Sep 2021 10:45 - 16 Sep 2021 10:54 #220786 by my1987toyota
when I get a chance I will give it a try Aciera.

Anfanger, Unfortunately I can't currently read German however I can always try translating the words .
From what I have seen from your site their are a lot of good example to examine.

Thank you both for your help thus far.
Last edit: 16 Sep 2021 10:54 by my1987toyota. Reason: updating info

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

Time to create page: 0.180 seconds
Powered by Kunena Forum