Automatic linuxcnc start

More
26 Apr 2017 12:36 #92138 by noqui
Is there a way that if i copy a g-code file in a directory, automatically linuxcnc starts and process it?
Thanks a lot.

Diego

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

More
26 Apr 2017 15:02 #92150 by tommylight
Replied by tommylight on topic Automatic linuxcnc start
Yes in the ini file there is a line for exactly that, named "file something". Not near a computer, will check later.
The following user(s) said Thank You: noqui

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

More
26 Apr 2017 18:37 #92164 by tommylight
Replied by tommylight on topic Automatic linuxcnc start
OPEN_FILE = /home/your_user_name_here/linuxcnc/configs/your_config_name_here/file_name_to_open_at_start.ngc

That is ine the "display"section of the ini file.
The following user(s) said Thank You: noqui

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

More
26 Apr 2017 21:35 - 26 Apr 2017 21:36 #92172 by rodw
Replied by rodw on topic Automatic linuxcnc start
I think the OP is looking for hot folder processing. A folder is watched and when a file arrives, it is processed and moved to an output folder. Generally if an error is found it is moved to an error folder. I have plenty of experience in WIndows, I'm sure Linux will have a solution.

Search for linux watched folder or linux hot folder. Typically you would have a separate application doing the watching then it just needs to know which program to run against the file. Then you just need to work out how to drive linuxcnc from a script to run the gcode.
Last edit: 26 Apr 2017 21:36 by rodw.
The following user(s) said Thank You: noqui, tommylight

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

More
28 Apr 2017 12:19 #92256 by andypugh
Replied by andypugh on topic Automatic linuxcnc start

Then you just need to work out how to drive linuxcnc from a script to run the gcode.


There is a "remote-control" for the Axis UI here:
linuxcnc.org/docs/2.7/html/man/man1/axis-remote.1.html

Though I don't immediately see a way to run the loaded file. (But then, I can see _strong_ arguments for enforcing a physical button-push on the actual machine in order to run G-code)

Alterntively a simple Python script could be used:

linuxcnc.org/docs/2.7/html/config/python-interface.html

program_open() to load the file and then auto() to run it. I note that the docs are rather silent on what the arguments to auto() need to be. Some experimentation might be needed.
The following user(s) said Thank You: noqui

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

More
28 Apr 2017 13:31 #92270 by noqui
Replied by noqui on topic Automatic linuxcnc start
Thanks to all of you. I think i will have to learn how to run linux from a script, because rodw is right i need a hot folder processing

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

More
28 Apr 2017 22:25 #92309 by rodw
Replied by rodw on topic Automatic linuxcnc start
So you now have the building blocks to solve this as auto seems to be the way to do it.

There is actually a builtin unix command called watch Type man watch for the docs. There may well be better options.

There is some more info on the watch command here
beerpla.net/2007/08/04/watch-a-useful-li...have-never-heard-of/

Also this tool looks interesting and more focussed on file watching...
manpages.ubuntu.com/manpages/zesty/en/man1/inoticoming.1.html

Done properly, File watching should have very low CPU overhead as typically there is an API that sits idle doing nothing until an event (a change to the watched folder) occurs when it springs to life.

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

More
02 May 2017 11:39 #92511 by bkt
Replied by bkt on topic Automatic linuxcnc start
as andypugh suggest for load ngc code best solution is python scrip ....
#!/usr/bin/env python

import sys
import linuxcnc

k1program = str(sys.argv[1])
c = linuxcnc.command()
c.mode(linuxcnc.MODE_AUTO)
c.reset_interpreter()
c.program_open('yourNiceFolder? + k1program)
c.mode(linuxcnc.MODE_MANUAL)

name of program should be xxx.ngc ... or need use + '.ngc' on k1program string .... and mixing it on bash script or c/c++ program that you can run in same time of linuxcnc/Axis gui you can realize your project .... for example make an array of string of program in folder .... when you add a program in your folder (array is more bigger) than you can run python script ... sorry but from 1 year I plan to convert phyton-i9nterfaces call into c/c++ call but I have no time. Otherwise i would have posted a complete example ... i'm not good with python ... but in some old arkEye post there is some trace of this (c/c++ conversion) ... in addition there is pyqt if you can program in c / c ++ but not in Python ....

regards
Giorgio

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

Time to create page: 0.147 seconds
Powered by Kunena Forum