Bash M1## how to use the P word

More
12 Sep 2021 20:51 #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.
 

File Attachment:

File Name: M101_2021-09-12.txt
File Size:0 KB


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.

More
13 Sep 2021 06:16 #220402 by cmorley
Did you make it executable?
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.

More
13 Sep 2021 08:31 #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 or Create an account to join the conversation.

More
13 Sep 2021 09:32 #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
The following user(s) said Thank You: my1987toyota

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

More
13 Sep 2021 20:36 #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 or Create an account to join the conversation.

More
13 Sep 2021 21:00 #220505 by MaHa
eg.  for case 100 i was successful with
case $1 in
     100.000000)

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

More
13 Sep 2021 23:14 #220527 by my1987toyota

eg.  for case 100 i was successful with

case $1 in
     100.000000)
 

Would you mind giving more context on what your code does?

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

More
14 Sep 2021 05:20 #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
The following user(s) said Thank You: my1987toyota

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

More
14 Sep 2021 06:01 - 14 Sep 2021 09:41 #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.
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.

More
14 Sep 2021 09:40 #220569 by my1987toyota
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
Powered by Kunena Forum