Linux IEEE 802.15.4 and 6LoWPAN development
 help / color / mirror / Atom feed
* [PATCH wpan-tools] info: add frequency output to current channel
@ 2015-06-03 11:47 Christoffer Holmstedt
  2015-06-04  7:09 ` Alexander Aring
  0 siblings, 1 reply; 2+ messages in thread
From: Christoffer Holmstedt @ 2015-06-03 11:47 UTC (permalink / raw)
  To: linux-wpan

Signed-off-by: Christoffer Holmstedt <christoffer@christofferholmstedt.se>
---
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(-)

diff --git a/src/info.c b/src/info.c
index cd6b2b74172e..9e27176f53e6 100644
--- a/src/info.c
+++ b/src/info.c
@@ -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]);
-- 
1.9.1


-- 
Christoffer Holmstedt

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH wpan-tools] info: add frequency output to current channel
  2015-06-03 11:47 [PATCH wpan-tools] info: add frequency output to current channel Christoffer Holmstedt
@ 2015-06-04  7:09 ` Alexander Aring
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Aring @ 2015-06-04  7:09 UTC (permalink / raw)
  To: Christoffer Holmstedt; +Cc: linux-wpan

On Wed, Jun 03, 2015 at 01:47:27PM +0200, Christoffer Holmstedt wrote:
> Signed-off-by: Christoffer Holmstedt <christoffer@christofferholmstedt.se>
> ---
> 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.
> 

ok. Applied thanks.

- Alex

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-06-04  7:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-03 11:47 [PATCH wpan-tools] info: add frequency output to current channel Christoffer Holmstedt
2015-06-04  7:09 ` Alexander Aring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox