Bash M1## how to use the P word

More
5 years 1 month ago #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 to join the conversation.

More
5 years 1 month ago #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

Please Log in to join the conversation.

More
5 years 1 month ago #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 to join the conversation.

More
5 years 1 month ago #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%.*}

Please Log in to join the conversation.

More
5 years 1 month ago #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 to join the conversation.

More
5 years 1 month ago #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

Please Log in to join the conversation.

More
5 years 1 month ago #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 to join the conversation.

More
5 years 1 month ago #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

Please Log in to join the conversation.

More
5 years 1 month ago #220770 by Aciera
I think it doesn't like the space after the variable name.

So try:

P=${1%.*}
Q=${2%.*}

Please Log in to join the conversation.

More
5 years 1 month ago #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.

Please Log in to join the conversation.

Time to create page: 0.060 seconds
Powered by Kunena Forum