Bash M1## how to use the P word
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
12 Sep 2021 20:51 #220366
by my1987toyota
Bash M1## how to use the P word was created by my1987toyota
So I have been trying to write an M1## code and using the P word to determine which instruction
to follow. I have written M1## codes to facilitate what feeder to trigger in combination with ClassicLadder.
The current code uses the " #!/bin/bash " and the " case " command.
if I put in the " echo " command before each halcmd . and it will list the commands when I run it in terminal.
but if I remove the " echo " command and run it in linuxcnc it wont send anything to linuxcnc but no error messages
appear either .
I am by no means any kind of expert in bash scripting and I hope I am missing something simple .
So I am looking for some idea what to look into here .
to follow. I have written M1## codes to facilitate what feeder to trigger in combination with ClassicLadder.
The current code uses the " #!/bin/bash " and the " case " command.
if I put in the " echo " command before each halcmd . and it will list the commands when I run it in terminal.
but if I remove the " echo " command and run it in linuxcnc it wont send anything to linuxcnc but no error messages
appear either .
I am by no means any kind of expert in bash scripting and I hope I am missing something simple .
So I am looking for some idea what to look into here .
Attachments:
Please Log in or Create an account to join the conversation.
13 Sep 2021 06:16 #220402
by cmorley
Replied by cmorley on topic Bash M1## how to use the P word
Did you make it executable?
Does the file name use a lower case M?
Does the file name use a lower case M?
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
13 Sep 2021 08:31 #220413
by my1987toyota
The file uses an upper case M.
Replied by my1987toyota on topic Bash M1## how to use the P word
I will double check on the executable part .cmorley post=220402 userid=482Did you make it executable?
Does the file name use a lower case M?
The file uses an upper case M.
Please Log in or Create an account to join the conversation.
13 Sep 2021 09:32 #220418
by anfänger
Replied by anfänger on topic Bash M1## how to use the P word
Upper case works for me. Usually it‘s the executable part. And it need to be in the right folder. And executable and in the folder before LinuxCNC starts. But then it works fine
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
13 Sep 2021 20:36 #220503
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
I am sure it will come down to my usual problem of inexperience .
I am still very new to coding C, C++, Python , Bash ect. I wish
their were more examples of Bash in Linuxcnc to draw from.
I think my problem stems from the fact that I am not sending a number to
a command I am using the P number to select a " case "
and that determines what part of the M code to run. That in turn
tells ClassicLadder what input and output pins to actuate .
I am still very new to coding C, C++, Python , Bash ect. I wish
their were more examples of Bash in Linuxcnc to draw from.
I think my problem stems from the fact that I am not sending a number to
a command I am using the P number to select a " case "
and that determines what part of the M code to run. That in turn
tells ClassicLadder what input and output pins to actuate .
Please Log in or Create an account to join the conversation.
13 Sep 2021 21:00 #220505
by MaHa
Replied by MaHa on topic Bash M1## how to use the P word
eg. for case 100 i was successful with
case $1 in
100.000000)
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
13 Sep 2021 23:14 #220527
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
Would you mind giving more context on what your code does?eg. for case 100 i was successful with
case $1 in 100.000000)
Please Log in or Create an account to join the conversation.
14 Sep 2021 05:20 #220554
by MaHa
Replied by MaHa on topic Bash M1## how to use the P word
It's from the timestamp for logfiles, still in use.
When M150 P100 is called, somehow the case statement is matching only, when testing 100 as 100.000000
forum.linuxcnc.org/20-g-code/36148-times...ogfile-solved#128037
When M150 P100 is called, somehow the case statement is matching only, when testing 100 as 100.000000
forum.linuxcnc.org/20-g-code/36148-times...ogfile-solved#128037
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
14 Sep 2021 06:01 - 14 Sep 2021 09:41 #220557
by anfänger
Replied by anfänger on topic Bash M1## how to use the P word
There was a change in LinuxCNC a while ago, i think all the former integers are now float. To change this you need to work with float in bash or convert. You can do this in the Goode or in bash.
Last edit: 14 Sep 2021 09:41 by anfänger.
The following user(s) said Thank You: my1987toyota
Please Log in or Create an account to join the conversation.
- my1987toyota
- Topic Author
- Offline
- Platinum Member
Less
More
- Posts: 814
- Thank you received: 331
14 Sep 2021 09:40 #220569
by my1987toyota
Replied by my1987toyota on topic Bash M1## how to use the P word
Thanks guys. When I get a chance I will give that a shot.
Please Log in or Create an account to join the conversation.
Time to create page: 0.099 seconds