[Tutor] help with translating a c function to a python function
shawn bright
nephish at gmail.com
Thu Jul 5 18:40:16 CEST 2007
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 ;
unsigned uIndex ;
while (usDataLen––)
{
uIndex = uchCRCHi ^ *puchMsgg++ ;
uchCRCHi = uchCRCLo ^ auchCRCHi[uIndex} ;
uchCRCLo = auchCRCLo[uIndex] ;
}
return (uchCRCHi << 8 | uchCRCLo) ;
}
some of it i can make out, but i can't seem to figgure out
this part ' auchCRCHi[uIndex};
it looks like a typo, because there is a closing } that does not match
the opening [.
anyway, if someone could kinda give me a push, it would help me out a lot.
thanks
More information about the Tutor
mailing list