- Posts: 1003
- Thank you received: 0
Bash M1## how to use the P word
- my1987toyota
- Topic Author
- Offline
- Platinum Member
-
Less
More
5 years 1 month ago #220571
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
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.
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.
5 years 1 month ago #220574
by anfänger
Replied by anfänger on topic Bash M1## how to use the P word
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
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.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1003
- Thank you received: 0
5 years 1 month ago #220578
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
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.
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.
5 years 1 month ago #220580
by Aciera
Replied by Aciera on topic Bash M1## how to use the P word
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%.*}
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.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1003
- Thank you received: 0
5 years 1 month ago #220582
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
Okay. That makes sense.Aciera post=220580 userid=25994I believe the quotes depend on the location setting.
It should work with either ' ' or " " quotes.
Please Log in to join the conversation.
5 years 1 month ago #220595
by anfänger
Replied by anfänger on topic Bash M1## how to use the P word
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
, 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.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1003
- Thank you received: 0
5 years 1 month ago #220742
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
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.
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.
5 years 1 month ago #220765
by anfänger
Replied by anfänger on topic Bash M1## how to use the P word
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
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.
5 years 1 month ago #220770
by Aciera
Replied by Aciera on topic Bash M1## how to use the P word
I think it doesn't like the space after the variable name.
So try:
P=${1%.*}
Q=${2%.*}
So try:
P=${1%.*}
Q=${2%.*}
Please Log in to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
-
Less
More
- Posts: 1003
- Thank you received: 0
5 years 1 month ago #220786
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
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.
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
