On Thu, 04 Aug 2011 21:52:45 +0200, Christoph Hansen
wrote:
> MRAB schrieb:
>
>> The value is MSB * 100 + (LSB>> 4) * 10 + (LSB& 0xF)
>
> i would say
>
> (MSB >> 4)*100 + (MSB & 0xF)*10 + (LSB >> 4)
>
> but who knows
I concur. I think the documentation is trying to say that the
low-order nibb
Chris Angelico wrote:
> On Fri, Aug 5, 2011 at 1:40 AM, Dan Stromberg wrote:
> print int(hex(0x72).replace('0x', ''))
>> 72
>
> Or simpler: int(hex(0x72)[2:])
>
> Although if you have it as a string, you need to ord() the string.
Or use str.encode():
>>> int("\x72".encode("hex"))
72
>>> i
On Fri, Aug 5, 2011 at 1:40 AM, Dan Stromberg wrote:
print int(hex(0x72).replace('0x', ''))
> 72
Or simpler: int(hex(0x72)[2:])
Although if you have it as a string, you need to ord() the string.
It's probably better to just do the bitwise operations though.
ChrisA
--
http://mail.python.o
It sounds like you have what you need, but here's an amusing way of dealing
with a BCD byte:
>>> print int(hex(0x72).replace('0x', ''))
72
On Thu, Aug 4, 2011 at 5:15 PM, shawn bright wrote:
> Thanks for your help on this, gents. Got it working now.
> shawn
>
> On Thu, Aug 4, 2011 at 2:28 PM, D
Thanks for your help on this, gents. Got it working now.
shawn
On Thu, Aug 4, 2011 at 2:28 PM, Dave Angel wrote:
> nibbles from a byte
--
http://mail.python.org/mailman/listinfo/python-list
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
MRAB schrieb:
The value is MSB * 100 + (LSB>> 4) * 10 + (LSB& 0xF)
i would say
(MSB >> 4)*100 + (MSB & 0xF)*10 + (LSB >> 4)
but who knows
--
http://mail.python.org/mailman/listinfo/python-list
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
nephish schrieb:
thanks for any tips on this.
I'll try.
In BCD a (decimal) digit is stored in a halfbyte (or a 'nibble'). So, in
a byte
you can store two decimal digits. For instance 42 would be
nibble1 nibble2
0100 0010
42
>>> c=0b0110
>>> c
66
>>> c >> 4
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-encode
On 01/-10/-28163 02:59 PM, 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.
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
c
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
c
13 matches
Mail list logo