All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH wpan-tools 1/2] treewide: shorten commands
@ 2015-01-20 10:35 Alexander Aring
  2015-01-20 10:35 ` [PATCH wpan-tools 2/2] interface: remove twice phy information Alexander Aring
  2015-01-20 11:05 ` [PATCH wpan-tools 1/2] treewide: shorten commands Stefan Schmidt
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Aring @ 2015-01-20 10:35 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

This patch shorten all commands. I had the idea to make a similarity
from PIB/MIB values according the 802.15.4 names convention but this is
bad for fast shell hacking. Mainly I remove the underscore and some
additional information which are not necessary like "_addr" in
"short_addr" and "extended_addr" and such things.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 src/info.c      | 10 +++++-----
 src/interface.c | 20 ++++++++++----------
 src/mac.c       | 10 +++++-----
 src/phy.c       |  6 +++---
 4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/info.c b/src/info.c
index 83f2e3e..6ce4715 100644
--- a/src/info.c
+++ b/src/info.c
@@ -31,7 +31,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 		phy_id = nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]);
 	}
 	if (print_name && tb_msg[NL802154_ATTR_WPAN_PHY_NAME])
-		printf("wpan_phy %s\n", nla_get_string(tb_msg[NL802154_ATTR_WPAN_PHY_NAME]));
+		printf("WPANphy %s\n", nla_get_string(tb_msg[NL802154_ATTR_WPAN_PHY_NAME]));
 
 	if (tb_msg[NL802154_ATTR_CHANNELS_SUPPORTED]) {
 		unsigned char page = 0;
@@ -56,14 +56,14 @@ 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]));
+		printf("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]));
+		printf("channel: %d\n", nla_get_u8(tb_msg[NL802154_ATTR_CHANNEL]));
 
 	if (tb_msg[NL802154_ATTR_CCA_MODE]) {
 		cca_mode = nla_get_u32(tb_msg[NL802154_ATTR_CCA_MODE]);
-		printf("cca_mode: %d", cca_mode);
+		printf("cca: %d", cca_mode);
 		if (cca_mode == NL802154_CCA_ENERGY_CARRIER) {
 			enum nl802154_cca_opts cca_opt;
 
@@ -83,7 +83,7 @@ static int print_phy_handler(struct nl_msg *msg, void *arg)
 	}
 
 	if (tb_msg[NL802154_ATTR_TX_POWER])
-		printf("tx_power: %d\n", nla_get_s8(tb_msg[NL802154_ATTR_TX_POWER]));
+		printf("txpower: %d\n", nla_get_s8(tb_msg[NL802154_ATTR_TX_POWER]));
 
 	return 0;
 }
diff --git a/src/interface.c b/src/interface.c
index 095753b..9e59f15 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -187,7 +187,7 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
 		unsigned int thiswpan_phy = nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]);
 		indent = "\t";
 		if (*wpan_phy != thiswpan_phy)
-			printf("phy#%d\n", thiswpan_phy);
+			printf("WPANphy#%d\n", thiswpan_phy);
 		*wpan_phy = thiswpan_phy;
 	}
 
@@ -199,29 +199,29 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
 	if (tb_msg[NL802154_ATTR_IFINDEX])
 		printf("%s\tifindex %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_IFINDEX]));
 	if (tb_msg[NL802154_ATTR_WPAN_DEV])
-		printf("%s\twpan_dev 0x%llx\n", indent,
+		printf("%s\tWPANdev 0x%llx\n", indent,
 		       (unsigned long long)nla_get_u64(tb_msg[NL802154_ATTR_WPAN_DEV]));
 	if (tb_msg[NL802154_ATTR_EXTENDED_ADDR])
-		printf("%s\textended_addr 0x%016llx\n", indent,
+		printf("%s\textended 0x%016llx\n", indent,
 		       le64toh(nla_get_u64(tb_msg[NL802154_ATTR_EXTENDED_ADDR])));
 	if (tb_msg[NL802154_ATTR_SHORT_ADDR])
-		printf("%s\tshort_addr 0x%04x\n", indent,
+		printf("%s\tshort 0x%04x\n", indent,
 		       le16toh(nla_get_u16(tb_msg[NL802154_ATTR_SHORT_ADDR])));
 	if (tb_msg[NL802154_ATTR_PAN_ID])
-		printf("%s\tpan_id 0x%04x\n", indent,
+		printf("%s\tpan 0x%04x\n", indent,
 		       le16toh(nla_get_u16(tb_msg[NL802154_ATTR_PAN_ID])));
 	if (tb_msg[NL802154_ATTR_IFTYPE])
 		printf("%s\ttype %s\n", indent, iftype_name(nla_get_u32(tb_msg[NL802154_ATTR_IFTYPE])));
 	if (!wpan_phy && tb_msg[NL802154_ATTR_WPAN_PHY])
-		printf("%s\twpan_phy %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]));
+		printf("%s\tWPANphy %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]));
 	if (tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES])
-		printf("%s\tmax_frame_retries %d\n", indent, nla_get_s8(tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES]));
+		printf("%s\tframeretries %d\n", indent, nla_get_s8(tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES]));
 	if (tb_msg[NL802154_ATTR_MIN_BE])
-		printf("%s\tmin_be %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MIN_BE]));
+		printf("%s\tminBE %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MIN_BE]));
 	if (tb_msg[NL802154_ATTR_MAX_BE])
-		printf("%s\tmax_be %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_BE]));
+		printf("%s\tmaxBE %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_BE]));
 	if (tb_msg[NL802154_ATTR_MAX_CSMA_BACKOFFS])
-		printf("%s\tmax_csma_backoffs %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_CSMA_BACKOFFS]));
+		printf("%s\tcsmabackoffs %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_MAX_CSMA_BACKOFFS]));
 	if (tb_msg[NL802154_ATTR_LBT_MODE])
 		printf("%s\tlbt %d\n", indent, nla_get_u8(tb_msg[NL802154_ATTR_LBT_MODE]));
 
diff --git a/src/mac.c b/src/mac.c
index 703d09f..79d088b 100644
--- a/src/mac.c
+++ b/src/mac.c
@@ -37,7 +37,7 @@ static int handle_pan_id_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, pan_id, "<pan_id>",
+COMMAND(set, pan, "<panid>",
 	NL802154_CMD_SET_PAN_ID, 0, CIB_NETDEV, handle_pan_id_set, NULL);
 
 static int handle_short_addr_set(struct nl802154_state *state,
@@ -64,7 +64,7 @@ static int handle_short_addr_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, short_addr, "<short_addr>",
+COMMAND(set, short, "<addr>",
 	NL802154_CMD_SET_SHORT_ADDR, 0, CIB_NETDEV, handle_short_addr_set, NULL);
 
 static int handle_max_frame_retries_set(struct nl802154_state *state,
@@ -91,7 +91,7 @@ static int handle_max_frame_retries_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, max_frame_retries, "<retries>",
+COMMAND(set, frameretries, "<retries>",
 	NL802154_CMD_SET_MAX_FRAME_RETRIES, 0, CIB_NETDEV,
 	handle_max_frame_retries_set, NULL);
 
@@ -126,7 +126,7 @@ static int handle_backoff_exponent(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, backoff_exponents, "<min_be> <max_be>",
+COMMAND(set, backoffexponents, "<minBE> <maxBE>",
 	NL802154_CMD_SET_BACKOFF_EXPONENT, 0, CIB_NETDEV,
 	handle_backoff_exponent, NULL);
 
@@ -154,7 +154,7 @@ static int handle_max_csma_backoffs(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, max_csma_backoffs, "<backoffs>",
+COMMAND(set, csmabackoffs, "<backoffs>",
 	NL802154_CMD_SET_MAX_CSMA_BACKOFFS, 0, CIB_NETDEV,
 	handle_max_csma_backoffs, NULL);
 
diff --git a/src/phy.c b/src/phy.c
index 2e25013..994841f 100644
--- a/src/phy.c
+++ b/src/phy.c
@@ -71,7 +71,7 @@ static int handle_tx_power_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, tx_power, "<dBm>",
+COMMAND(set, txpower, "<dBm>",
 	NL802154_CMD_SET_TX_POWER, 0, CIB_PHY, handle_tx_power_set, NULL);
 
 static int handle_cca_mode_set(struct nl802154_state *state,
@@ -112,7 +112,7 @@ static int handle_cca_mode_set(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, cca_mode, "<mode|3 <1|0>>",
+COMMAND(set, cca, "<mode|3 <1|0>>",
 	NL802154_CMD_SET_CCA_MODE, 0, CIB_PHY, handle_cca_mode_set, NULL);
 
 static int handle_cca_ed_level(struct nl802154_state *state,
@@ -139,5 +139,5 @@ static int handle_cca_ed_level(struct nl802154_state *state,
 nla_put_failure:
 	return -ENOBUFS;
 }
-COMMAND(set, cca_ed_level, "<level>",
+COMMAND(set, edlevel, "<level>",
 	NL802154_CMD_SET_CCA_ED_LEVEL, 0, CIB_PHY, handle_cca_ed_level, NULL);
-- 
2.2.2


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

* [PATCH wpan-tools 2/2] interface: remove twice phy information
  2015-01-20 10:35 [PATCH wpan-tools 1/2] treewide: shorten commands Alexander Aring
@ 2015-01-20 10:35 ` Alexander Aring
  2015-01-20 11:05 ` [PATCH wpan-tools 1/2] treewide: shorten commands Stefan Schmidt
  1 sibling, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2015-01-20 10:35 UTC (permalink / raw)
  To: linux-wpan; +Cc: Alexander Aring

The phy information is already shown in a previous printout and this
code seems that it was never be functional.

Signed-off-by: Alexander Aring <alex.aring@gmail.com>
---
 src/interface.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/interface.c b/src/interface.c
index 9e59f15..559a104 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -212,8 +212,6 @@ static int print_iface_handler(struct nl_msg *msg, void *arg)
 		       le16toh(nla_get_u16(tb_msg[NL802154_ATTR_PAN_ID])));
 	if (tb_msg[NL802154_ATTR_IFTYPE])
 		printf("%s\ttype %s\n", indent, iftype_name(nla_get_u32(tb_msg[NL802154_ATTR_IFTYPE])));
-	if (!wpan_phy && tb_msg[NL802154_ATTR_WPAN_PHY])
-		printf("%s\tWPANphy %d\n", indent, nla_get_u32(tb_msg[NL802154_ATTR_WPAN_PHY]));
 	if (tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES])
 		printf("%s\tframeretries %d\n", indent, nla_get_s8(tb_msg[NL802154_ATTR_MAX_FRAME_RETRIES]));
 	if (tb_msg[NL802154_ATTR_MIN_BE])
-- 
2.2.2


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

* Re: [PATCH wpan-tools 1/2] treewide: shorten commands
  2015-01-20 10:35 [PATCH wpan-tools 1/2] treewide: shorten commands Alexander Aring
  2015-01-20 10:35 ` [PATCH wpan-tools 2/2] interface: remove twice phy information Alexander Aring
@ 2015-01-20 11:05 ` Stefan Schmidt
  2015-01-20 11:32   ` Alexander Aring
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Schmidt @ 2015-01-20 11:05 UTC (permalink / raw)
  To: 'Alexander Aring', linux-wpan

Hello.

On 20/01/15 11:35, Alexander Aring wrote:
> This patch shorten all commands. I had the idea to make a similarity
> from PIB/MIB values according the 802.15.4 names convention but this is
> bad for fast shell hacking. Mainly I remove the underscore and some
> additional information which are not necessary like "_addr" in
> "short_addr" and "extended_addr" and such things.
>
> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> ---
>   src/info.c      | 10 +++++-----
>   src/interface.c | 20 ++++++++++----------
>   src/mac.c       | 10 +++++-----
>   src/phy.c       |  6 +++---
>   4 files changed, 23 insertions(+), 23 deletions(-)

Hmm, it feels like you are going overboard with shorting things here. 
Why is the reason behind it? Just less typing? Shell auto completion 
would handle this. :)

I mean it is up to you but with this you might break scripts that are 
already out there and I think the current  commands are quite fine. 
Cutting out the underscores makes some of these hard to read imho.

regards
Stefan Schmidt



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

* Re: [PATCH wpan-tools 1/2] treewide: shorten commands
  2015-01-20 11:05 ` [PATCH wpan-tools 1/2] treewide: shorten commands Stefan Schmidt
@ 2015-01-20 11:32   ` Alexander Aring
  2015-01-20 11:47     ` Alexander Aring
  2015-01-20 14:43     ` Stefan Schmidt
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Aring @ 2015-01-20 11:32 UTC (permalink / raw)
  To: Stefan Schmidt; +Cc: linux-wpan

On Tue, Jan 20, 2015 at 11:05:26AM +0000, Stefan Schmidt wrote:
> Hello.
> 
> On 20/01/15 11:35, Alexander Aring wrote:
> >This patch shorten all commands. I had the idea to make a similarity
> >from PIB/MIB values according the 802.15.4 names convention but this is
> >bad for fast shell hacking. Mainly I remove the underscore and some
> >additional information which are not necessary like "_addr" in
> >"short_addr" and "extended_addr" and such things.
> >
> >Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> >---
> >  src/info.c      | 10 +++++-----
> >  src/interface.c | 20 ++++++++++----------
> >  src/mac.c       | 10 +++++-----
> >  src/phy.c       |  6 +++---
> >  4 files changed, 23 insertions(+), 23 deletions(-)
> 
> Hmm, it feels like you are going overboard with shorting things here. Why is
> the reason behind it? Just less typing? Shell auto completion would handle
> this. :)
> 

it's just less typing and I notice that the original iw command doesn't
have an underscore in their commands.

The first time when I hacked it, then I just took the same naming
convention in kernel implementation which use the naming convention from
802.15.4 standard (without the beginning "MAC" and "PHY" keywords). Now
I am too lazy to always type pan_id short_addr, etc...

Do you like to implement some completion stuff which can be shipped out
optionally with the wpan-tools? :-)

> I mean it is up to you but with this you might break scripts that are
> already out there and I think the current  commands are quite fine. Cutting
> out the underscores makes some of these hard to read imho.
> 

mhhh, I am unsure also about this and just gave it a try if somebody
screams I would maybe reconsider this patch. :-)

- Alex

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

* Re: [PATCH wpan-tools 1/2] treewide: shorten commands
  2015-01-20 11:32   ` Alexander Aring
@ 2015-01-20 11:47     ` Alexander Aring
  2015-01-20 14:43     ` Stefan Schmidt
  1 sibling, 0 replies; 6+ messages in thread
From: Alexander Aring @ 2015-01-20 11:47 UTC (permalink / raw)
  To: Stefan Schmidt; +Cc: linux-wpan

On Tue, Jan 20, 2015 at 12:32:31PM +0100, Alexander Aring wrote:
> On Tue, Jan 20, 2015 at 11:05:26AM +0000, Stefan Schmidt wrote:
> > Hello.
> > 
> > On 20/01/15 11:35, Alexander Aring wrote:
> > >This patch shorten all commands. I had the idea to make a similarity
> > >from PIB/MIB values according the 802.15.4 names convention but this is
> > >bad for fast shell hacking. Mainly I remove the underscore and some
> > >additional information which are not necessary like "_addr" in
> > >"short_addr" and "extended_addr" and such things.
> > >
> > >Signed-off-by: Alexander Aring <alex.aring@gmail.com>
> > >---
> > >  src/info.c      | 10 +++++-----
> > >  src/interface.c | 20 ++++++++++----------
> > >  src/mac.c       | 10 +++++-----
> > >  src/phy.c       |  6 +++---
> > >  4 files changed, 23 insertions(+), 23 deletions(-)
> > 
> > Hmm, it feels like you are going overboard with shorting things here. Why is
> > the reason behind it? Just less typing? Shell auto completion would handle
> > this. :)
> > 
> 
> it's just less typing and I notice that the original iw command doesn't
> have an underscore in their commands.
> 
> The first time when I hacked it, then I just took the same naming
> convention in kernel implementation which use the naming convention from
> 802.15.4 standard (without the beginning "MAC" and "PHY" keywords). Now
> I am too lazy to always type pan_id short_addr, etc...
> 
> Do you like to implement some completion stuff which can be shipped out
> optionally with the wpan-tools? :-)
> 
> > I mean it is up to you but with this you might break scripts that are
> > already out there and I think the current  commands are quite fine. Cutting
> > out the underscores makes some of these hard to read imho.
> > 
> 
> mhhh, I am unsure also about this and just gave it a try if somebody
> screams I would maybe reconsider this patch. :-)
> 

ok. I will drop this patch. Will resend the second patch later.

- Alex

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

* Re: [PATCH wpan-tools 1/2] treewide: shorten commands
  2015-01-20 11:32   ` Alexander Aring
  2015-01-20 11:47     ` Alexander Aring
@ 2015-01-20 14:43     ` Stefan Schmidt
  1 sibling, 0 replies; 6+ messages in thread
From: Stefan Schmidt @ 2015-01-20 14:43 UTC (permalink / raw)
  To: 'Alexander Aring'; +Cc: linux-wpan

Hello.

On 20/01/15 12:32, Alexander Aring wrote:
> On Tue, Jan 20, 2015 at 11:05:26AM +0000, Stefan Schmidt wrote:
>> Hello.
>>
>> On 20/01/15 11:35, Alexander Aring wrote:
>>> This patch shorten all commands. I had the idea to make a similarity
>> >from PIB/MIB values according the 802.15.4 names convention but this is
>>> bad for fast shell hacking. Mainly I remove the underscore and some
>>> additional information which are not necessary like "_addr" in
>>> "short_addr" and "extended_addr" and such things.
>>>
>>> Signed-off-by: Alexander Aring <alex.aring@gmail.com>
>>> ---
>>>   src/info.c      | 10 +++++-----
>>>   src/interface.c | 20 ++++++++++----------
>>>   src/mac.c       | 10 +++++-----
>>>   src/phy.c       |  6 +++---
>>>   4 files changed, 23 insertions(+), 23 deletions(-)
>>
>> Hmm, it feels like you are going overboard with shorting things here. Why
>> is
>> the reason behind it? Just less typing? Shell auto completion would handle
>> this. :)
>>
>
> it's just less typing and I notice that the original iw command doesn't
> have an underscore in their commands.
>
> The first time when I hacked it, then I just took the same naming
> convention in kernel implementation which use the naming convention from
> 802.15.4 standard (without the beginning "MAC" and "PHY" keywords).

Having the naming the same in specs, kernel and the config util is 
actually good thing. This helps newcomers to understand them more easily.

> Now I am too lazy to always type pan_id short_addr, etc...

If the primary goal would be less typing the the binary should be named 
"i" and the options a, b, c, d :)

> Do you like to implement some completion stuff which can be shipped out
> optionally with the wpan-tools? :-)

Here is a start:
_iwpan()
{
     local cur prev opts
     COMPREPLY=()
     cur="${COMP_WORDS[COMP_CWORD]}"
     prev="${COMP_WORDS[COMP_CWORD-1]}"
     opts="--debug --version phy dev set channel tx_power cca_mode 
cca_ed_level pan_id short_addr max_frame_retries backoff_exponents 
max_csma_backoffs lbt info list interface add"

     COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) )
     return 0
}
complete -F _iwpan iwpan

Just drop this in a file called iwpan in  /etc/bash_completion.d/ and a 
simple command completion would work with bash. zsh user might want to 
do their own.

This has no fancy things like completing available wpan interfaces, etc 
but it completes all commands which was what you complained about for 
typing. :)

regards
Stefan Schmidt



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

end of thread, other threads:[~2015-01-20 14:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-20 10:35 [PATCH wpan-tools 1/2] treewide: shorten commands Alexander Aring
2015-01-20 10:35 ` [PATCH wpan-tools 2/2] interface: remove twice phy information Alexander Aring
2015-01-20 11:05 ` [PATCH wpan-tools 1/2] treewide: shorten commands Stefan Schmidt
2015-01-20 11:32   ` Alexander Aring
2015-01-20 11:47     ` Alexander Aring
2015-01-20 14:43     ` Stefan Schmidt

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.