473,324 Members | 2,002 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

CRC CCITT UPDATE in Python

Please,

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));
}

Source: http://tldp.tuxhilfe.de/linuxfocus/c...nual-1.0.4.pdf

Reason, I would like to code in Python one simulator from one
code C++ AVR

Thanks.,

../Fã -Py -Thorneiro

Apr 1 '07 #1
2 2878
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
Apr 1 '07 #2
En Sun, 01 Apr 2007 10:10:04 -0300, [Py Thorneiro] <py********@gmail.com>
escribió:

[Py Thorneiro]
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));
}
[Martin v. Löwis]
>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).
[Py Thorneiro]
Please, could you help me? :-) How to port this hi8 and lo8 to
Python,
is there some function similar?
That's exactly what MvL said. To put it more clearly:

def lo8(i16):
return i16 & 0xff

def hi8(i16):
return (i16 >8) & 0xff

--
Gabriel Genellina

Apr 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: VenuGopal | last post by:
Hi, I am recording a wave file using the MCI. Currently It rcords in the PCM format. Now i want to save the file in the CCITT format (any of the algorithms will do). I see MSDN and i come to...
2
by: RadGar | last post by:
Hi, I'm reposting my question in this group from comp.arch.embedded - as it was suggested to me that it might be better to do so. In advance to all reading: this is meant mostly for people who...
0
by: Brad Simon | last post by:
I have an app that needs to create a CRC-16 CCITT code for a small string (less than 16 characters). I cannot find any sample code that will help me do it. My language of choice is VB .NET 2.0,...
1
by: Ed | last post by:
Please help me with an algorithm to calculate CRC-CCITT in C++ Thanks
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.