Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #10877
| Date | 2011-08-04 13:14 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: problem with bcd and a number |
| References | <31c8d075-2901-46eb-adcf-1c1803ab7938@a4g2000yqg.googlegroups.com> <4E3AF476.9050502@mrabarnett.plus.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.1902.1312487936.1164.python-list@python.org> (permalink) |
MRAB wrote: > 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) Not according to the docs -- msb has two digits, lsb has one and garbage. ~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll 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