gEDA-dev: Troubles with controlling PCB over a pipe

Peter TB Brett peter at peter-b.co.uk
Mon Aug 28 14:34:04 EDT 2006


Hi folks,

I'm working on controlling PCB over a pipe from another program using 
PCB's --listen option.

Now, it was all going fine, but then I hit an insurmountable barrier.  I 
needed to know when PCB had completed an operation: specifically, writing the 
current layout to a file.  What I wanted to do was the following:

 - Save the current layout
 - Mess with the layout
 - Get PCB to reload the layout

Even though I can send in the command to write the file, there's no way to 
find out when the command's completed.  I can't just read PCB's stdout until 
I find an 'I saved to a file', for two reasons: if I don't keep reading PCB's 
stdout all the time, I'll hang PCB because writing to a pipe is a blocking 
operation, so I'd have to have a 'keep PCB happy' thread; and if I do 
implement such a thread, how do I get it to distinguish between saving 
because the user told it to and saving because I told it to?

In an ideal world where pipes are the only way of doing IPC, when in --listen 
mode PCB should not generate *any* output on stdout other than "OK\n" if an 
action passed into stdin succeeds and "ERR <string>\n" if an action fails 
(this way other PCB error messages can still be output on stderr where they 
belong).  This would give a good way of finding out (a) when an action has 
completed and (b) if it completed successfully.  Also it would make it easier 
of the program that's automating PCB to present meaningful error messages. 
How much work would this entail?

Of course, an even better solution would be for me to use a "real" IPC library 
to talk to PCB, but unfortunately that's currently not possible.

Another slight bugbear is that actions passed in on stdin can generate dialog 
boxes which the user has to click, and there's no way to check if the user 
clicked something which stopped your action from being executed.

Peter

P.S. One idea that occurred to me while typing this e-mail is to get PCB to 
save the layout to a *different* file, and then wait until that file exists.  
Unfortunately, I'd still have no guarantee that PCB has *finished* writing to 
the file before I try and load it and mess about with it, so that's not 
really a workable solution.

-- 
Fisher Society publicity officer            http://tinyurl.com/o39w2
CUSBC novices, match and league secretary   http://tinyurl.com/mwrc9
Quake II build tools maintainer             http://tinyurl.com/fkldd

v3sw6YChw7$ln3pr6$ck3ma8u7+Lw3+2m0l7Ci6e4+8t4Gb8en6g6Pa2Xs5Mr4p4
  hackerkey.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://www.seul.org/pipermail/geda-dev/attachments/20060828/a47f8006/attachment.pgp


More information about the geda-dev mailing list