Comments (5)
Hello @Timvrakas,
I'm surprised by the error you get as the string generated and passed as a pmt symbol comes directly from the concatenation of uint8_t which should all be valid UTF-8 characters. What happens if you connect the output to the print input of a "Message Debug" block?
The "CRC verif" can also output directly the bytes as a stream. Outputting vectors of bytes is tricky as the size of this vector might be different for each frame (in explicit header mode) but the output size has to be already known by the constructor and I'm not aware of a gnuradio block that allows variable output/input vector length.
from gr-lora_sdr.
That explains why a vector of bytes is not used, thanks.
When I use the "Message Debug" block, the message prints like this:
******* MESSAGE DEBUG PRINT ********
��Hello World
************************************
The invalid UTF is rendered as ??
However, when I try to process with a Python Block:
class print_hex(gr.basic_block):
def __init__(self):
gr.basic_block.__init__(
self,
name="print_hex",
in_sig=None,
out_sig=None)
self.message_port_register_in(pmt.intern('msg_in'))
self.set_msg_handler(pmt.intern('msg_in'), self.handle_msg)
def handle_msg(self, msg):
print(msg.is_symbol())
print(msg)
I get the following:
True
thread_body_wrapper :error: ERROR thread[thread-per-block[14]: <block print_hex(12)>]: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
I can't seem to interpret the symbol as anything other than an encoded string. I suspect if I write a C++ block, I could handle the string as binary data and won't have an issue, but I wonder if it's possible to do this in Python. Does the PMT "Blob" type also require a fixed length defined ahead of time?
Does the stream of bytes interface include tags to mark the start and/or end of a packet, and CRC validity?
from gr-lora_sdr.
I see the byte stream is tagged:
Tag Debug:
Input Stream: 00
Offset: 17 Source: n/a Key: frame_info Value: ((err . 0) (ldro_mode . 1) (crc . 1) (pay_len . 54) (cr . 4))
Does err
include CRC errors?
I feel this may be the most "GNURadio" appropriate solution, rather than passing the payload as messages.
from gr-lora_sdr.
Hi,
The tag debug block has no issue recovering the string, it prints ?? for ascii symbols that are not printable (but their value should be correct). I've never tried to recover a message generated by a c++ block directly in python so I don't know if this can cause your issue.
Regarding the blob, I never used it but you should probably be able to quickly try it by changing the line with the "message_port_pub" to use a blob based on message_str.data() and message_str.length() instead of directly using the string.
The tags are currently only used for the input of the crc verif block and I should have disable their propagation as their offset won't be correct at the output. The "err" only indicates header errors.
Based on what you say, I think the most practical implementation would be:
- a stream of bytes with tags indicating beginning, number of bytes and CRC result.
- a message output containing a dictionary with keys: payload_as_blob, payload_as_string, payload_length, and crc_valid.
from gr-lora_sdr.
I got this working using tags and the byte stream output. Here's my python block for future reference:
import numpy as np
from gnuradio import gr
import pmt
class print_hex(gr.basic_block):
def __init__(self):
gr.basic_block.__init__(
self,
name="print_hex",
in_sig=[np.byte],
out_sig=None)
def general_work(self, input_items, output_items):
"""example: multiply with constant"""
tags = self.get_tags_in_window(0, 0, len(input_items[0]))
for tag in tags:
print(f'Tag Key: {tag.key}')
print(f'Tag Value: {tag.value}')
print(f'Tag Offset: {tag.offset}')
print(f'Read offset: {self.nitems_read(0)}')
pay_len_pmt = pmt.dict_ref(tag.value, pmt.intern("pay_len"), pmt.PMT_NIL)
pay_len = pmt.to_python(pay_len_pmt)
print(f'Payload Length: {pay_len}')
print(f'Buffer Length: {len(input_items[0])}')
print(input_items[0][(tag.offset-self.nitems_read(0)):(tag.offset-self.nitems_read(0)+pay_len)])
self.consume(0,pay_len)
return(0)
from gr-lora_sdr.
Related Issues (20)
- Implementing encoder and decoder with smaller SF 2-6 HOT 9
- getting nothing terminal window after running setup HOT 18
- PREAMBLE, SYNC WORD and LDRO HOT 6
- HackRF CRC issues HOT 3
- Erroneous Decoding for LDRO Enabled Transmissions HOT 1
- Error `include could not find requested file:` HOT 1
- ModuleNotFoundError even after loading PYTHONPATH HOT 2
- Chirps not appearing in Waterfall HOT 8
- RE:getting nothing terminal window after running setup HOT 6
- GNU Radio3.8.3.1 HOT 3
- Error when increasing spreading factor. HOT 4
- Cannot use a file source to replace USRP source HOT 12
- USRP not working HOT 6
- can’t recv LLCC68 message HOT 2
- Difficulties decoding meshtastic HOT 5
- Performance of cyl_bessel_i() on a low-powered arm64 device HOT 4
- Trouble receiving real-time signals HOT 5
- how to get rssi HOT 1
- Can't decode a signal HOT 8
- InvalidSpec: The package "conda-forge/noarch::adwaita-icon-theme==41.0=ha770c72_1" is not available for the specified platform HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gr-lora_sdr.