M17-Project / gr-m17

GNU Radio M17 protocol implementation
GNU General Public License v2.0
23 stars 5 forks source link

Demo transmitter generates invalid data #9

Closed sp5wwp closed 1 year ago

sp5wwp commented 1 year ago

Demo transmitter available in the examples directory - transmitterPLUTOSDR.grc - doesn't seem to correctly encode data. Additionally, a Throttle block is required in the flowgraph to make the RF stream decode at the receiver.

How to recreate:

Expected result:

Actual result:

jmfriedt commented 1 year ago

Throttle should never be included in GNU Radio Companion flowgraphs including real hardware as the coarse CPU timing limitation of the Throttle block will conflict with the hardware clock of the Pluto Sink. See the Throttle block Documentation:

"N.B. this should only be used in GUI apps where there is no other rate limiting block. It is not intended nor effective at precisely controlling the rate of samples. That should be controlled by a source or sink tied to sample clock. E.g., a USRP or audio card."

The sink datarate (or RRC and Resampler) should be tuned for the m17_coder to be fed with the expected datarate from the Vector Source.

sp5wwp commented 1 year ago

Yes, I am aware of all that, but for some reason the RF stream generated by a flowgraph with throttle bypassed doesn't even decode in SDR++. All I get is an excellent looking RF signal, but no decode.

argilo commented 1 year ago

For one thing, the forecast function is incorrect:

https://github.com/M17-Project/gr-m17/blob/cbd0e352fde525bf231d07ffa92e4d4eba082bde/lib/m17_coder_impl.cc#L370-L374

16 input bytes produces 192 output symbols, not 384, so the ratio should be 12.

Next, the work function uses a do loop to do its work, checking whether there is sufficient space for a frame only after completing one iteration. If the output buffer is shorter than 192 items, a buffer overrun occurs. Switching to a while loop and putting the condition at the top should fix that.

Since frames are always 192 symbols, the block should just set its output multiple to 192.

argilo commented 1 year ago

I fixed these bugs, removed the throttle from the PLUTO transmitter, and added a missing "Pack K Bits" block, and now the transmitter appears to be working properly.

sp5wwp commented 1 year ago

Confirmed, fixed.