M100 running Python

More
06 Feb 2015 23:52 #55748 by BigJohnT
M100 running Python was created by BigJohnT
I've been unsuccessful trying to run a M100 file from the MDI window or in a G code file. Of course no error is seen anywhere so I'm a bit stuck. I can click on the files and they run as expected.

JT

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

More
07 Feb 2015 01:15 #55753 by ArcEye
Replied by ArcEye on topic M100 running Python
Can only suggest you run Linuxcnc in a terminal.

You should get either python errors or bash errors output to stderr and displayed in the terminal.

regards

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

More
07 Feb 2015 01:45 - 07 Feb 2015 01:52 #55754 by BigJohnT
Replied by BigJohnT on topic M100 running Python
Good idea, I forgot to put a happy extension on the files.

Edit: No errors reported. Both files execute from the terminal but not from within LinuxCNC

JT.
Attachments:
Last edit: 07 Feb 2015 01:52 by BigJohnT.

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

More
07 Feb 2015 04:06 #55757 by ArcEye
Replied by ArcEye on topic M100 running Python
This is obviously connected to the topic on the users list.

If you are still struggling in the morning (here), I'll give it a try.
Never tried it before personally.

regards

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

More
07 Feb 2015 09:54 #55764 by dgarrett
Replied by dgarrett on topic M100 running Python
Ref:http://www.linuxcnc.org/docs/html/config/ini_config.html#sub:RS274NGC-section
Search order for M files:
A search is made for each possible user defined function, typically (M100-M199). The search order is:

    [DISPLAY]PROGRAM_PREFIX (if specified)

    If [DISPLAY]PROGRAM_PREFIX is not specified, search the default location: nc_files

    Then search each directory in the list [RS274NGC]USER_M_PATH

    The first executable M1xx found in the search is used for each M1xx.

Note also:

1) The file must be executable (as stated above) use chmod +x to set.
2) The file must be named starting with a captial M.
(but gcode itself doesn't care about capitalization so you can invoke with lower case m)
3) The most common location is probably using [DISPLAY]PROGRAM_PREFIX.
4) Using [RS274NGC]USER_M_PATH is more flexible if you manage many m files.
5) The use of nc_files is probably uncommon as nc_files refers to a directory
relative to the directory containing the inifile (e.g. a subdirectory of the
inifile directory or a symbolic link in the inifile directory named (nc_files)
that points to another directory.
6) The search is made once at program startup -- you cannot dynamically add
files or change permissions while runnning.

Source code Ref: git.linuxcnc.org/gitweb?p=linuxcnc.git;a...bd7b27d7;hb=HEAD#l86

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

More
07 Feb 2015 20:43 - 07 Feb 2015 20:43 #55777 by ArcEye
Replied by ArcEye on topic M100 running Python
Hi JT

I have it running, but only by changing a bit.

I made it executable and invoked python directly

Imported os and ran system() to load into iceweasel

I am unsure how clicking on the file ever displayed it previously, unless you were doing so from something that picked up the mime type (like a file manager) and automatically launched it in a browser

The only problem is that the refresh falls foul of my settings for iceweasel and it does not display anything unless you press F5 manually to refresh and display it
Substituting other html code works fine

#! /usr/bin/python

import os

fo = open('status.html', 'w')
info = '''
<HTML>
<HEAD>
<meta http-equiv="refresh" content="10"> <!-- Refresh every 1 minute -->
<TITLE>Change Part</TITLE>
</HEAD>
<BODY>
<p>Change Part!</p>
</BODY>
</HTML>
'''
fo.write(info)
fo.close

os.system("iceweasel status.html")

quit()

regards
Last edit: 07 Feb 2015 20:43 by ArcEye.

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

More
08 Feb 2015 20:27 - 08 Feb 2015 21:31 #55808 by BigJohnT
Replied by BigJohnT on topic M100 running Python
Here's what I sorted out or rather cradek guessed what was happening. The M110 file is not executed where it is, so I was looking in the wrong directory for the html file. What happens is when the M110 is executed in Axis it is in the configuration directory so not specifying a specific output directory the html file was created in the configuration directory. I was assuming the M110 was executed where it was which led me to the incorrect conclusion that it was not working. When I ran the M110 from the file manager or terminal it ran in the nc_files directory so the output was sent to that directory.

I had the html page open in icewheasel prior to running so I was looking for the change only.

Thanks for looking
JT
Last edit: 08 Feb 2015 21:31 by BigJohnT.

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

Time to create page: 0.078 seconds
Powered by Kunena Forum