netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Roskin <proski@gnu.org>
To: jt@hpl.hp.com
Cc: NetDev <netdev@vger.kernel.org>
Subject: Re: dBm cutoff at -1dBm is too low
Date: Sun, 07 May 2006 23:35:50 -0400	[thread overview]
Message-ID: <1147059350.32348.10.camel@dv> (raw)
In-Reply-To: <20060505172818.GA7543@bougret.hpl.hp.com>

On Fri, 2006-05-05 at 10:28 -0700, Jean Tourrilhes wrote:
> 	I tried to use 'signed' in the struct a long while ago, and
> for some reason it broke left and right, I don't remember the
> details. So, whatever we do, it would not be straightforward.

Then let's keep the structure as is and change what iwconfig is
displaying:

--- iwlib.c
+++ iwlib.c
@@ -1400,7 +1400,7 @@ iw_print_stats(char *		buffer,
 	    {
 	      len = snprintf(buffer, buflen, "Signal level%c%d dBm  ",
 			     qual->updated & IW_QUAL_LEVEL_UPDATED ? '=' : ':',
-			     qual->level - 0x100);
+			     ((qual->level - 192) & 0xff) + 192);
 	      buffer += len;
 	      buflen -= len;
 	    }

Semantically, it's already nonsense to use an unsigned number for a
value that is almost always negative.  The true meaning of qual->level
is already a subject of convention.  So let's just adjust this
convention so that we don't punish the clients that report valid
positive dBm values.

The client calculates a value (perhaps an integer) and pushes it into
unsigned char in the hope that the client side can understand it using
the common sense.  Interpreting 0dBm as -256dBm goes against the common
sense.  This has to be specifically worked around in the drivers.

Of course, it would be nice to document it somewhere, and to have
constants e.g.

#define DBM_MIN -192
#define DBM_MAX 63

-- 
Regards,
Pavel Roskin


      parent reply	other threads:[~2006-05-08  3:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-05-04 16:37 dBm cutoff at -1dBm is too low Pavel Roskin
2006-05-05 17:28 ` Jean Tourrilhes
2006-05-07  3:32   ` Pavel Roskin
2006-05-08 17:17     ` Jean Tourrilhes
2006-05-09  4:54       ` Pavel Roskin
2006-05-09 18:54         ` Jean Tourrilhes
2006-05-08  3:35   ` Pavel Roskin [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1147059350.32348.10.camel@dv \
    --to=proski@gnu.org \
    --cc=jt@hpl.hp.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).