diff options
author | Eric Blossom | 2010-12-02 17:27:36 -0800 |
---|---|---|
committer | Eric Blossom | 2010-12-02 17:27:36 -0800 |
commit | 9d91d36c7e509928705f093935024d08d2c019c8 (patch) | |
tree | 39766aae3df6a539bb369ffc61740512ee550e7a | |
parent | 09dc1cd6928d1c32cf06509a8b81202e11bcf3a4 (diff) | |
download | gnuradio-9d91d36c7e509928705f093935024d08d2c019c8.tar.gz gnuradio-9d91d36c7e509928705f093935024d08d2c019c8.tar.bz2 gnuradio-9d91d36c7e509928705f093935024d08d2c019c8.zip |
Move guts of gr-run-waveform into gnuradio/run-waveform.scm
-rw-r--r-- | gnuradio-core/src/guile/Makefile.am | 1 | ||||
-rw-r--r-- | gnuradio-core/src/guile/gnuradio/run-waveform.scm | 53 | ||||
-rwxr-xr-x | gr-guile/apps/gr-run-waveform | 40 |
3 files changed, 62 insertions, 32 deletions
diff --git a/gnuradio-core/src/guile/Makefile.am b/gnuradio-core/src/guile/Makefile.am index 4e12b646d..50d46411a 100644 --- a/gnuradio-core/src/guile/Makefile.am +++ b/gnuradio-core/src/guile/Makefile.am @@ -41,6 +41,7 @@ nobase_guile_DATA = \ gnuradio/export-safely.scm \ gnuradio/runtime-shim.scm \ gnuradio/waveform.scm \ + gnuradio/run-waveform.scm \ gnuradio/test-suite/guile-test \ gnuradio/test-suite/lib.scm diff --git a/gnuradio-core/src/guile/gnuradio/run-waveform.scm b/gnuradio-core/src/guile/gnuradio/run-waveform.scm new file mode 100644 index 000000000..3a2c4e6b7 --- /dev/null +++ b/gnuradio-core/src/guile/gnuradio/run-waveform.scm @@ -0,0 +1,53 @@ +;;; +;;; Copyright 2010 Free Software Foundation, Inc. +;;; +;;; This file is part of GNU Radio +;;; +;;; GNU Radio is free software; you can redistribute it and/or modify +;;; it under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3, or (at your option) +;;; any later version. +;;; +;;; GNU Radio is distributed in the hope that it will be useful, +;;; but WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with this program. If not, see <http://www.gnu.org/licenses/>. +;;; + +;;; Load and run a waveform defined with define-waveform + + +;; I don't seem to be able to make this work... +;; I think it's some kind of interaction with the syntax-case +;; macro, define-waveform, and the module system. +;; +;;(define-module (gnuradio run-waveform) +;; #:use-module (oop goops) +;; #:use-module (gnuradio core) +;; #:use-module (gnuradio waveform) +;; #:duplicates (merge-generics replace check)) + +(use-modules (oop goops) + (gnuradio core) + (gnuradio waveform)) + + +(define (load-into-module filename module) + (let ((f (open-file filename "r"))) + (let loop ((form (read f))) + (cond ((eof-object? form) #t) + (else (eval form module) + (loop (read f))))))) + + +(define-public (run-waveform waveform-filename . args) + (debug-enable 'backtrace 'debug) + (load waveform-filename) + ;;(load-into-module waveform-filename (current-module)) + (let ((f (waveform-last-registered))) + (if (not f) + (error "No define-waveform found in file \n" filename) + (gr:run (f args))))) diff --git a/gr-guile/apps/gr-run-waveform b/gr-guile/apps/gr-run-waveform index a8d1d0389..555956c70 100755 --- a/gr-guile/apps/gr-run-waveform +++ b/gr-guile/apps/gr-run-waveform @@ -22,42 +22,18 @@ ;;; Load and run a waveform defined with define-waveform ;;; -;;; usage: gr-run-waveform filename.wfd +;;; usage: gr-run-waveform filename.wfd [args...] - -(use-modules (oop goops) - (gnuradio core) - (gnuradio waveform)) - - -(define (enable-debug-mode) - (display %load-path) - (newline) - (set! %load-verbosely #t) - (debug-enable 'backtrace 'debug)) - -(define (usage args) - (let ((port (current-error-port))) - (display "usage: " port) - (display (car args) port) - (newline port) - (exit 1))) - +(load-from-path "gnuradio/run-waveform") (define (main args) (if (not (>= (length args) 2)) - (usage args)) - (enable-debug-mode) - (let ((filename (cadr args))) - ;; Probably ought to handle errors here - (load filename) - (let ((f (waveform-last-registered))) - (if (not f) - (begin - (format 1 "No define-waveform found in file '~A'\n" filename) - (exit 1))) - (gr:run (f (cdr args)))))) - + (let ((port (current-error-port))) + (display "usage: " port) + (display (car args) port) + (display " filename.wfd [args...]\n" port) + (exit 1))) + (apply run-waveform (cdr args))) ;;; Local Variables: ;;; mode: scheme |