commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r4853 - in gnuradio/branches/developers/eb/ibu/pmt/src


From: eb
Subject: [Commit-gnuradio] r4853 - in gnuradio/branches/developers/eb/ibu/pmt/src: . lib scheme scheme/gnuradio
Date: Mon, 2 Apr 2007 23:58:29 -0600 (MDT)

Author: eb
Date: 2007-04-02 23:58:29 -0600 (Mon, 02 Apr 2007)
New Revision: 4853

Added:
   gnuradio/branches/developers/eb/ibu/pmt/src/scheme/
   gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/
   
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/gen_serial_tags.scm
   
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serial-tags.scm
   gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serialize.scm
Removed:
   gnuradio/branches/developers/eb/ibu/pmt/src/lib/gen_serial_tags.scm
   gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt-serialize.scm
   gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt_serial_tags.dat
Log:
Moved some things around.  I love svn!

Deleted: gnuradio/branches/developers/eb/ibu/pmt/src/lib/gen_serial_tags.scm

Deleted: gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt-serialize.scm

Deleted: gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt_serial_tags.dat

Copied: 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/gen_serial_tags.scm 
(from rev 4833, 
gnuradio/branches/developers/eb/ibu/pmt/src/lib/gen_serial_tags.scm)
===================================================================
--- 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/gen_serial_tags.scm 
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/gen_serial_tags.scm 
    2007-04-03 05:58:29 UTC (rev 4853)
@@ -0,0 +1,121 @@
+#!/usr/bin/guile \
+-e main -s
+!#
+;;; -*-scheme-*-
+;;;
+;;; Copyright 2007 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 2, 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, write to the Free Software Foundation, Inc.,
+;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+;;;
+
+(use-modules (ice-9 format))
+
+(defmacro when (pred . body)
+  `(if ,pred (begin ,@body) #f))
+
+;; ----------------------------------------------------------------
+
+(define (main args)
+
+  (define (usage)
+    (format 0
+           "usage: ~a <pmt_serial_tags.dat> <pmt_serial_tags.h> 
<pmt_serial_tags.scm>~%"
+           (car args)))
+
+  (when (not (= (length args) 4))
+       (usage)
+       (exit 1))
+      
+  (let ((i-file (open-input-file (cadr args)))
+       (h-file (open-output-file (caddr args)))
+       (scm-file (open-output-file (cadddr args))))
+
+      (write-header-comment h-file "// ")
+      (display "#ifndef INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
+      (display "#define INCLUDED_PMT_SERIAL_TAGS_H\n" h-file)
+      (newline h-file)
+      (display "enum pst_tags {\n" h-file)
+
+      (write-header-comment scm-file ";;; ")
+
+      (for-each-in-file i-file
+       (lambda (form)
+        (let* ((name (car form))
+               (c-name (string-upcase (c-ify name)))
+               (value (cadr form)))
+          ;;(format h-file   "static const int ~a\t= 0x~x;~%" c-name value)
+          (format h-file   "  ~a\t= 0x~x,~%" c-name value)
+          (format scm-file "(define ~a #x~x)~%" name value))))
+
+      (display "};\n" h-file)
+      (display "#endif\n" h-file)))
+
+(define (c-ify name)
+  (list->string (map (lambda (c)
+                      (if (eqv? c #\-) #\_ c))
+                    (string->list (symbol->string name)))))
+
+
+(define (write-header-comment o-port prefix)
+  (for-each (lambda (comment)
+             (format o-port "~a~a~%" prefix comment))
+           header-comment))
+
+(define header-comment
+  '(
+    ""
+    "Copyright 2007 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 2, 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, write to the Free Software Foundation, Inc.,"
+    "51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA."
+    ""
+    ""
+    "THIS FILE IS MACHINE GENERATED FROM pmt_serial_tags.dat. DO NOT EDIT BY 
HAND."
+    "See pmt_serial_tags.dat for additional commentary."
+    ""))
+
+
+
+(define (for-each-in-file file f)
+  (let ((port (if (port? file)
+                 file
+                 (open-input-file file))))
+    (letrec
+     ((loop
+       (lambda (port form)
+        (cond ((eof-object? form)
+               (when (not (eq? port file))
+                     (close-input-port port))
+               #t)
+              (else
+               (f form)
+               (set! form #f)          ; for GC
+               (loop port (read port)))))))
+     (loop port (read port)))))

Copied: 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serial-tags.scm 
(from rev 4839, 
gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt_serial_tags.dat)
===================================================================
--- 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serial-tags.scm 
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serial-tags.scm 
    2007-04-03 05:58:29 UTC (rev 4853)
@@ -0,0 +1,76 @@
+;;; -*-scheme-*-
+;;;
+;;; Copyright 2007 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 2, 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, write to the Free Software Foundation, Inc.,
+;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+;;;
+
+;;; definitions of tag values used for marshalling pmt data
+
+(pst-true              #x00)
+(pst-false             #x01)
+(pst-symbol            #x02)   ; untagged-int16 n; followed by n bytes of 
symbol name
+(pst-int32             #x03)
+(pst-double            #x04)
+(pst-complex           #x05)   ; complex<double>: real, imag
+(pst-null              #x06)
+(pst-pair              #x07)   ; followed by two objects
+(pst-vector            #x08)   ; untagged-int32 n; followed by n objects
+(pst-dict              #x09)   ; untagged-int32 n; followed by n key/value 
tuples
+
+(pst-uniform-vector    #x0a)
+
+;; u8, s8, u16, s16, u32, s32, u64, s64, f32, f64, c32, c64
+;;
+;;   untagged-uint8  tag
+;;   untagged-uint8  uvi (uniform vector info, see below)
+;;   untagged-int32  n-items
+;;   untagged-uint8  npad
+;;   npad bytes of zeros to align binary data
+;;   n-items binary numeric items
+;;
+;; uvi:
+;; +-+-+-+-+-+-+-+-+
+;; |B|   subtype   |
+;; +-+-+-+-+-+-+-+-+
+;;
+;; B == 0, numeric data is little-endian.
+;; B == 1, numeric data is big-endian.
+
+    (uvi-endian-mask    #x80)
+    (uvi-subtype-mask   #x7f)
+
+    (uvi-little-endian  #x00)
+    (uvi-big-endian     #x80)
+
+    (uvi-u8            #x00)
+    (uvi-s8            #x01)
+    (uvi-u16           #x02)
+    (uvi-s16           #x03)
+    (uvi-u32           #x04)
+    (uvi-s32           #x05)
+    (uvi-u64           #x06)
+    (uvi-s64           #x07)
+    (uvi-f32           #x08)
+    (uvi-f64           #x09)
+    (uvi-c32           #x0a)
+    (uvi-c64           #x0b)
+
+
+(pst-comment           #x3b)           ; ascii ';'
+(pst-comment-end       #x0a)           ; ascii '\n'
+

Copied: 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serialize.scm 
(from rev 4852, 
gnuradio/branches/developers/eb/ibu/pmt/src/lib/pmt-serialize.scm)
===================================================================
--- 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serialize.scm   
                            (rev 0)
+++ 
gnuradio/branches/developers/eb/ibu/pmt/src/scheme/gnuradio/pmt-serialize.scm   
    2007-04-03 05:58:29 UTC (rev 4853)
@@ -0,0 +1,45 @@
+;;;
+;;; Copyright 2007 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 2, 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, write to the Free Software Foundation, Inc.,
+;;; 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+;;;
+
+;;; An implementation of pmt_serialize in scheme.
+;;; Currently handles only symbols and pairs.  They're all we need for now.
+
+(load "pmt-serial-tags.scm")
+
+(define (pmt-serialize obj put-byte)
+  (define (put-u16 x)
+    (put-byte (logand (ash x -8) #xff))
+    (put-byte (logand x #xff)))
+    
+  (cond ((null? obj)
+        (put-byte pst-null))
+       ((symbol? obj)
+        (let* ((sym-as-bytes (map char->integer (string->list (symbol->string 
obj))))
+               (len (length sym-as-bytes)))
+          (put-byte pst-symbol)
+          (put-u16 len)
+          (for-each put-byte sym-as-bytes)))
+       
+       ((pair? obj)
+        (put-byte pst-pair)
+        (pmt-serialize (car obj) put-byte)
+        (pmt-serialize (cdr obj) put-byte))
+       (else
+        (throw 'not-implemented "pmt-serialize" obj))))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]