Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10874

Re: problem with bcd and a number

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.031
X-Spam-Evidence '*H*': 0.94; '*S*': 0.00; 'something,': 0.07; 'from:addr:python': 0.09; 'wrote:': 0.15; 'from:addr:mrabarnett.plus.com': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'packet': 0.16; 'received:84.92': 0.16; 'received:84.92.122': 0.16; 'received:84.92.122.60': 0.16; 'reply-to:addr:python-list': 0.16; 'bytes': 0.19; 'subject:problem': 0.19; 'header:In-Reply-To:1': 0.22; 'trying': 0.23; 'parse': 0.23; 'byte': 0.25; 'there.': 0.25; 'hey': 0.26; 'received:84': 0.28; 'all,': 0.28; 'second': 0.29; 'port.': 0.30; 'subject:number': 0.30; 'thanks': 0.31; 'this.': 0.31; 'to:addr:python-list': 0.34; 'header:User-Agent:1': 0.34; 'reply-to:addr:python.org': 0.35; 'pull': 0.37; 'but': 0.37; 'subject:: ': 0.38; 'two': 0.38; 'subject:with': 0.39; 'to:addr:python.org': 0.39; 'missing': 0.40; 'where': 0.40; 'maximum': 0.62; 'radio': 0.63; 'serial': 0.71; 'header:Reply- To:1': 0.71; 'reply-to:no real name:2**0': 0.72; '100': 0.72; '100%': 0.82; 'need,': 0.91
X-IronPort-Anti-Spam-Filtered true
X-IronPort-Anti-Spam-Result AvMGAFzzOk7Unw4U/2dsb2JhbABDmFKPGHeBQAEBBThAEQsIEAkWDwkDAgECAUUTCAEBh2rCCYZCBJgCi14
Date Thu, 04 Aug 2011 20:35:18 +0100
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0
MIME-Version 1.0
To python-list@python.org
Subject Re: problem with bcd and a number
References <31c8d075-2901-46eb-adcf-1c1803ab7938@a4g2000yqg.googlegroups.com>
In-Reply-To <31c8d075-2901-46eb-adcf-1c1803ab7938@a4g2000yqg.googlegroups.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
Reply-To python-list@python.org
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1901.1312486523.1164.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1312486523 news.xs4all.nl 23918 [2001:888:2000:d::a6]:50756
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10874

Show key headers only | View raw


On 04/08/2011 19:26, nephish wrote:
> Hey all,
>
> I have been trying to get my head around how to do something, but i am
> missing how to pull it off.
> I am reading a packet from a radio over a serial port.
>
> i have " two bytes containing the value i need.  The first byte is the
> LSB, second is MSB.  Both bytes are BCD-encoded, with the LSB
> containing digits zX and MSB containing digits xy.  The system speed
> is then xyz%, where 100% means maximum speed and would be given by
> bytes 00(LSB) 10(MSB)."
>
> that is a quote from the documentation.
> Anyway, i am able to parse out the two bytes i need, but don't know
> where to go from there.
>
> thanks for any tips on this.

The value is MSB * 100 + (LSB >> 4) * 10 + (LSB & 0xF)

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

problem with bcd and a number nephish <nephish@gmail.com> - 2011-08-04 11:26 -0700
  Re: problem with bcd and a number Ethan Furman <ethan@stoneleaf.us> - 2011-08-04 12:44 -0700
  Re: problem with bcd and a number MRAB <python@mrabarnett.plus.com> - 2011-08-04 20:35 +0100
    Re: problem with bcd and a number Christoph Hansen <ch@radamanthys.de> - 2011-08-04 21:52 +0200
      Re: problem with bcd and a number Peter Pearson <ppearson@nowhere.invalid> - 2011-08-05 16:01 +0000
  Re: problem with bcd and a number Ethan Furman <ethan@stoneleaf.us> - 2011-08-04 13:14 -0700

csiph-web