Hey thanks,
i finally did get a function working.
i posted it on www.bitsbam.com
i did guess that the puchMsg++ ment that it was iterating through the bytes
of an array.
And Kent and Alan helped me get through the other parts.
I am glad for all this help, because this is an issue that comes up
i
>> i have a c function from some modbus documentation that i need to
>> translate into python.
>> unsigned short CRC16(puchMsg, usDataLen)
>> unsigned char *puchMsg ;
>> unsigned short usDataLen ;
>> {
>> unsigned char uchCRCHi = 0xFF ;
>> unsigned char uchCRCLo = 0xFF ;
>> unsigned u
"shawn bright" <[EMAIL PROTECTED]> wrote
> oh, here is what i have so far, but is not giving me the right
> values
>
> def crc16(data):
> crc_hi = 0xff
> crc_lo = 0xff
> for x in data:
> crc_index = crc_hi ^ x
So far so good..
> crc_hi = crc_lo ^ (crc_hi |
Thanks Alan,
so do you think my translation is close?
i do not know a lick of c. Nope, not one line.
thanks
shawn
On 7/5/07, Alan Gauld <[EMAIL PROTECTED]> wrote:
>
> "shawn bright" <[EMAIL PROTECTED]> wrote
> while (usDataLen––)
> {
> uIndex = uchCRCHi ^ *puchMsgg++ ;
> u
"shawn bright" <[EMAIL PROTECTED]> wrote
while (usDataLen––)
{
uIndex = uchCRCHi ^ *puchMsgg++ ;
uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex} ;
uchCRCLo = auchCRCLo[uIndex] ;
}
return (uchCRCHi << 8 | uchCRCLo) ;
}
> this part ' auchCRCHi[uIndex};
> it looks
oh, here is what i have so far, but is not giving me the right values
def crc16(data):
crc_hi = 0xff
crc_lo = 0xff
for x in data:
crc_index = crc_hi ^ x
crc_hi = crc_lo ^ (crc_hi | crc_index)
crc_lo = crc_lo | crc_index
return (crc_hi << 8 | c
hello all,
i have a c function from some modbus documentation that i need to
translate into python.
it looks like this:
unsigned short CRC16(puchMsg, usDataLen)
unsigned char *puchMsg ;
unsigned short usDataLen ;
{
unsigned char uchCRCHi = 0xFF ;
unsigned char uchCRCLo = 0xFF ;
unsi