Re: CRC CCITT UPDATE in Python

2007-04-01 Thread Py Thorneiro

Hi Martin!

 OK, thanks; but its work in AVR... After compile it and work in agree
with the device that I need to talk, the software work fine, but I would
like port it to PC in Python...

Hi Folks,

 So sorry, but I try find it googling, searkoding (
http://www.koders.com) and try understand so bether and unhapilly don´t had
sucess... I try normally  the hands-on technique and to practise the DIY
philosophy; but in this case my mind isn´t helping me!:-)

 Please, could you help me? :-) How to port this hi8 and lo8 to Python,
is there some function similar?

Tnx,

./Fernando -Py - thorneiro -


On 4/1/07, "Martin v. Löwis" <[EMAIL PROTECTED]> wrote:



>   Please, is there here some good soul that understand this
> functions hi8 and lo8 (from GCC AVR) and can help me to port it to
> Python?
>
> uint16_t
> crc_ccitt_update (uint16_t crc, uint8_t data)
> {
>data ˆ= lo8 (crc);
>data ˆ= data << 4;
>return uint16_t)data << 8) | hi8 (crc)) ˆ (uint8_t)(data >> 4)
> ˆ ((uint16_t)data << 3));
> }

Most likely, lo8(crc) == crc & 0xFF, and hi8(crc) == (crc >> 8) & 0xFF
(the last bit masking might be redundant, as crc should not occupy more
than 16 bits, anyway).

HTH,
Martin


-- 
http://mail.python.org/mailman/listinfo/python-list

Port Function crc_ccitt_update from C++

2007-04-01 Thread Py Thorneiro

Hi folks,

   Please, I don´t understand exactly what this function CRC CCITT UPDATE
in C++ AVR can be ported to Python..

uint16_t
crc_ccitt_update (uint16_t crc, uint8_t data)
{
  data ˆ= lo8 (crc);
  data ˆ= data << 4;
  return uint16_t)data << 8) | hi8 (crc)) ˆ (uint8_t)(data >> 4)
ˆ ((uint16_t)data << 3));
}

Source:
http://tldp.tuxhilfe.de/linuxfocus/common/src2/article352/avr-libc-user-manual-1.0.4.pdf

 In parts reason this lo8 and hi8, is there some good soul here that
can help-me with this conversion?

I try seach in Google and Koders some code that use it, but I don´t had
sucess...


Big Hugs
Thanks
Regards.


-Py -Thorneiro
-- 
http://mail.python.org/mailman/listinfo/python-list