All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
@ 2015-06-01 13:35 Christoffer Holmstedt
  2015-06-02  4:10 ` Varka Bhadram
  0 siblings, 1 reply; 9+ messages in thread
From: Christoffer Holmstedt @ 2015-06-01 13:35 UTC (permalink / raw)
  To: linux-wpan

Add the frequency to the channel numbers output when running "iwpan list".
The frequencies listed are according to chapter 8.1.2 in IEEE 802.15.4-2011.
The output now looks like this (fake wpan loopback with all channels
supported):

capabilities:
	iftypes: node
	channels:
		page 0:
			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
			[ 9]    922 MHz [10]    924 MHz [11]   2405 MHz
			[12]   2410 MHz [13]   2415 MHz [14]   2420 MHz
			[15]   2425 MHz [16]   2430 MHz [17]   2435 MHz
			[18]   2440 MHz [19]   2445 MHz [20]   2450 MHz
			[21]   2455 MHz [22]   2460 MHz [23]   2465 MHz
			[24]   2470 MHz [25]   2475 MHz [26]   2480 MHz
		page 1:
			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
			[ 9]    922 MHz [10]    924 MHz
		page 2:
			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
			[ 9]    922 MHz [10]    924 MHz
		page 3:
			[ 0]   2412 MHz [ 1]   2417 MHz [ 2]   2422 MHz
			[ 3]   2427 MHz [ 4]   2432 MHz [ 5]   2437 MHz
			[ 6]   2442 MHz [ 7]   2447 MHz [ 8]   2452 MHz
			[ 9]   2457 MHz [10]   2462 MHz [11]   2467 MHz
			[12]   2472 MHz [13]   2484 MHz
		page 4:
			[ 0]  499.2 MHz [ 1] 3494.4 MHz [ 2] 3993.6 MHz
			[ 3] 4492.8 MHz [ 4] 3993.6 MHz [ 5] 6489.6 MHz
			[ 6] 6988.8 MHz [ 7] 6489.6 MHz [ 8] 7488.0 MHz
			[ 9] 7987.2 MHz [10] 8486.4 MHz [11] 7987.2 MHz
			[12] 8985.6 MHz [13] 9484.8 MHz [14] 9984.0 MHz
			[15] 9484.8 MHz
		page 5:
			[ 0]    780 MHz [ 1]    782 MHz [ 2]    784 MHz
			[ 3]    786 MHz [ 4]    780 MHz [ 5]    782 MHz
			[ 6]    784 MHz [ 7]    786 MHz
		page 6:
			[ 0]  951.2 MHz [ 1]  951.8 MHz [ 2]  952.4 MHz
			[ 3]  953.0 MHz [ 4]  953.6 MHz [ 5]  954.2 MHz
			[ 6]  954.8 MHz [ 7]  955.4 MHz [ 8]  954.4 MHz
			[ 9]  954.6 MHz [10]  951.1 MHz [11]  951.5 MHz
			[12]  951.9 MHz [13]  952.3 MHz [14]  952.7 MHz
			[15]  953.1 MHz [16]  953.5 MHz [17]  953.9 MHz
			[18]  954.3 MHz [19]  954.7 MHz [20]  955.1 MHz
			[21]  955.5 MHz

Signed-off-by: Christoffer Holmstedt <christoffer@christofferholmstedt.se>
---
 src/info.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 137 insertions(+), 2 deletions(-)

diff --git a/src/info.c b/src/info.c
index e8f5dda8da94..ee3a80838913 100644
--- a/src/info.c
+++ b/src/info.c
@@ -23,6 +23,129 @@ static void print_minmax_handler(int min, int max)
 	printf("\b \n");
 }
 
+static void print_freq_handler(int channel_page, int channel)
+{
+	float freq = 0;
+
+	switch (channel_page) {
+	case 0:
+		if (channel == 0) {
+			freq = 868.3;
+			printf("%6.1f", freq);
+			break;
+		} else if (channel > 0 && channel < 11) {
+			freq = 906 + 2 * (channel - 1);
+		} else {
+			freq = 2405 + 5 * (channel - 11);
+		}
+		printf("%6.0f", freq);
+		break;
+	case 1:
+		if (channel == 0) {
+			freq = 868.3;
+			printf("%6.1f", freq);
+			break;
+		} else if (channel >= 1 && channel <= 10) {
+			freq = 906 + 2 * (channel - 1);
+		}
+		printf("%6.0f", freq);
+		break;
+	case 2:
+		if (channel == 0) {
+			freq = 868.3;
+			printf("%6.1f", freq);
+			break;
+		} else if (channel >= 1 && channel <= 10) {
+			freq = 906 + 2 * (channel - 1);
+		}
+		printf("%6.0f", freq);
+		break;
+	case 3:
+		if (channel >= 0 && channel <= 12) {
+			freq = 2412 + 5 * channel;
+		} else if (channel == 13) {
+			freq = 2484;
+		}
+		printf("%6.0f", freq);
+		break;
+	case 4:
+		switch (channel) {
+		case 0:
+			freq = 499.2;
+			break;
+		case 1:
+			freq = 3494.4;
+			break;
+		case 2:
+			freq = 3993.6;
+			break;
+		case 3:
+			freq = 4492.8;
+			break;
+		case 4:
+			freq = 3993.6;
+			break;
+		case 5:
+			freq = 6489.6;
+			break;
+		case 6:
+			freq = 6988.8;
+			break;
+		case 7:
+			freq = 6489.6;
+			break;
+		case 8:
+			freq = 7488.0;
+			break;
+		case 9:
+			freq = 7987.2;
+			break;
+		case 10:
+			freq = 8486.4;
+			break;
+		case 11:
+			freq = 7987.2;
+			break;
+		case 12:
+			freq = 8985.6;
+			break;
+		case 13:
+			freq = 9484.8;
+			break;
+		case 14:
+			freq = 9984.0;
+			break;
+		case 15:
+			freq = 9484.8;
+			break;
+		}
+		printf("%6.1f", freq);
+		break;
+	case 5:
+		if (channel >= 0 && channel <= 3) {
+			freq = 780 + 2 * channel;
+		} else if (channel >= 4 && channel <= 7) {
+			freq = 780 + 2 * (channel - 4);
+		}
+		printf("%6.0f", freq);
+		break;
+	case 6:
+		if (channel >= 0 && channel <= 7) {
+			freq = 951.2 + 0.6 * channel;
+		} else if (channel >= 8 && channel <= 9) {
+			freq = 954.4 + 0.2 * (channel - 8);
+		} else if (channel >= 10  && channel <= 21) {
+			freq = 951.1 + 0.4 * (channel - 10);
+		}
+
+		printf("%6.1f", freq);
+		break;
+	default:
+		printf("Unkno.");
+		break;
+	}
+}
+
 static int print_phy_handler(struct nl_msg *msg, void *arg)
 {
 	struct nlattr *tb_msg[NL802154_ATTR_MAX + 1];
@@ -145,6 +268,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 		}
 
 		if (tb_msg[NL802154_CAP_ATTR_CHANNELS]) {
+			int counter = 0;
 			int rem_pages;
 			struct nlattr *nl_pages;
 			printf("\tchannels:\n");
@@ -152,9 +276,20 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 					    rem_pages) {
 				int rem_channels;
 				struct nlattr *nl_channels;
+				counter = 0;
 				printf("\t\tpage %d: ", nla_type(nl_pages));
-				nla_for_each_nested(nl_channels, nl_pages, rem_channels)
-					printf("%d,", nla_type(nl_channels));
+				nla_for_each_nested(nl_channels, nl_pages, rem_channels) {
+					if (counter % 3 == 0) {
+						printf("\n\t\t\t[%2d] ", nla_type(nl_channels));
+						print_freq_handler(nla_type(nl_pages), nla_type(nl_channels));
+						printf(" MHz ");
+					} else {
+						printf("[%2d] ", nla_type(nl_channels));
+						print_freq_handler(nla_type(nl_pages), nla_type(nl_channels));
+						printf(" MHz ");
+					}
+					counter++;
+				}
 				/*  TODO hack use sprintf here */
 				printf("\b \b\n");
 			}
-- 
1.9.1


-- 
Christoffer Holmstedt

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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-01 13:35 [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities Christoffer Holmstedt
@ 2015-06-02  4:10 ` Varka Bhadram
  2015-06-02  6:08   ` Christoffer Holmstedt
  0 siblings, 1 reply; 9+ messages in thread
From: Varka Bhadram @ 2015-06-02  4:10 UTC (permalink / raw)
  To: Christoffer Holmstedt, linux-wpan

Hi Christoffer Holmstedt,

On 06/01/2015 07:05 PM, Christoffer Holmstedt wrote:

> Add the frequency to the channel numbers output when running "iwpan list".
> The frequencies listed are according to chapter 8.1.2 in IEEE 802.15.4-2011.
> The output now looks like this (fake wpan loopback with all channels
> supported):
>
> capabilities:
> 	iftypes: node
> 	channels:
> 		page 0:
> 			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
> 			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
> 			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
> 			[ 9]    922 MHz [10]    924 MHz [11]   2405 MHz
> 			[12]   2410 MHz [13]   2415 MHz [14]   2420 MHz
> 			[15]   2425 MHz [16]   2430 MHz [17]   2435 MHz
> 			[18]   2440 MHz [19]   2445 MHz [20]   2450 MHz
> 			[21]   2455 MHz [22]   2460 MHz [23]   2465 MHz
> 			[24]   2470 MHz [25]   2475 MHz [26]   2480 MHz
> 		page 1:
> 			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
> 			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
> 			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
> 			[ 9]    922 MHz [10]    924 MHz
> 		page 2:
> 			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
> 			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
> 			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
> 			[ 9]    922 MHz [10]    924 MHz
> 		page 3:
> 			[ 0]   2412 MHz [ 1]   2417 MHz [ 2]   2422 MHz
> 			[ 3]   2427 MHz [ 4]   2432 MHz [ 5]   2437 MHz
> 			[ 6]   2442 MHz [ 7]   2447 MHz [ 8]   2452 MHz
> 			[ 9]   2457 MHz [10]   2462 MHz [11]   2467 MHz
> 			[12]   2472 MHz [13]   2484 MHz
> 		page 4:
> 			[ 0]  499.2 MHz [ 1] 3494.4 MHz [ 2] 3993.6 MHz
> 			[ 3] 4492.8 MHz [ 4] 3993.6 MHz [ 5] 6489.6 MHz
> 			[ 6] 6988.8 MHz [ 7] 6489.6 MHz [ 8] 7488.0 MHz
> 			[ 9] 7987.2 MHz [10] 8486.4 MHz [11] 7987.2 MHz
> 			[12] 8985.6 MHz [13] 9484.8 MHz [14] 9984.0 MHz
> 			[15] 9484.8 MHz
> 		page 5:
> 			[ 0]    780 MHz [ 1]    782 MHz [ 2]    784 MHz
> 			[ 3]    786 MHz [ 4]    780 MHz [ 5]    782 MHz
> 			[ 6]    784 MHz [ 7]    786 MHz
> 		page 6:
> 			[ 0]  951.2 MHz [ 1]  951.8 MHz [ 2]  952.4 MHz
> 			[ 3]  953.0 MHz [ 4]  953.6 MHz [ 5]  954.2 MHz
> 			[ 6]  954.8 MHz [ 7]  955.4 MHz [ 8]  954.4 MHz
> 			[ 9]  954.6 MHz [10]  951.1 MHz [11]  951.5 MHz
> 			[12]  951.9 MHz [13]  952.3 MHz [14]  952.7 MHz
> 			[15]  953.1 MHz [16]  953.5 MHz [17]  953.9 MHz
> 			[18]  954.3 MHz [19]  954.7 MHz [20]  955.1 MHz
> 			[21]  955.5 MHz
>
> Signed-off-by: Christoffer Holmstedt <christoffer@christofferholmstedt.se>
> ---
>   src/info.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>   1 file changed, 137 insertions(+), 2 deletions(-)

I tested this patch with cc2520. Its working fine.

But the channels listing per page is like this,

root@beaglebone:~# iwpan list
wpan_phy phy0
supported channels:
	page 0: 11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
current_page: 0
current_channel: 11
tx_power: 0
capabilities:
	iftypes: node
	channels:
		page 0:
			[11]   2405 MHz [12]   2410 MHz [13]   2415 MHz
			[14]   2420 MHz [15]   2425 MHz [16]   2430 MHz
			[17]   2435 MHz [18]   2440 MHz [19]   2445 MHz
			[20]   2450 MHz [21]   2455 MHz [22]   2460 MHz
			[23]   2465 MHz [24]   2470 MHz [25]   2475 MHz
			[26]   2480 MHz

This not much readable, not able to understand which freq comes under which channel.

Alex already suggested one way of listing this..

	page 0:
		[11] 2405 MHz,	[12] 2410 MHz,	[13] 2415 MHz,
		[14] 2420 MHz,	[15] 2425 MHz,	[16] 2430 MHz,
		[17] 2435 MHz,	[18] 2440 MHz,	[19] 2445 MHz,
		....

This seems to be good. Use single space after channel number and use the comma
to separate them.

> diff --git a/src/info.c b/src/info.c
> index e8f5dda8da94..ee3a80838913 100644
> --- a/src/info.c
> +++ b/src/info.c
> @@ -23,6 +23,129 @@ static void print_minmax_handler(int min, int max)
>   	printf("\b \n");
>   }
>   
> +static void print_freq_handler(int channel_page, int channel)
> +{
> +	float freq = 0;
> +
> +	switch (channel_page) {
> +	case 0:
> +		if (channel == 0) {
> +			freq = 868.3;
> +			printf("%6.1f", freq);
> +			break;
> +		} else if (channel > 0 && channel < 11) {
> +			freq = 906 + 2 * (channel - 1);
> +		} else {
> +			freq = 2405 + 5 * (channel - 11);
> +		}
> +		printf("%6.0f", freq);
> +		break;
> +	case 1:
> +		if (channel == 0) {
> +			freq = 868.3;
> +			printf("%6.1f", freq);
> +			break;
> +		} else if (channel >= 1 && channel <= 10) {
> +			freq = 906 + 2 * (channel - 1);
> +		}
> +		printf("%6.0f", freq);
> +		break;
> +	case 2:
> +		if (channel == 0) {
> +			freq = 868.3;
> +			printf("%6.1f", freq);
> +			break;
> +		} else if (channel >= 1 && channel <= 10) {
> +			freq = 906 + 2 * (channel - 1);
> +		}
> +		printf("%6.0f", freq);
> +		break;
> +	case 3:
> +		if (channel >= 0 && channel <= 12) {
> +			freq = 2412 + 5 * channel;
> +		} else if (channel == 13) {
> +			freq = 2484;
> +		}
> +		printf("%6.0f", freq);
> +		break;
> +	case 4:
> +		switch (channel) {
> +		case 0:
> +			freq = 499.2;
> +			break;
> +		case 1:
> +			freq = 3494.4;
> +			break;
> +		case 2:
> +			freq = 3993.6;
> +			break;
> +		case 3:
> +			freq = 4492.8;
> +			break;
> +		case 4:
> +			freq = 3993.6;
> +			break;
> +		case 5:
> +			freq = 6489.6;
> +			break;
> +		case 6:
> +			freq = 6988.8;
> +			break;
> +		case 7:
> +			freq = 6489.6;
> +			break;
> +		case 8:
> +			freq = 7488.0;
> +			break;
> +		case 9:
> +			freq = 7987.2;
> +			break;
> +		case 10:
> +			freq = 8486.4;
> +			break;
> +		case 11:
> +			freq = 7987.2;
> +			break;
> +		case 12:
> +			freq = 8985.6;
> +			break;
> +		case 13:
> +			freq = 9484.8;
> +			break;
> +		case 14:
> +			freq = 9984.0;
> +			break;
> +		case 15:
> +			freq = 9484.8;
> +			break;
> +		}
> +		printf("%6.1f", freq);
> +		break;
> +	case 5:
> +		if (channel >= 0 && channel <= 3) {
> +			freq = 780 + 2 * channel;
> +		} else if (channel >= 4 && channel <= 7) {
> +			freq = 780 + 2 * (channel - 4);
> +		}
> +		printf("%6.0f", freq);
> +		break;
> +	case 6:
> +		if (channel >= 0 && channel <= 7) {
> +			freq = 951.2 + 0.6 * channel;
> +		} else if (channel >= 8 && channel <= 9) {
> +			freq = 954.4 + 0.2 * (channel - 8);
> +		} else if (channel >= 10  && channel <= 21) {
> +			freq = 951.1 + 0.4 * (channel - 10);
> +		}
> +
> +		printf("%6.1f", freq);
> +		break;
> +	default:
> +		printf("Unkno.");

Make it as unknown only. No need of this shortcut.


-- 
Varka Bhadram


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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-02  4:10 ` Varka Bhadram
@ 2015-06-02  6:08   ` Christoffer Holmstedt
  2015-06-02  7:09     ` Alexander Aring
  0 siblings, 1 reply; 9+ messages in thread
From: Christoffer Holmstedt @ 2015-06-02  6:08 UTC (permalink / raw)
  To: Varka Bhadram; +Cc: linux-wpan

Hi Varka

On Tue, Jun 02, 2015 at 09:40:32AM +0530, Varka Bhadram wrote:
> Hi Christoffer Holmstedt,
> 
> On 06/01/2015 07:05 PM, Christoffer Holmstedt wrote:
> 
> >Add the frequency to the channel numbers output when running "iwpan list".
> >The frequencies listed are according to chapter 8.1.2 in IEEE 802.15.4-2011.
> >The output now looks like this (fake wpan loopback with all channels
> >supported):
> >
> >capabilities:
> >	iftypes: node
> >	channels:
> >		page 0:
> >			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
> >			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
> >			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
> >			[ 9]    922 MHz [10]    924 MHz [11]   2405 MHz
> >			[12]   2410 MHz [13]   2415 MHz [14]   2420 MHz
> >			[15]   2425 MHz [16]   2430 MHz [17]   2435 MHz
> >			[18]   2440 MHz [19]   2445 MHz [20]   2450 MHz
> >			[21]   2455 MHz [22]   2460 MHz [23]   2465 MHz
> >			[24]   2470 MHz [25]   2475 MHz [26]   2480 MHz
> >		page 1:
> >			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
> >			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
> >			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
> >			[ 9]    922 MHz [10]    924 MHz
> >		page 2:
> >			[ 0]  868.3 MHz [ 1]    906 MHz [ 2]    908 MHz
> >			[ 3]    910 MHz [ 4]    912 MHz [ 5]    914 MHz
> >			[ 6]    916 MHz [ 7]    918 MHz [ 8]    920 MHz
> >			[ 9]    922 MHz [10]    924 MHz
> >		page 3:
> >			[ 0]   2412 MHz [ 1]   2417 MHz [ 2]   2422 MHz
> >			[ 3]   2427 MHz [ 4]   2432 MHz [ 5]   2437 MHz
> >			[ 6]   2442 MHz [ 7]   2447 MHz [ 8]   2452 MHz
> >			[ 9]   2457 MHz [10]   2462 MHz [11]   2467 MHz
> >			[12]   2472 MHz [13]   2484 MHz
> >		page 4:
> >			[ 0]  499.2 MHz [ 1] 3494.4 MHz [ 2] 3993.6 MHz
> >			[ 3] 4492.8 MHz [ 4] 3993.6 MHz [ 5] 6489.6 MHz
> >			[ 6] 6988.8 MHz [ 7] 6489.6 MHz [ 8] 7488.0 MHz
> >			[ 9] 7987.2 MHz [10] 8486.4 MHz [11] 7987.2 MHz
> >			[12] 8985.6 MHz [13] 9484.8 MHz [14] 9984.0 MHz
> >			[15] 9484.8 MHz
> >		page 5:
> >			[ 0]    780 MHz [ 1]    782 MHz [ 2]    784 MHz
> >			[ 3]    786 MHz [ 4]    780 MHz [ 5]    782 MHz
> >			[ 6]    784 MHz [ 7]    786 MHz
> >		page 6:
> >			[ 0]  951.2 MHz [ 1]  951.8 MHz [ 2]  952.4 MHz
> >			[ 3]  953.0 MHz [ 4]  953.6 MHz [ 5]  954.2 MHz
> >			[ 6]  954.8 MHz [ 7]  955.4 MHz [ 8]  954.4 MHz
> >			[ 9]  954.6 MHz [10]  951.1 MHz [11]  951.5 MHz
> >			[12]  951.9 MHz [13]  952.3 MHz [14]  952.7 MHz
> >			[15]  953.1 MHz [16]  953.5 MHz [17]  953.9 MHz
> >			[18]  954.3 MHz [19]  954.7 MHz [20]  955.1 MHz
> >			[21]  955.5 MHz
> >
> >Signed-off-by: Christoffer Holmstedt <christoffer@christofferholmstedt.se>
> >---
> >  src/info.c | 139 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
> >  1 file changed, 137 insertions(+), 2 deletions(-)
> 
> I tested this patch with cc2520. Its working fine.

Good then my "create patch" workflow works fine ;)

> 
> But the channels listing per page is like this,
> 
> root@beaglebone:~# iwpan list
> wpan_phy phy0
> supported channels:
> 	page 0: 11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26
> current_page: 0
> current_channel: 11
> tx_power: 0
> capabilities:
> 	iftypes: node
> 	channels:
> 		page 0:
> 			[11]   2405 MHz [12]   2410 MHz [13]   2415 MHz
> 			[14]   2420 MHz [15]   2425 MHz [16]   2430 MHz
> 			[17]   2435 MHz [18]   2440 MHz [19]   2445 MHz
> 			[20]   2450 MHz [21]   2455 MHz [22]   2460 MHz
> 			[23]   2465 MHz [24]   2470 MHz [25]   2475 MHz
> 			[26]   2480 MHz
> 
> This not much readable, not able to understand which freq comes under which channel.

Yes, I was thinking about that. It was a trade off between number of columns,
alignment between pages and channels that came to the above solution with the
risk of making it hard to understand.

The current whitespace in the beginning is to align all channels for all
channel pages but this might not be that common so it is worth thinking about.

All channels in all pages take the same amount of characters (6) for the above
alignment. This is due to UWB PHY having center frequencies such as 7987.2
(channel page 4).

> 
> Alex already suggested one way of listing this..
> 
> 	page 0:
> 		[11] 2405 MHz,	[12] 2410 MHz,	[13] 2415 MHz,
> 		[14] 2420 MHz,	[15] 2425 MHz,	[16] 2430 MHz,
> 		[17] 2435 MHz,	[18] 2440 MHz,	[19] 2445 MHz,
> 		....
> 
> This seems to be good. Use single space after channel number and use the comma
> to separate them.

I agree. I will redo it to align channels only within a channel as well as add
the comma after "MHz".

> 
> >diff --git a/src/info.c b/src/info.c
> >index e8f5dda8da94..ee3a80838913 100644
> >--- a/src/info.c
> >+++ b/src/info.c
> >@@ -23,6 +23,129 @@ static void print_minmax_handler(int min, int max)
> >  	printf("\b \n");
> >  }
> >+static void print_freq_handler(int channel_page, int channel)
> >+{
> >+	float freq = 0;
> >+
> >+	switch (channel_page) {
> >+	case 0:
> >+		if (channel == 0) {
> >+			freq = 868.3;
> >+			printf("%6.1f", freq);
> >+			break;
> >+		} else if (channel > 0 && channel < 11) {
> >+			freq = 906 + 2 * (channel - 1);
> >+		} else {
> >+			freq = 2405 + 5 * (channel - 11);
> >+		}
> >+		printf("%6.0f", freq);
> >+		break;
> >+	case 1:
> >+		if (channel == 0) {
> >+			freq = 868.3;
> >+			printf("%6.1f", freq);
> >+			break;
> >+		} else if (channel >= 1 && channel <= 10) {
> >+			freq = 906 + 2 * (channel - 1);
> >+		}
> >+		printf("%6.0f", freq);
> >+		break;
> >+	case 2:
> >+		if (channel == 0) {
> >+			freq = 868.3;
> >+			printf("%6.1f", freq);
> >+			break;
> >+		} else if (channel >= 1 && channel <= 10) {
> >+			freq = 906 + 2 * (channel - 1);
> >+		}
> >+		printf("%6.0f", freq);
> >+		break;
> >+	case 3:
> >+		if (channel >= 0 && channel <= 12) {
> >+			freq = 2412 + 5 * channel;
> >+		} else if (channel == 13) {
> >+			freq = 2484;
> >+		}
> >+		printf("%6.0f", freq);
> >+		break;
> >+	case 4:
> >+		switch (channel) {
> >+		case 0:
> >+			freq = 499.2;
> >+			break;
> >+		case 1:
> >+			freq = 3494.4;
> >+			break;
> >+		case 2:
> >+			freq = 3993.6;
> >+			break;
> >+		case 3:
> >+			freq = 4492.8;
> >+			break;
> >+		case 4:
> >+			freq = 3993.6;
> >+			break;
> >+		case 5:
> >+			freq = 6489.6;
> >+			break;
> >+		case 6:
> >+			freq = 6988.8;
> >+			break;
> >+		case 7:
> >+			freq = 6489.6;
> >+			break;
> >+		case 8:
> >+			freq = 7488.0;
> >+			break;
> >+		case 9:
> >+			freq = 7987.2;
> >+			break;
> >+		case 10:
> >+			freq = 8486.4;
> >+			break;
> >+		case 11:
> >+			freq = 7987.2;
> >+			break;
> >+		case 12:
> >+			freq = 8985.6;
> >+			break;
> >+		case 13:
> >+			freq = 9484.8;
> >+			break;
> >+		case 14:
> >+			freq = 9984.0;
> >+			break;
> >+		case 15:
> >+			freq = 9484.8;
> >+			break;
> >+		}
> >+		printf("%6.1f", freq);
> >+		break;
> >+	case 5:
> >+		if (channel >= 0 && channel <= 3) {
> >+			freq = 780 + 2 * channel;
> >+		} else if (channel >= 4 && channel <= 7) {
> >+			freq = 780 + 2 * (channel - 4);
> >+		}
> >+		printf("%6.0f", freq);
> >+		break;
> >+	case 6:
> >+		if (channel >= 0 && channel <= 7) {
> >+			freq = 951.2 + 0.6 * channel;
> >+		} else if (channel >= 8 && channel <= 9) {
> >+			freq = 954.4 + 0.2 * (channel - 8);
> >+		} else if (channel >= 10  && channel <= 21) {
> >+			freq = 951.1 + 0.4 * (channel - 10);
> >+		}
> >+
> >+		printf("%6.1f", freq);
> >+		break;
> >+	default:
> >+		printf("Unkno.");
> 
> Make it as unknown only. No need of this shortcut.

This is for the same reason as above. Alignment in the output, it is a trade
off between "readability" in two different ways. Alignment in the output or
printing the full word "Unknown". I will change this to "Unknown" and we can
change it at a later date if it ever shows up and mess up alignment. In any
case if "Unknown" shows up the actual frequency should be added instead of
fixing alignment. ;)

> 
> 
> -- 
> Varka Bhadram

Thanks for your comments Varka.
-- 
Christoffer Holmstedt

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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-02  6:08   ` Christoffer Holmstedt
@ 2015-06-02  7:09     ` Alexander Aring
  2015-06-02  7:38       ` Christoffer Holmstedt
  0 siblings, 1 reply; 9+ messages in thread
From: Alexander Aring @ 2015-06-02  7:09 UTC (permalink / raw)
  To: Christoffer Holmstedt; +Cc: Varka Bhadram, linux-wpan

On Tue, Jun 02, 2015 at 08:08:38AM +0200, Christoffer Holmstedt wrote:
...
> 
> This is for the same reason as above. Alignment in the output, it is a trade
> off between "readability" in two different ways. Alignment in the output or
> printing the full word "Unknown". I will change this to "Unknown" and we can
> change it at a later date if it ever shows up and mess up alignment. In any
> case if "Unknown" shows up the actual frequency should be added instead of
> fixing alignment. ;)
> 

Then maybe some "-" instead "unkown", is this better, or it's too small
then?

- Alex

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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-02  7:09     ` Alexander Aring
@ 2015-06-02  7:38       ` Christoffer Holmstedt
  2015-06-02  9:34         ` Lennert Buytenhek
  0 siblings, 1 reply; 9+ messages in thread
From: Christoffer Holmstedt @ 2015-06-02  7:38 UTC (permalink / raw)
  To: Alexander Aring; +Cc: Varka Bhadram, linux-wpan

On Tue, Jun 02, 2015 at 09:09:30AM +0200, Alexander Aring wrote:
> On Tue, Jun 02, 2015 at 08:08:38AM +0200, Christoffer Holmstedt wrote:
> ...
> > 
> > This is for the same reason as above. Alignment in the output, it is a trade
> > off between "readability" in two different ways. Alignment in the output or
> > printing the full word "Unknown". I will change this to "Unknown" and we can
> > change it at a later date if it ever shows up and mess up alignment. In any
> > case if "Unknown" shows up the actual frequency should be added instead of
> > fixing alignment. ;)
> > 
> 
> Then maybe some "-" instead "unkown", is this better, or it's too small
> then?
> 

The more I think about it the more I feel "Unknown" is better. If for some
reason the channel page and channel combination is not listed and "Unknown" is
printed the last thing the user will care about is alignment in the output.

Channel page and channel number information will not change that often so we
should be able to keep up with future changes (additions). I have tried to get
hold of the 802.15.4-2015 draft from March/April but without success. The local
university will charge me ~350€ or something in that region for it. I wanted it
to see if any new channel pages/channels have been added since -2011 edition.

Anyway, v2 coming in a few minutes.

> - Alex

-- 
Christoffer Holmstedt

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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-02  7:38       ` Christoffer Holmstedt
@ 2015-06-02  9:34         ` Lennert Buytenhek
  2015-06-02  9:53           ` Christoffer Holmstedt
  2015-06-02 10:15           ` Alexander Aring
  0 siblings, 2 replies; 9+ messages in thread
From: Lennert Buytenhek @ 2015-06-02  9:34 UTC (permalink / raw)
  To: Christoffer Holmstedt; +Cc: Alexander Aring, Varka Bhadram, linux-wpan

On Tue, Jun 02, 2015 at 09:38:27AM +0200, Christoffer Holmstedt wrote:

> > > This is for the same reason as above. Alignment in the output, it is a trade
> > > off between "readability" in two different ways. Alignment in the output or
> > > printing the full word "Unknown". I will change this to "Unknown" and we can
> > > change it at a later date if it ever shows up and mess up alignment. In any
> > > case if "Unknown" shows up the actual frequency should be added instead of
> > > fixing alignment. ;)
> > > 
> > 
> > Then maybe some "-" instead "unkown", is this better, or it's too small
> > then?
> > 
> 
> The more I think about it the more I feel "Unknown" is better. If for some
> reason the channel page and channel combination is not listed and "Unknown" is
> printed the last thing the user will care about is alignment in the output.
> 
> Channel page and channel number information will not change that often
> so we should be able to keep up with future changes (additions). I have
> tried to get hold of the 802.15.4-2015 draft from March/April but
> without success. The local university will charge me ~350€ or something
> in that region for it. I wanted it to see if any new channel
> pages/channels have been added since -2011 edition.

There are some amendments already available for download that
document new channel pages:

802.15.4f-2012.pdf: channel pages 7, 8
802.15.4g-2012.pdf: channel pages 9, 10
802.15.4j-2013.pdf: channel page 11
802.15.4k-2013.pdf: channel page 12
802.15.4p-2014.pdf: channel page 13

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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-02  9:34         ` Lennert Buytenhek
@ 2015-06-02  9:53           ` Christoffer Holmstedt
  2015-06-02 10:15           ` Alexander Aring
  1 sibling, 0 replies; 9+ messages in thread
From: Christoffer Holmstedt @ 2015-06-02  9:53 UTC (permalink / raw)
  To: Lennert Buytenhek; +Cc: Alexander Aring, Varka Bhadram, linux-wpan

On Tue, Jun 02, 2015 at 12:34:51PM +0300, Lennert Buytenhek wrote:
> On Tue, Jun 02, 2015 at 09:38:27AM +0200, Christoffer Holmstedt wrote:
> 
> > > > This is for the same reason as above. Alignment in the output, it is a trade
> > > > off between "readability" in two different ways. Alignment in the output or
> > > > printing the full word "Unknown". I will change this to "Unknown" and we can
> > > > change it at a later date if it ever shows up and mess up alignment. In any
> > > > case if "Unknown" shows up the actual frequency should be added instead of
> > > > fixing alignment. ;)
> > > > 
> > > 
> > > Then maybe some "-" instead "unkown", is this better, or it's too small
> > > then?
> > > 
> > 
> > The more I think about it the more I feel "Unknown" is better. If for some
> > reason the channel page and channel combination is not listed and "Unknown" is
> > printed the last thing the user will care about is alignment in the output.
> > 
> > Channel page and channel number information will not change that often
> > so we should be able to keep up with future changes (additions). I have
> > tried to get hold of the 802.15.4-2015 draft from March/April but
> > without success. The local university will charge me ~350€ or something
> > in that region for it. I wanted it to see if any new channel
> > pages/channels have been added since -2011 edition.
> 
> There are some amendments already available for download that
> document new channel pages:
> 
> 802.15.4f-2012.pdf: channel pages 7, 8
> 802.15.4g-2012.pdf: channel pages 9, 10
> 802.15.4j-2013.pdf: channel page 11
> 802.15.4k-2013.pdf: channel page 12
> 802.15.4p-2014.pdf: channel page 13

Yea, I haven't read them yet but I assumed that was the case, will look into
that. In the meantime I believe v2 can be merged and channel pages 7-13 will
added in future patches.

-- 
Christoffer Holmstedt

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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-02  9:34         ` Lennert Buytenhek
  2015-06-02  9:53           ` Christoffer Holmstedt
@ 2015-06-02 10:15           ` Alexander Aring
  2015-06-02 10:37             ` Lennert Buytenhek
  1 sibling, 1 reply; 9+ messages in thread
From: Alexander Aring @ 2015-06-02 10:15 UTC (permalink / raw)
  To: Lennert Buytenhek; +Cc: Christoffer Holmstedt, Varka Bhadram, linux-wpan

On Tue, Jun 02, 2015 at 12:34:51PM +0300, Lennert Buytenhek wrote:
> On Tue, Jun 02, 2015 at 09:38:27AM +0200, Christoffer Holmstedt wrote:
> 
> > > > This is for the same reason as above. Alignment in the output, it is a trade
> > > > off between "readability" in two different ways. Alignment in the output or
> > > > printing the full word "Unknown". I will change this to "Unknown" and we can
> > > > change it at a later date if it ever shows up and mess up alignment. In any
> > > > case if "Unknown" shows up the actual frequency should be added instead of
> > > > fixing alignment. ;)
> > > > 
> > > 
> > > Then maybe some "-" instead "unkown", is this better, or it's too small
> > > then?
> > > 
> > 
> > The more I think about it the more I feel "Unknown" is better. If for some
> > reason the channel page and channel combination is not listed and "Unknown" is
> > printed the last thing the user will care about is alignment in the output.
> > 
> > Channel page and channel number information will not change that often
> > so we should be able to keep up with future changes (additions). I have
> > tried to get hold of the 802.15.4-2015 draft from March/April but
> > without success. The local university will charge me ~350€ or something
> > in that region for it. I wanted it to see if any new channel
> > pages/channels have been added since -2011 edition.
> 
> There are some amendments already available for download that
> document new channel pages:
> 
> 802.15.4f-2012.pdf: channel pages 7, 8
> 802.15.4g-2012.pdf: channel pages 9, 10
> 802.15.4j-2013.pdf: channel page 11
> 802.15.4k-2013.pdf: channel page 12
> 802.15.4p-2014.pdf: channel page 13

mhhh, I looked into this. At the moment we have a highest channel number
define (don't asking me where this comes from, was before there) [0]. I
thought somewhere from the standard, that's why it's inside
ieee802154.h.

I see for example 802.15.4k-2013 that the "phyCurrentChannel" range is
above of them. e.g. Table 681. Currently we save it in some array file
and the current channel is a bitfield [1].

So I think if we support it in kernel, we need some more granularity
representation of the channels/pages, maybe also introduce some enums
about band identifier information and such things.

I want to note that only.


The current nl802154 for asking supported channel/page should be easily
extendable since we doing for_each_nested stuff there. But Currently there
is a lack of support for channel/page stuff, the datatype is also "u8" and
seems also to be something which fits not in there like "current channel
range: 1-416".

Oh well, that would be fun to change it again. :-)

- Alex

[0] http://lxr.free-electrons.com/source/include/linux/ieee802154.h#L42
[1] http://lxr.free-electrons.com/source/include/net/cfg802154.h#L85

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

* Re: [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities
  2015-06-02 10:15           ` Alexander Aring
@ 2015-06-02 10:37             ` Lennert Buytenhek
  0 siblings, 0 replies; 9+ messages in thread
From: Lennert Buytenhek @ 2015-06-02 10:37 UTC (permalink / raw)
  To: Alexander Aring; +Cc: Christoffer Holmstedt, Varka Bhadram, linux-wpan

On Tue, Jun 02, 2015 at 12:15:17PM +0200, Alexander Aring wrote:

> > > > > This is for the same reason as above. Alignment in the output, it is a trade
> > > > > off between "readability" in two different ways. Alignment in the output or
> > > > > printing the full word "Unknown". I will change this to "Unknown" and we can
> > > > > change it at a later date if it ever shows up and mess up alignment. In any
> > > > > case if "Unknown" shows up the actual frequency should be added instead of
> > > > > fixing alignment. ;)
> > > > > 
> > > > 
> > > > Then maybe some "-" instead "unkown", is this better, or it's too small
> > > > then?
> > > > 
> > > 
> > > The more I think about it the more I feel "Unknown" is better. If for some
> > > reason the channel page and channel combination is not listed and "Unknown" is
> > > printed the last thing the user will care about is alignment in the output.
> > > 
> > > Channel page and channel number information will not change that often
> > > so we should be able to keep up with future changes (additions). I have
> > > tried to get hold of the 802.15.4-2015 draft from March/April but
> > > without success. The local university will charge me ~350€ or something
> > > in that region for it. I wanted it to see if any new channel
> > > pages/channels have been added since -2011 edition.
> > 
> > There are some amendments already available for download that
> > document new channel pages:
> > 
> > 802.15.4f-2012.pdf: channel pages 7, 8
> > 802.15.4g-2012.pdf: channel pages 9, 10
> > 802.15.4j-2013.pdf: channel page 11
> > 802.15.4k-2013.pdf: channel page 12
> > 802.15.4p-2014.pdf: channel page 13
> 
> mhhh, I looked into this. At the moment we have a highest channel number
> define (don't asking me where this comes from, was before there) [0]. I
> thought somewhere from the standard, that's why it's inside
> ieee802154.h.
> 
> I see for example 802.15.4k-2013 that the "phyCurrentChannel" range is
> above of them. e.g. Table 681. Currently we save it in some array file
> and the current channel is a bitfield [1].
> 
> So I think if we support it in kernel, we need some more granularity
> representation of the channels/pages, maybe also introduce some enums
> about band identifier information and such things.
> 
> I want to note that only.

I'm guessing that it's probably because page 0 supports channels 0-26,
and before 802.15.4-2006 there was no concept of channel pages at all.


> The current nl802154 for asking supported channel/page should be easily
> extendable since we doing for_each_nested stuff there. But Currently there
> is a lack of support for channel/page stuff, the datatype is also "u8" and
> seems also to be something which fits not in there like "current channel
> range: 1-416".
> 
> Oh well, that would be fun to change it again. :-)

:-)

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

end of thread, other threads:[~2015-06-02 10:37 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-01 13:35 [PATCH wpan-tools] info: add frequency to channel listing for phy capabilities Christoffer Holmstedt
2015-06-02  4:10 ` Varka Bhadram
2015-06-02  6:08   ` Christoffer Holmstedt
2015-06-02  7:09     ` Alexander Aring
2015-06-02  7:38       ` Christoffer Holmstedt
2015-06-02  9:34         ` Lennert Buytenhek
2015-06-02  9:53           ` Christoffer Holmstedt
2015-06-02 10:15           ` Alexander Aring
2015-06-02 10:37             ` Lennert Buytenhek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.