diff options
author | Rob Savoye | 2010-11-27 10:25:37 -0700 |
---|---|---|
committer | Rob Savoye | 2010-11-27 10:25:37 -0700 |
commit | edddbb1a182983c2ec2a55bbafe30a119cc0b994 (patch) | |
tree | 7662b551ecf2d21a3435e07a0e3c33e0c9279cb5 /gr-run-waveform | |
parent | b5a8b6fdf5596123ecd2e7bcfb346945247db742 (diff) | |
download | gnuradio-edddbb1a182983c2ec2a55bbafe30a119cc0b994.tar.gz gnuradio-edddbb1a182983c2ec2a55bbafe30a119cc0b994.tar.bz2 gnuradio-edddbb1a182983c2ec2a55bbafe30a119cc0b994.zip |
start getting I/O ports to work
Diffstat (limited to 'gr-run-waveform')
-rw-r--r-- | gr-run-waveform/xyzzy.cc | 26 | ||||
-rw-r--r-- | gr-run-waveform/xyzzy.h | 2 |
2 files changed, 19 insertions, 9 deletions
diff --git a/gr-run-waveform/xyzzy.cc b/gr-run-waveform/xyzzy.cc index 807824a4c..999282359 100644 --- a/gr-run-waveform/xyzzy.cc +++ b/gr-run-waveform/xyzzy.cc @@ -128,7 +128,10 @@ XYZZY::file_exists(const std::string &filespec) SCM XYZZY::make_read_only_port(const std::string &filespec) { - scm_t_bits bits = scm_make_port_type("gnuradio", xyzzy_fill_input, xyzzy_write); + // scm_t_bits bits = scm_make_port_type(const_cast<char *>(filespec.c_str()), + // xyzzy_fill_input, xyzzy_write); + char *foo = "foo"; + scm_t_bits bits = scm_make_port_type(foo, 0, 0); scm_set_port_flush (bits, xyzzy_flush); scm_set_port_close (bits, xyzzy_close); } @@ -238,15 +241,20 @@ int xyzzy_fill_input (SCM port) { scm_t_port *gr_port = SCM_PTAB_ENTRY (port); - if (gr_port->read_pos + gr_port->read_buf_size > gr_port->read_end) { - return EOF; - } - - // if (_contents.empty()) { - // gr_port->read_buf; // = datafile.file_exists("FOO"); - // gr_port->read_end = gr_port->read_buf + gr_port->read_buf_size; - // gr_port->read_pos += gr_port->read_buf_size; + + // if (gr_port->read_pos + gr_port->read_buf_size > gr_port->read_end) { + // return EOF; // } + + std::string &contents = datafile.get_contents(""); + if (contents.empty()) { + // buffer start. + gr_port->read_buf = const_cast<unsigned char *>(gr_port->read_pos); + // pointer to last buffered char + 1 + gr_port->read_end = gr_port->read_buf + gr_port->read_buf_size; + // the next unread char. + gr_port->read_pos += gr_port->read_buf_size; + } return *gr_port->read_buf; } diff --git a/gr-run-waveform/xyzzy.h b/gr-run-waveform/xyzzy.h index 5bdb531e9..2306eabf4 100644 --- a/gr-run-waveform/xyzzy.h +++ b/gr-run-waveform/xyzzy.h @@ -99,6 +99,8 @@ public: boost::shared_ptr<struct directory_entry> read_dir_entry(boost::uint8_t *header); + std::string &get_contents(const std::string &filespec) { return _contents[filespec]; }; + private: std::string _filespec; std::map<std::string, std::string> _contents; |