[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Discuss-gnuradio] Passing file descriptors via SWIG
From: |
Martin Braun |
Subject: |
[Discuss-gnuradio] Passing file descriptors via SWIG |
Date: |
Fri, 13 Mar 2009 13:49:31 +0100 |
User-agent: |
Mutt/1.5.17 (2007-11-01) |
Hi,
following
http://lists.gnu.org/archive/html/discuss-gnuradio/2009-02/msg00400.html,
I tried connecting two processes with a FIFO using gr.file_descriptor_*.
However, I can't seem to pass the file descriptor from the Python to the
C++ domain. This is the error message I get:
gr_file_descriptor_sink: Bad file descriptor
This is the code (pipe1 was created by using 'mkfifo pipe1'):
Source-File:
<<< SNIP >>>
from gnuradio import gr
class sig_source(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
src = gr.sig_source_f(8000, gr.GR_SIN_WAVE, 2000, 1.0)
head = gr.head(gr.sizeof_float, 8000)
print "Opening pipe..."
fid = open('pipe1', 'wb')
print "Done. fileno: ", fid.fileno()
sink = gr.file_descriptor_sink(gr.sizeof_float, fid.fileno())
self.connect(src, head, sink)
if __name__ == '__main__':
try:
sig_source().run()
except KeyboardInterrupt:
pass
<<< SNIP >>>
Sink:
<<< SNIP >>>
from gnuradio import gr
class sig_sink(gr.top_block):
def __init__(self):
gr.top_block.__init__(self)
print "Opening pipe..."
fid = open('pipe1', 'rb')
print "Done. fileno: ", fid.fileno()
src = gr.file_descriptor_source(gr.sizeof_float, fid.fileno())
self.sink = gr.vector_sink_f()
self.connect(src, self.sink)
if __name__ == '__main__':
try:
sigsnk = sig_sink()
sigsnk.run()
print sigsnk.sink.data()[0:4]
except KeyboardInterrupt:
pass
<<< SNIP >>>
When I start both scripts, this is what I get:
Opening pipe...
Done. fileno: 3
file_descriptor_source[read]: Bad file descriptor
on both the write and read ends of the pipe. This does work when I open
the pipe with gr_file_sink, but then I have to think about the
buffering.
Has anyone ever done this and could drop me some example code that
works? I'd really appreciate it...
Cheers
MB
--
Dipl.-Ing. Martin Braun Phone: +49-(0)721-608 3790
Institut fuer Nachrichtentechnik Fax: +49-(0)721-608 6071
Universitaet Karlsruhe (TH) http://www.int.uni-karlsruhe.de/
pgpWd7HKtnHkO.pgp
Description: PGP signature
- [Discuss-gnuradio] Passing file descriptors via SWIG,
Martin Braun <=