summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/lib/general/gr_annotator_raw.cc2
-rw-r--r--gruel/src/lib/pmt/pmt-serial-tags.scm1
-rw-r--r--gruel/src/lib/pmt/pmt_serialize.cc38
3 files changed, 40 insertions, 1 deletions
diff --git a/gnuradio-core/src/lib/general/gr_annotator_raw.cc b/gnuradio-core/src/lib/general/gr_annotator_raw.cc
index 074c09173..e1ae73efb 100644
--- a/gnuradio-core/src/lib/general/gr_annotator_raw.cc
+++ b/gnuradio-core/src/lib/general/gr_annotator_raw.cc
@@ -66,7 +66,7 @@ void gr_annotator_raw::add_tag(uint64_t offset, pmt_t key, pmt_t val)
std::sort(d_queued_tags.begin(), d_queued_tags.end(),
gr_tag_t::offset_compare);
// make sure we are not adding an item in the past!
- if(tag.offset >= nitems_read(0)) {
+ if(tag.offset > nitems_read(0)) {
throw std::runtime_error("gr_annotator_raw::add_tag: item added too far in the past\n.");
}
}
diff --git a/gruel/src/lib/pmt/pmt-serial-tags.scm b/gruel/src/lib/pmt/pmt-serial-tags.scm
index a78d87681..4f06bf75f 100644
--- a/gruel/src/lib/pmt/pmt-serial-tags.scm
+++ b/gruel/src/lib/pmt/pmt-serial-tags.scm
@@ -34,6 +34,7 @@
(define pst-uniform-vector #x0a)
(define pst-uint64 #x0b)
+(define pst-tuple #x0c)
;; u8, s8, u16, s16, u32, s32, u64, s64, f32, f64, c32, c64
;;
diff --git a/gruel/src/lib/pmt/pmt_serialize.cc b/gruel/src/lib/pmt/pmt_serialize.cc
index 05140bb42..3c62b01f6 100644
--- a/gruel/src/lib/pmt/pmt_serialize.cc
+++ b/gruel/src/lib/pmt/pmt_serialize.cc
@@ -213,6 +213,25 @@ deserialize_untagged_f64(double *ip, std::streambuf &sb)
return t != std::streambuf::traits_type::eof();
}
+static bool
+deserialize_tuple(pmt_t *tuple, std::streambuf &sb)
+{
+ uint32_t nitems;
+ bool ok = deserialize_untagged_u32(&nitems, sb);
+ pmt_t list(PMT_NIL);
+ for(uint32_t i=0; i<nitems; i++){
+ pmt_t item = pmt_deserialize( sb );
+ pmt_print(item);
+ if(pmt_eq(list, PMT_NIL)){
+ list = pmt_list1(item);
+ } else {
+ list = pmt_list_add(list, item);
+ }
+ }
+ (*tuple) = pmt_to_tuple(list);
+ return ok;
+}
+
/*
* Write portable byte-serial representation of \p obj to \p sb
@@ -300,6 +319,16 @@ pmt_serialize(pmt_t obj, std::streambuf &sb)
if (pmt_is_dict(obj))
throw pmt_notimplemented("pmt_serialize (dict)", obj);
+ if (pmt_is_tuple(obj)){
+ size_t tuple_len = pmt::pmt_length(obj);
+ ok = serialize_untagged_u8(PST_TUPLE, sb);
+ ok &= serialize_untagged_u32(tuple_len, sb);
+ for(size_t i=0; i<tuple_len; i++){
+ ok &= pmt_serialize(pmt_tuple_ref(obj, i), sb);
+ }
+ return ok;
+ }
+ //throw pmt_notimplemented("pmt_serialize (tuple)", obj);
throw pmt_notimplemented("pmt_serialize (?)", obj);
}
@@ -369,6 +398,15 @@ pmt_deserialize(std::streambuf &sb)
goto error;
return pmt_make_rectangular( r,i );
}
+
+ case PST_TUPLE:
+ {
+ pmt_t tuple;
+ if(!deserialize_tuple(&tuple, sb)){
+ goto error;
+ }
+ return tuple;
+ }
case PST_VECTOR:
case PST_DICT: