As a beginner in Pd, I'm also wondering what that means...
Hey IOhannes,
thank you, but could you please explain it a bit more in detail? I am not a complete newbie, but not so much into the pd-list speak. I searched in the list for the question, but there was no comprehensible solution shown... It's on pd extended 0.42.5 on Win XP.
best mirro
Hi list,
I wonder if there is a possibility to receive console messages within a
patch. Could be helpful, for instance, when there is a certain error that should immediately trigger a reaction.
Thanks for advice.
i guess there are some answers for that in the archives.
the simplest is probably still $ pd -stderr 2>&1 | pdsend 9999 localhost udp
and then have [netreceive 9999 1] listen for your output.
fgmasdr IOhannes --
I wonder if there is a possibility to receive console messages within a patch. Could be helpful, for instance, when there is a certain error that should immediately trigger a reaction. Thanks for advice.
I had made something specifically for that, that redirects the console messages in a way similar to how other languages have «try/catch» or «begin/rescue» keywords to trap errors.
http://artengine.ca/desiredata/gallery/unpost.gif
But this external would require a modification to pd that has been circulating on the net since 2003 and rejected by Miller in 2004.
Because Miller doesn't want features like that.
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
----- Original Message -----
From: Mathieu Bouchard matju@artengine.ca To: Vincent Kaschner kostrowitzky@gmx.de Cc: pd-list@iem.at; IOhannes m zmoelnig zmoelnig@iem.at Sent: Wednesday, November 16, 2011 8:53 PM Subject: Re: [PD] get console messages within patch
I wonder if there is a possibility to receive console messages
within a patch. Could be helpful, for instance, when there is a certain error that should immediately trigger a reaction. Thanks for advice.
I had made something specifically for that, that redirects the console messages in a way similar to how other languages have «try/catch» or «begin/rescue» keywords to trap errors.
http://artengine.ca/desiredata/gallery/unpost.gif
But this external would require a modification to pd that has been circulating on the net since 2003 and rejected by Miller in 2004.
What's the modification? Is it on the tracker?
Because Miller doesn't want features like that.
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC _______________________________________________ Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
Le 2011-11-16 à 18:06:00, Jonathan Wilkes a écrit :
From: Mathieu Bouchard matju@artengine.ca http://artengine.ca/desiredata/gallery/unpost.gif But this external would require a modification to pd that has been circulating on the net since 2003 and rejected by Miller in 2004.
What's the modification? Is it on the tracker?
Actually, I don't find it in the bug tracker nor the patch tracker.
Don't worry, it's somewhere in SourceForget.
...
Actually, you can find it in the devel_0_37 branch. This is what I used to implement the original Pd console. Then I submitted it to Miller (through pd-list). Then Miller ignored my code and rewrote it without using printhook and left out one or two features as well. I'm pretty sure he claimed that t_printhook was a bad or ugly design. That was in jan 2004 or so, but I only got to know about Miller's console in august when he unveiled pd 38.
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
----- Original Message -----
From: Mathieu Bouchard matju@artengine.ca To: Jonathan Wilkes jancsika@yahoo.com Cc: Vincent Kaschner kostrowitzky@gmx.de; "pd-list@iem.at" pd-list@iem.at; IOhannes m zmoelnig zmoelnig@iem.at Sent: Sunday, November 20, 2011 11:59 PM Subject: Re: [PD] get console messages within patch
Le 2011-11-16 à 18:06:00, Jonathan Wilkes a écrit :
From: Mathieu Bouchard matju@artengine.ca http://artengine.ca/desiredata/gallery/unpost.gif But this external would require a modification to pd that has been
circulating on the net since 2003 and rejected by Miller in 2004.
What's the modification? Is it on the tracker?
Actually, I don't find it in the bug tracker nor the patch tracker.
Don't worry, it's somewhere in SourceForget.
...
Actually, you can find it in the devel_0_37 branch. This is what I used to implement the original Pd console. Then I submitted it to Miller (through pd-list). Then Miller ignored my code and rewrote it without using printhook
What's printhook?
and left out one or two features as well. I'm pretty sure he claimed that t_printhook was a bad or ugly design. That was in jan 2004 or so, but I only got to know about Miller's console in august when he unveiled pd 38.
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
Le 2011-11-20 à 22:23:00, Jonathan Wilkes a écrit :
----- Original Message -----
From: Mathieu Bouchard matju@artengine.ca Le 2011-11-16 à 18:06:00, Jonathan Wilkes a écrit :
From: Mathieu Bouchard matju@artengine.ca http://artengine.ca/desiredata/gallery/unpost.gif But this external would require a modification to pd that has been
circulating on the net since 2003 and rejected by Miller in 2004.
What's the modification? Is it on the tracker?
Actually, I don't find it in the bug tracker nor the patch tracker. Don't worry, it's somewhere in SourceForget.
What's printhook?
It's the feature that redirects the formatted output of [print] and post() and error() to a single destination.
[unpost] changes this at runtime while keeping a backup, sends a message, and when the call returns, it restores the backup. That's all.
Here's the source code of [unpost] :
-----------------8<--------découpez-ici--------8<-----------------
static t_class *unpost_class; struct t_unpost : t_object { t_outlet *o0,*o1; }; struct t_unpost_frame { t_unpost *self; std::ostringstream buf; }; static t_unpost_frame *current_unpost;
void *unpost_new (t_symbol *s) { t_unpost *x = (t_unpost *)pd_new(unpost_class); x->o0 = outlet_new(x,&s_symbol); x->o1 = outlet_new(x,&s_symbol); return x; } extern t_printhook sys_printhook; void unpost_printhook (const char *s) { std::ostringstream &b = current_unpost->buf; b << s; const char *p; const char *d=b.str().data(),*dd=d; for (;;) { p = strchr(d,'\n'); if (!p) break; current_unpost->self->o1->send(gensym2(d,p-d)); d=p+1; } if (d!=dd) { char *q = strdup(d); /* well i could use memmove, but i'm not supposed to use strcpy because of overlap */ current_unpost->buf.clear(); current_unpost->buf << q; free(q); } } void unpost_anything (t_unpost *x, t_symbol *s, int argc, t_atom *argv) { t_printhook backup1 = sys_printhook; t_unpost_frame *backup2 = current_unpost; sys_printhook = unpost_printhook; current_unpost = new t_unpost_frame; current_unpost->self = x; x->o0->send(s,argc,argv); sys_printhook = backup1; current_unpost = backup2; }
| Mathieu BOUCHARD ----- téléphone : +1.514.383.3801 ----- Montréal, QC
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 2011-11-17 02:25, Vincent Kaschner wrote:
As a beginner in Pd, I'm also wondering what that means...
Hey IOhannes,
thank you, but could you please explain it a bit more in detail? I am not a complete newbie, but not so much into the pd-list speak. I searched in the list for the question, but there was no comprehensible solution shown... It's on pd extended 0.42.5 on Win XP.
sorry for talking gibberish.
i don't know much about Pd-extended and little about w32. i'll give it a try though:
$ pd -stderr 2>&1 | pdsend 9999 localhost udp
this basically means:
local machine.
the 2nd part of the line ("pdsend 9999 localhost udp") should be fairly obvious: it calls the pdsend program (on w32 it is called pdsend.exe and you might have to find out where it is - somewhere in the Pd\bin\ folder is a good guess), with some parameters, that specify the target port (9999), the target host (localhost, the machine the program is executed on) and the protocol (udp).
the 1st part is a bit more complicated, i'll come to it later. it basically grabs all messages printed by Pd.
the fun part is in the middle, "|" (aka 'pipe') takes the "output" of one program (in this case Pd) and uses it as "input" to another program (here: pdsend)
the slightly unorthodox part is the 1st one: we have to make Pd produce it's output in a form that is usable as input for pdsend. this basically means that instead of sending the printout to the pd-console, we have to redirect it to a special output, that is called "stdout" (pdsend will read from "stdin", and the pipe ("|") will magically transform the stdout of the 1st program to the stdin of the 2nd; see [1] for more information) Pd usually send s it output to the Pd-console. however, you can start it with a special cmdline flag, that will all messages to a special output, the "stderr" (see [1] again). if you start Pd from the console (the cmdline; on w32 this would be e.g. the "cmd" program), all messages sent to the stderr will show up on the console (note, that on w32 you will have to start pd.com rather than pd.exe, because else windows will prevent the stderr to be printed to the console). this is almost what we want (we are sending Pd's printout to some standard stream!), but we are not there yet (Pd sends to "stderr", whereas we want it to send to "stdout")
luckily enough, many cmdline interpreters have a special syntax for redirecting stdstreams. on bash (a common cmdline interpreter on un*x) and afaik on w32, you can do redirect the stderr of a program to the stdout using "2>&1" (stderr has a numeric file descriptor 2; stdout has a numeric file descriptor 1; so this redirection means: take filedescriptor 2 (stderr) and send it to filedescriptor 1 (stdout))
so the line i gave means: "pd" - start Pd, "-stderr" - but send all printout to stderr rather than the pdconsole "2>&1" - then redirect the stderr to stdout, "|" - pipe the stdout to the stdin "pdsend ..." - of pdsend, which will send the data (back to Pd)
hope that helps.
fgamrt IOhannes
[1] http://en.wikipedia.org/wiki/Standard_streams
best mirro
Hi list,
I wonder if there is a possibility to receive console messages within a
patch. Could be helpful, for instance, when there is a certain error that should immediately trigger a reaction.
Thanks for advice.
i guess there are some answers for that in the archives.
the simplest is probably still $ pd -stderr 2>&1 | pdsend 9999 localhost udp
and then have [netreceive 9999 1] listen for your output.
fgmasdr IOhannes --
2011/11/17 IOhannes m zmoelnig zmoelnig@iem.at
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 2011-11-17 02:25, Vincent Kaschner wrote:
As a beginner in Pd, I'm also wondering what that means...
Hey IOhannes,
thank you, but could you please explain it a bit more in detail? I am
not
a complete newbie, but not so much into the pd-list speak. I searched in the list for the question, but there was no comprehensible solution
shown...
It's on pd extended 0.42.5 on Win XP.
sorry for talking gibberish.
i don't know much about Pd-extended and little about w32. i'll give it a try though:
$ pd -stderr 2>&1 | pdsend 9999 localhost udp
this basically means:
- take the output of Pd, and send it (using pdsend) to port 9999 of the
local machine.
the 2nd part of the line ("pdsend 9999 localhost udp") should be fairly obvious: it calls the pdsend program (on w32 it is called pdsend.exe and you might have to find out where it is - somewhere in the Pd\bin\ folder is a good guess), with some parameters, that specify the target port (9999), the target host (localhost, the machine the program is executed on) and the protocol (udp).
the 1st part is a bit more complicated, i'll come to it later. it basically grabs all messages printed by Pd.
the fun part is in the middle, "|" (aka 'pipe') takes the "output" of one program (in this case Pd) and uses it as "input" to another program (here: pdsend)
the slightly unorthodox part is the 1st one: we have to make Pd produce it's output in a form that is usable as input for pdsend. this basically means that instead of sending the printout to the pd-console, we have to redirect it to a special output, that is called "stdout" (pdsend will read from "stdin", and the pipe ("|") will magically transform the stdout of the 1st program to the stdin of the 2nd; see [1] for more information) Pd usually send s it output to the Pd-console. however, you can start it with a special cmdline flag, that will all messages to a special output, the "stderr" (see [1] again). if you start Pd from the console (the cmdline; on w32 this would be e.g. the "cmd" program), all messages sent to the stderr will show up on the console (note, that on w32 you will have to start pd.com rather than pd.exe, because else windows will prevent the stderr to be printed to the console). this is almost what we want (we are sending Pd's printout to some standard stream!), but we are not there yet (Pd sends to "stderr", whereas we want it to send to "stdout")
luckily enough, many cmdline interpreters have a special syntax for redirecting stdstreams. on bash (a common cmdline interpreter on un*x) and afaik on w32, you can do redirect the stderr of a program to the stdout using "2>&1" (stderr has a numeric file descriptor 2; stdout has a numeric file descriptor 1; so this redirection means: take filedescriptor 2 (stderr) and send it to filedescriptor 1 (stdout))
so the line i gave means: "pd" - start Pd, "-stderr" - but send all printout to stderr rather than the pdconsole "2>&1" - then redirect the stderr to stdout, "|" - pipe the stdout to the stdin "pdsend ..." - of pdsend, which will send the data (back to Pd)
hope that helps.
fgamrt IOhannes
How do I get past "send: Connection refused (111)"?
gr, Tim
[1] http://en.wikipedia.org/wiki/Standard_streams
best mirro
Hi list,
I wonder if there is a possibility to receive console messages within a
patch. Could be helpful, for instance, when there is a certain error
that
should immediately trigger a reaction.
Thanks for advice.
i guess there are some answers for that in the archives.
the simplest is probably still $ pd -stderr 2>&1 | pdsend 9999 localhost udp
and then have [netreceive 9999 1] listen for your output.
fgmasdr IOhannes --
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
iEYEARECAAYFAk7ExbcACgkQkX2Xpv6ydvQVrgCgqNEW7N3V8vWSk8M01MLpDr22 jVcAoIFKLeGVp/g3+gV6K1wm4KuYH+Ri =0WOh -----END PGP SIGNATURE-----
Pd-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
On 2011-11-17 09:53, tim vets wrote:
How do I get past "send: Connection refused (111)"?
by re-reading my original email and adding a receiver ([netreceive]) within Pd, that listens on the port (and protocol) you specified with pdsend.
fgmasdr IOhannes