diff --git a/grc/m17_m17_coder.block.yml b/grc/m17_m17_coder.block.yml index 3c9ccec..07cf20e 100644 --- a/grc/m17_m17_coder.block.yml +++ b/grc/m17_m17_coder.block.yml @@ -10,11 +10,11 @@ parameters: - id: src_id label: Source ID dtype: string - default: '01.02.03.04.05.06' + default: 'EMITTR' - id: dst_id label: Destination ID dtype: string - default: '255.255.255.255.255.255' + default: 'RECVER' - id: type label: Type dtype: int @@ -30,7 +30,7 @@ parameters: options: ['True', 'False'] asserts: - - ${type<256} + - ${ type < 65536 } templates: imports: from gnuradio import m17 make: m17.m17_coder(${src_id},${dst_id},${type},${meta},${samp_rate},${debug}) @@ -64,7 +64,7 @@ outputs: optional: 0 documentation: |- - The m17-coder block reads a byte datastream clocked (samp_rate) at 4800 bits/s and will output a real stream at 24 times this input rate. The source and destination fields are 6-bytes separated by a dot, the type field is a 0-255 value and the meta field a free string which can be updated during transmission. + The m17-coder block reads a byte datastream clocked (samp_rate) at 200 bits/s and will output a real stream at 24 times this input rate. The source and destination fields are 6-character strings, the type field is a 0-255 value and the meta field a free string which can be updated during transmission. # 'file_format' specifies the version of the GRC yml format used in the file # and should usually not be changed. diff --git a/include/gnuradio/m17/m17_coder.h b/include/gnuradio/m17/m17_coder.h index 803949c..0c852e2 100644 --- a/include/gnuradio/m17/m17_coder.h +++ b/include/gnuradio/m17/m17_coder.h @@ -33,11 +33,20 @@ public: * creating new instances. */ static sptr make(std::string src_id,std::string dst_id,short type,std::string meta,float samp_rate,bool debug); +/* virtual void set_meta(std::string meta)=0; virtual void set_src_id(std::string src_id)=0; virtual void set_dst_id(std::string dst_id)=0; virtual void set_samp_rate(float samp_rate)=0; virtual void set_debug(bool debug)=0; + virtual void set_type(short type)=0; +*/ + void set_meta(std::string meta); + void set_src_id(std::string src_id); + void set_dst_id(std::string dst_id); + void set_samp_rate(float samp_rate); + void set_debug(bool debug); + void set_type(short type); }; } // namespace m17 diff --git a/include/gnuradio/m17/m17_decoder.h b/include/gnuradio/m17/m17_decoder.h index 93d02ae..af0faa6 100644 --- a/include/gnuradio/m17/m17_decoder.h +++ b/include/gnuradio/m17/m17_decoder.h @@ -33,8 +33,12 @@ public: * creating new instances. */ static sptr make(bool debug_data,bool debug_ctrl); +/* virtual void set_debug_data(bool debug)=0; virtual void set_debug_ctrl(bool debug)=0; +*/ + void set_debug_data(bool debug); + void set_debug_ctrl(bool debug); }; } // namespace m17 diff --git a/lib/m17_coder_impl.cc b/lib/m17_coder_impl.cc index a0d9edd..8aefa10 100644 --- a/lib/m17_coder_impl.cc +++ b/lib/m17_coder_impl.cc @@ -274,7 +274,7 @@ uint16_t LSF_CRC(struct LSF *in) : gr::block("m17_coder", gr::io_signature::make(1, 1, sizeof(char)), gr::io_signature::make(1, 1, sizeof(float))) - ,_meta(meta), _samp_rate(samp_rate), _debug(debug) + ,_samp_rate(samp_rate), _meta(meta),_type(type), _debug(debug) { set_meta(meta); set_src_id(src_id); set_dst_id(dst_id); @@ -299,31 +299,47 @@ void m17_coder_impl::set_debug(bool debug) } void m17_coder_impl::set_src_id(std::string src_id) -{for (int i=0;i<6;i++) {_src_id[i]=0;} - sscanf(src_id.c_str(), "%hhu.%hhu.%hhu.%hhu.%hhu.%hhu", &_src_id[0], &_src_id[1], &_src_id[2], &_src_id[3],&_src_id[4],&_src_id[5]); +{int length; + for (int i=0;i<6;i++) {_src_id[i]=' ';} + if (src_id.length()>6) length=6; else length=src_id.length(); + for (int i=0;i>8; + lsf.crc[1]=ccrc&0xFF; + printf("new SRC ID: %c%c%c%c%c%c\n",_src_id[0],_src_id[1],_src_id[2],_src_id[3],_src_id[4],_src_id[5]);fflush(stdout); } void m17_coder_impl::set_dst_id(std::string dst_id) -{for (int i=0;i<6;i++) {_dst_id[i]=0;} - sscanf(dst_id.c_str(), "%hhu.%hhu.%hhu.%hhu.%hhu.%hhu", &_dst_id[0], &_dst_id[1], &_dst_id[2], &_dst_id[3],&_dst_id[4],&_dst_id[5]); +{int length; + for (int i=0;i<6;i++) {_dst_id[i]=0;} + if (dst_id.length()>6) length=6; else length=dst_id.length(); + for (int i=0;i>8; + lsf.crc[1]=ccrc&0xFF; + printf("new DST ID: %c%c%c%c%c%c\n",_dst_id[0],_dst_id[1],_dst_id[2],_dst_id[3],_dst_id[4],_dst_id[5]);fflush(stdout); } void m17_coder_impl::set_meta(std::string meta) {int length; printf("new meta: %s\n",meta.c_str());fflush(stdout); - _meta=meta; + _meta.assign(meta); if (meta.length()<14) length=meta.length(); else length=14; for (int i=0;i>8; + lsf.crc[1]=ccrc&0xFF; } void m17_coder_impl::set_type(short type) {_type=type; - lsf.type[0]=_type&0xff; - lsf.type[1]=_type>>8; + lsf.type[0]=_type>>8; // MSB + lsf.type[1]=_type&0xff; // LSB + uint16_t ccrc=LSF_CRC(&lsf); + lsf.crc[0]=ccrc>>8; + lsf.crc[1]=ccrc&0xFF; printf("new type: %hhd %hhd\n",lsf.type[1],lsf.type[0]);fflush(stdout); } diff --git a/lib/m17_coder_impl.h b/lib/m17_coder_impl.h index da8bb74..5fdbe8a 100644 --- a/lib/m17_coder_impl.h +++ b/lib/m17_coder_impl.h @@ -26,8 +26,8 @@ private: public: - void set_src_id(std::string meta); - void set_dst_id(std::string meta); + void set_src_id(std::string src_id); + void set_dst_id(std::string dst_id); void set_samp_rate(float samp_rate); void set_meta(std::string meta); void set_type(short type); diff --git a/python/m17/bindings/m17_coder_python.cc b/python/m17/bindings/m17_coder_python.cc index 92f6b56..9cbba31 100644 --- a/python/m17/bindings/m17_coder_python.cc +++ b/python/m17/bindings/m17_coder_python.cc @@ -11,10 +11,10 @@ /* This file is automatically generated using bindtool and can be manually edited */ /* The following lines can be configured to regenerate this file during cmake */ /* If manual edits are made, the following tags should be modified accordingly. */ -/* BINDTOOL_GEN_AUTOMATIC(0) */ -/* BINDTOOL_USE_PYGCCXML(0) */ +/* BINDTOOL_GEN_AUTOMATIC(1) */ +/* BINDTOOL_USE_PYGCCXML(1) */ /* BINDTOOL_HEADER_FILE(m17_coder.h) */ -/* BINDTOOL_HEADER_FILE_HASH(c70d84b69c542c130371d582918a0457) */ +/* BINDTOOL_HEADER_FILE_HASH(7c3c43fefced882d5d1e91dd86246916) */ /***********************************************************************************/ #include diff --git a/python/m17/bindings/m17_decoder_python.cc b/python/m17/bindings/m17_decoder_python.cc index 7525d1c..bd71b74 100644 --- a/python/m17/bindings/m17_decoder_python.cc +++ b/python/m17/bindings/m17_decoder_python.cc @@ -14,7 +14,7 @@ /* BINDTOOL_GEN_AUTOMATIC(0) */ /* BINDTOOL_USE_PYGCCXML(0) */ /* BINDTOOL_HEADER_FILE(m17_decoder.h) */ -/* BINDTOOL_HEADER_FILE_HASH(65dad00081eedbe437e95b036b53a10f) */ +/* BINDTOOL_HEADER_FILE_HASH(1272f56a1d826511e7890e4080bcd62c) */ /***********************************************************************************/ #include