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 -vvvv


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

Reply via email to