Skip to content

drivers/radios Apply register to rssi dBm conversion to all radios#6895

Merged
miri64 merged 6 commits intoRIOT-OS:masterfrom
bergzand:drivers/radio-rssi-conv
Nov 27, 2017
Merged

drivers/radios Apply register to rssi dBm conversion to all radios#6895
miri64 merged 6 commits intoRIOT-OS:masterfrom
bergzand:drivers/radio-rssi-conv

Conversation

@bergzand
Copy link
Copy Markdown
Member

Implementation idea of #6887. Should be easy to convert to absolute positive values if preferred.

@Hyungsin
Copy link
Copy Markdown

@bergzand, is it possible for you to change the implementation according to @gebart'comment in #6887 ?
Using int16_t for rssi seems to be good. Any concern about this change?

@bergzand
Copy link
Copy Markdown
Member Author

@Hyungsin I've got no problem with that, but I'd like some kind of GO from somebody higher up in the hierarchy before I'm going to change and check most of the radio drivers

@Hyungsin
Copy link
Copy Markdown

@thomaseichinger, any feedback?

radio_info->rssi = at86rf2xx_reg_read(dev, AT86RF2XX_REG__PHY_ED_LEVEL);
rssi = at86rf2xx_reg_read(dev, AT86RF2XX_REG__PHY_ED_LEVEL);
#endif
radio_info->rssi = -RSSI_BASE_VAL - rssi;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@bergzand Please help me out, what is the reason for changing the algebraic sign of this calculation? Especially as you are changing .rssi to int8_t ...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I forgot to change .rssi back to the original uint8_t. The sign here is flipped to have the value from the datasheet directly as a define. The sign is flipped to correct the algabraic formula from sec 8.5.3 from the datasheet of the at86rf233 to get a positive value.

* @{
*/
#define CC2420_CRCCOR_CRC_MASK (0x80)
#define CC2420_CRCCOR_COR_MASK (0x7F)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

missing /** @} */

/* fetch and check if CRC_OK bit (MSB) is set */
cc2420_fifo_read(dev, &crc_corr, 1);
if (!(crc_corr & 0x80)) {
if (!(crc_corr & CC2420_CRCCOR_CRC_MASK)) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Think this and related changes should go in a separate commit.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point.

@bergzand
Copy link
Copy Markdown
Member Author

@thomaseichinger Thank you for your feedback. I initially build the implementation here to have rssi as a int8_t, but changed it to uint8_t after some discussion in #6887. I think I only changed the implementation to report rssi as the absolute value, but forgot to change the variable back to uint8_t.

@bergzand
Copy link
Copy Markdown
Member Author

The main discussion point now is whether to use uint8_t to express RSSI as the absolute value or as proposed by @gebart use int16_t for RSSI.

@bergzand bergzand force-pushed the drivers/radio-rssi-conv branch from 318200b to 49b89ce Compare August 30, 2017 15:30
@thomaseichinger
Copy link
Copy Markdown
Member

@bergzand Thank you for shedding some light on it. Personally I think @gebart's suggestion using int16_t provides us with more flexibility.

@bergzand
Copy link
Copy Markdown
Member Author

Great, then I make sure to adjust and clean up this PR. Is it okay to keep it one big PR for all radio drivers or do you prefer separate PR's for each radio?

@thomaseichinger
Copy link
Copy Markdown
Member

I think one PR is fine but maybe split changes in one commit per device.

@bergzand bergzand force-pushed the drivers/radio-rssi-conv branch 2 times, most recently from 28a0279 to e4a5939 Compare August 30, 2017 20:13
@bergzand
Copy link
Copy Markdown
Member Author

bergzand commented Aug 30, 2017

@thomaseichinger I rebased it a bit, it is now a set of commits, one for the .rssi and one per radio. .rssi is now int16_t and I corrected all issues from your review. The kw2xrf is now also adjusted for signed dBm.

@thomaseichinger
Copy link
Copy Markdown
Member

Awesome! Finally, could you add a mention in the header comment that rssi has to be in dBm?

@bergzand bergzand force-pushed the drivers/radio-rssi-conv branch from a6af6f4 to 4970660 Compare August 31, 2017 08:21
@bergzand
Copy link
Copy Markdown
Member Author

Of course.
Added "in dBm" to the comments of the two structs.

@thomaseichinger thomaseichinger added Area: drivers Area: Device drivers Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Aug 31, 2017
@bergzand
Copy link
Copy Markdown
Member Author

@gvz If you have time, could you please test this PR with the cc2420? I don't have access to that radio, so my code is a best guess on the information from the datasheet.

@gvz
Copy link
Copy Markdown
Contributor

gvz commented Nov 21, 2017

@bergzand Just tried on the cc2420 and the rssi is 65470, I guess something went wrong. I will try to have a look.

@bergzand
Copy link
Copy Markdown
Member Author

@gvz That looks like an interpretation error, int16_t as uint16_t. 65470 is -66 when interpreted as signed, and that looks like a valid number for rssi.

@gvz
Copy link
Copy Markdown
Contributor

gvz commented Nov 21, 2017

Ok I found it: its in: gnrc_netif_hdr_print.c the fix is:
- printf("rssi: %u ", (unsigned) hdr->rssi);
+ printf("rssi: %d ", (signed) hdr->rssi);

@bergzand
Copy link
Copy Markdown
Member Author

Got it, thanks, will put a fixup asap here.

@bergzand
Copy link
Copy Markdown
Member Author

@gvz It should print negative numbers now :)

Copy link
Copy Markdown
Member

@smlng smlng left a comment

Choose a reason for hiding this comment

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

tested with samr21-xpro and pba-d-01-kw2x, looks good. Though the drivers derive RSSI and LQI value differently.

@smlng smlng added the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Nov 23, 2017
@smlng
Copy link
Copy Markdown
Member

smlng commented Nov 23, 2017

please squash

@bergzand bergzand force-pushed the drivers/radio-rssi-conv branch from 444f67c to 2d491e0 Compare November 27, 2017 20:50
@bergzand
Copy link
Copy Markdown
Member Author

Squashed

@bergzand bergzand added CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR and removed CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR labels Nov 27, 2017
@miri64 miri64 merged commit a63bb6d into RIOT-OS:master Nov 27, 2017
@bergzand bergzand deleted the drivers/radio-rssi-conv branch November 27, 2017 22:52
miri64 added a commit to miri64/RIOT that referenced this pull request Dec 13, 2017
miri64 added a commit to miri64/RIOT that referenced this pull request Dec 13, 2017
bergzand added a commit that referenced this pull request Dec 13, 2017
tests: fix tests/gnrc_netif for changes in #6895
shr70 pushed a commit to Josar/RIOT that referenced this pull request Dec 18, 2017
panail pushed a commit to panail/RIOT that referenced this pull request Oct 29, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants