Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SX126x/SX128x] Start reading from Rx buffer offset #1185

Merged
merged 4 commits into from
Aug 10, 2024

Conversation

GUVWAF
Copy link
Contributor

@GUVWAF GUVWAF commented Aug 10, 2024

As discussed in #1159 and similar to #1184, this will let SX126x and SX128x radios read the data in its buffer from the offset as returned by GetRxBufferStatus in order to match the data with the returned packet length of the last packet in case you skipped reading a packet. The behaviour is the same for both radios and this is the relevant part of the datasheet:

Two possibilities exist to obtain the offset value:
•First is to use the RxBaseAddr value since the user defines it before receiving a payload.
•Second, offset can be initialized with the value of RxStartBufferPointer returned by GetRxbufferStatus(...) command.
Note:
(...) When receiving, if the packet size exceeds the buffer memory allocated for the Rx, it will overwrite the
transmit portion of the data buffer.

So we're now changing to the second method, with the downside that there's a higher chance you will overwrite Rx data when transmitting. However, I would argue that it's easier to make sure you don't transmit before reading available data than to make sure you always read the data in time.

For the SX126x, I had to remove the call to setBufferBaseAddress(), since it will force the data to start at 0, while the returned pointer is still from the previous packet (if you don't go to standby in between). I tested that this works with and without going to standby in between.

For the SX128x, there was no call to setBufferBaseAddress(), but it calls standBy() in readData() and therefore the returned pointer will be correct. I'm not sure if it's really necessary anymore to call standBy() here (and thus the interrupt example wouldn't need to call startReceive() again), but since I don't have the hardware, I haven't tested this.

Copy link
Owner

@jgromes jgromes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this fix! I left two minor comments, after those are addressed this can be merged.

src/modules/SX126x/SX126x.cpp Outdated Show resolved Hide resolved
src/modules/SX128x/SX128x.cpp Outdated Show resolved Hide resolved
@jgromes jgromes merged commit 5624971 into jgromes:master Aug 10, 2024
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants