diff options
-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 4e12b646da..50d46411a3 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 0000000000..3a2c4e6b7e --- /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 a8d1d03895..555956c70a 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 |