Hello Guest it is April 24, 2024, 08:33:44 AM

Author Topic: file i/o  (Read 1993 times)

0 Members and 1 Guest are viewing this topic.

file i/o
« on: April 01, 2017, 06:05:43 PM »
Why does this fail with error that the file cannot be created?
Not sure how to open and close files for probe data.

Quote

local rc=mc.mcCntlProbeFileOpen (inst, "KFCProbeFile.csv", "%.4Axis_X, %.4Axis_Y", TRUE)

local rc=mc.mcCntlProbeFileClose(inst)


Thanks
Re: file i/o
« Reply #1 on: April 01, 2017, 06:23:22 PM »
Hi,
the file open statement requires a path in addition to the filename.

Have a look at m401 in Mach4Hobby/LuaExamples/ProbeToFile .

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: file i/o
« Reply #2 on: April 01, 2017, 06:43:01 PM »
I don't understand the M401 code but how about this?  It still does not write to the file during the probe operation.
Quote

local path="c:\\Mach4Hobby\\Modules\\KFCProbeFile.csv"
mc.mcCntlProbeFileOpen(inst, path, "%.4Axis_X, %.4Axis_Y", TRUE)


Thanks Craig
Re: file i/o
« Reply #3 on: April 01, 2017, 09:54:08 PM »
Hi,
I don't think you've got the path right yet...

This is a register I use to access a file which is subsequently used in a macro:
Quote
C:\Users\craig\Documents\eagle\fourthFOC\AEProbeData.txt

Try putting your probefile in the same directory as your Gcode, not your modules directory.

Craig

'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: file i/o
« Reply #4 on: April 02, 2017, 11:32:10 AM »
Got it?   TRUE is not valid but true is...  case sensitive!

Also  \\ double slashes is correct so this below worked great

mc.mcCntlProbeFileOpen(inst, "C:\\mach4Hobby\\GcodeFiles\\KFCProbeValues.csv","%.4AXIS_ %.4AXIS_Y\n", true)

only problem is that the G31 move will only run twice in a row then it kicks out...
« Last Edit: April 02, 2017, 11:34:44 AM by thespindoctor »
Re: file i/o
« Reply #5 on: April 08, 2017, 04:29:11 PM »
Hi,
in LUA a backslash, '\', is an escape character. Consequently if you wish to put a backslash in a LUA string the backslash
will have to be quoted or preceeded by an escape character ie another backslash.

Your instruction:
mc.mcCntlProbeFileOpen(inst, "C:\\mach4Hobby\\GcodeFiles\\KFCProbeValues.csv","%.4AXIS_ %.4AXIS_Y\n", true)
does require the double backslashes however if you have a path string with backslashes embedded:
mc.mcCntlProbeFileOpen(inst,path,"%.4AXIS_ %.4AXIS_Y\n", true)
will work.

Craig
'I enjoy sex at 73.....I live at 71 so its not too far to walk.'
Re: file i/o
« Reply #6 on: April 08, 2017, 07:59:36 PM »
Thanks!