Skip to contentSkip to conversation

info: add frequency output to current channel

PATCH In review Christoffer Holmstedt 2 participants 2 messages Jun 3, 2015 – Jun 4, 2015 IEEE 802.15.4

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 info: add frequency output to current channel

---
Not much to say here but I realised that the formatting done by print_freq_handler() add extra whitespaces when not needed e.g. when used for the current_channel output. I'm thinking about refactoring print_freq_handler() to get_freq() and return the float which in the end will let the caller do the formatting.

As an example to this problem default channel of 13 for channel page 0 with the openlabs SPI board for RPi will print 2 whitespaces instead of one which would look better.

	current_channel: 13,  2415 MHz

It's not a big deal but I've put it on my todo list.

 src/info.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
src/info.c +7 -2
index cd6b2b74172e..9e27176f53e6 100644
@@ -193,8 +193,13 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	if (tb_msg[NL802154_ATTR_PAGE])
 		printf("current_page: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_PAGE]));
 
-	if (tb_msg[NL802154_ATTR_CHANNEL])
-		printf("current_channel: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_CHANNEL]));
+	if (tb_msg[NL802154_ATTR_CHANNEL] &&
+	    tb_msg[NL802154_ATTR_PAGE]) {
+		printf("current_channel: %d, ", nla_get_u8(tb_msg[NL802154_ATTR_CHANNEL]));
+		print_freq_handler(nla_get_u8(tb_msg[NL802154_ATTR_PAGE]),
+				   nla_get_u8(tb_msg[NL802154_ATTR_CHANNEL]));
+		printf(" MHz\n");
+	}
 
 	if (tb_msg[NL802154_ATTR_CCA_MODE]) {
 		cca_mode = nla_get_u32(tb_msg[NL802154_ATTR_CCA_MODE]);
Signature · 5 lines
1.9.1


-- 
Christoffer Holmstedt
maintainer
#1 lore raw
Quoted 8 lines · Christoffer Holmstedt

---
Not much to say here but I realised that the formatting done by print_freq_handler() add extra whitespaces when not needed e.g. when used for the current_channel output. I'm thinking about refactoring print_freq_handler() to get_freq() and return the float which in the end will let the caller do the formatting.

Quoted 8 lines

As an example to this problem default channel of 13 for channel page 0 with the openlabs SPI board for RPi will print 2 whitespaces instead of one which would look better.

	current_channel: 13,  2415 MHz

It's not a big deal but I've put it on my todo list.

ok. Applied thanks.

- Alex