Bash M1## how to use the P word

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

Attachment not found



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 .


 

Please Log in to join the conversation.

More
5 years 1 month ago #220402 by cmorley
Did you make it executable?
Does the file name use a lower case M?

Please Log in to join the conversation.

More
5 years 1 month ago #220413 by my1987toyota

cmorley post=220402 userid=482Did you make it executable?
Does the file name use a lower case M?

I will double check on the executable part .
The file uses an upper case M.

Please Log in to join the conversation.

More
5 years 1 month ago #220418 by anfänger
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

Please Log in to join the conversation.

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

Please Log in to join the conversation.

More
5 years 1 month ago #220505 by MaHa
eg.  for case 100 i was successful with
Code:
case $1 in      100.000000)

Please Log in to join the conversation.

More
5 years 1 month ago #220527 by my1987toyota

eg.  for case 100 i was successful with

Code:
case $1 in      100.000000)
 
Would you mind giving more context on what your code does?

Please Log in to join the conversation.

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

Please Log in to join the conversation.

More
5 years 1 month ago #220557 by anfänger
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.

Please Log in to join the conversation.

More
5 years 1 month ago #220569 by my1987toyota
Thanks guys. When I get a chance I will give that a shot.

Please Log in to join the conversation.

Time to create page: 0.152 seconds
Powered by Kunena Forum