LOGOPEN - logging HAL PINS?

More
01 Dec 2010 09:34 #5791 by eslavko
Hello...

We have command (LOGOPEN, filename) to open file and have chance to log some stuff. I have a lot of situation where that can be very useful. But got problem as Log should be closed before some other application can read log.
So I think that command be more usseful if we can configure it to NOT truncate log file. something like:

(LOGOPEN, filename)
old way to truncate filename

(LOGOPEN, filename,append)
to preserve old data and append new to the end.


And other one what to put into log?
(LOG, some text)
(LOG,#<named_parameter>)

I like to expand that to
(LOG,#<HAL_PIN>)

In many time I need to save current coordinate and have problems as they are not available. The only way I find is to save coordinate with G28.1 and then save variable. But isn't realy good as the coordinate are machine coordinate and in most cases are different of coordinates shown in AXIS DRO dysplay. Making HAL pin with correct DRO value isn't so hard but how to put that in some other routine or to write to file? Someone will say that I can use teach-in.py script for that. And I wil say try to do that in regular basis...

Does realy only me need that stuff?!?

Slavko.

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

More
01 Dec 2010 14:21 #5796 by andypugh
eslavko wrote:


I like to expand that to
(LOG,#<HAL_PIN>)

That does sound potentially useful, though I am not sure that the G-code interpreter can see HAL pins.
Have you looked at Halsampler? that might do what you want.
www.linuxcnc.org/docview/html//man/man1/halsampler.1.html
And the other direction-
www.linuxcnc.org/docview/html//man/man1/halstreamer.1.html

In many time I need to save current coordinate and have problems as they are not available. The only way I find is to save coordinate with G28.1 and then save variable. But isn't realy good as the coordinate are machine coordinate
...
Does realy only me need that stuff?!?
No, I have often wanted to write G-code which knows the current relative coordiates.


The way I do it is:

G92 x0 y0 z0 (store position)
g92.2
#<x> = #5211
#<y> = #5212
#<z> = #5213
g92.1

But that only works if you are not using G92 offsets at the time. I guess you _could_ store the G92 offsets then put them back.

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

More
01 Dec 2010 14:52 - 01 Dec 2010 14:53 #5802 by eslavko
andypugh wrote:
.

The way I do it is:

G92 x0 y0 z0 (store position)
g92.2
#<x> = #5211
#<y> = #5212
#<z> = #5213
g92.1

But that only works if you are not using G92 offsets at the time. I guess you _could_ store the G92 offsets then put them back.


Just does what I needed...
And I changed LOGOPEN to not restore existing file.. Hopefuly that will someone check and updated the source.

Just don't know where to post.. Forum? mailing list? .....
Last edit: 01 Dec 2010 14:53 by eslavko.

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

More
01 Dec 2010 14:55 #5803 by eslavko
... just to be sure to someone of 'right' ones see that post I duplicate post here.

Hello...

I was trying to change behaviour of (LOGOPEN, filename) feature to not
truncate file when oppened (to add)
As my knowledge with C is not good I can't manage to do in way I like
and to be good for others too.
My idea was to use (LOGOPEN, filename) as is and (LOGOPEN, filename,
append) to append to file.
But I can't find a way to do it. So After little twigeling I manage like
this:

(LOGOPEN, filename) as is
(LOGOPEN, _filename) to append to the file. (filename start's with
underscore)

and change was done in src/emc/task/emccanon.cc

the old way is:

void LOGOPEN(char *name) {
if(logfile) fclose(logfile);
logfile = fopen(name, "wt");
fprintf(stderr, "LOGOPEN(%s) -> %p\n", name, logfile);
}


changed to:

void LOGOPEN(char *name) {
if(logfile) fclose(logfile);
if (name[1] == '_') {
logfile = fopen(name, "at");
} else {
logfile = fopen(name, "wt");
}
fprintf(stderr, "LOGOPEN(%s) -> %p\n", name, logfile);
}


It's works. But can someone check if maybe I make something dumb, and to
update that in 2.5.0~pre? (probably comment in manual is good to have too)

Thanks
Slavko.

p.s.
What is 'correct' way to post such changes?!

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

More
01 Dec 2010 15:03 #5804 by andypugh
eslavko wrote:

What is 'correct' way to post such changes?!


email to the emc-dev mailing list and hope that someone there with commit access likes the idea.

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

More
01 Dec 2010 15:07 #5805 by BigJohnT
I think the developers prefer a git patch...

wiki.linuxcnc.org/cgi-bin/emcinfo.pl?Git..._changes_with_others

John

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

More
02 Dec 2010 16:58 #5817 by eslavko
I managed to add command (LOGAPPEND,filename) and posted patch in emc-developer maillist. Hopefuly someone will see that and apply..

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

More
03 Dec 2010 00:56 #5823 by andypugh
They did.

I am jealous, my patches hang about for months.

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

More
03 Dec 2010 07:52 #5832 by eslavko
andypugh wrote:

They did.

I am jealous, my patches hang about for months.


I just have luck two times.. (1'st time in life)
1. I managed to write that with my knowledge. (well in real I didn't write anithing, I just copy/paste few lines and change name :D. The hardest is what/where to do that. So simple operation but in 5 places to do.)
2. The patch is acepted.. :D

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

More
03 Dec 2010 12:45 #5835 by BigJohnT
Good job on the patch, you even updated the manual for me!

Thanks
John

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

Time to create page: 0.140 seconds
Powered by Kunena Forum