Traduire language C
Forum Programmation : Traduire language C
TomsGuide.com : 800 000 inscrits répondent à toutes vos questions high-tech et informatique.
Pour obtenir de l'aide, inscrivez-vous gratuitement !
Bonjour, J’aimerais avoir la traduction en langage mathématique ou commun de l’algorithme calculant un CRC-16 afin de l’écrire sous Windev.Pour info, ce CRC permet de vérifier une trame entre un PC et un lecteur RFID. Le CRC-16 utilisé (codé sur 2 bytes) est une variante du standard CCITT-16 (Polynôme = 0x1021 / Valeur initiale = 0xFFFF). Ci-dessous l’algorithme de calcul développé en C : /** @fn void CRC_calcCrc8(u16 *crcReg, u16 poly, u16 u8Data) * @brief Standard CRC calculation on an 8-bit piece of data. To make it * CCITT-16, use poly=0x1021 and an initial crcReg=0xFFFF. * * Note: This function allows one to call it repeatedly to continue * calculating a CRC. Thus, the first time it's called, it * should have an initial crcReg of 0xFFFF, after which it can be called with its own result. * * @param *crcReg Pointer to current CRC register. * @param poly Polynomial to apply. * @param u8Data u8 data to perform CRC on. * @return None. */ void CRC_calcCrc8(short *crcReg, short poly, short u8Data) { short i; short xorFlag; short bit; short dcdBitMask = 0x80; for (i=0; i<8; i ) { // Get the carry bit. This determines if the polynomial should be xor'd // with the CRC register. xorFlag = *crcReg & 0x8000; // Shift the bits over by one. *crcReg <<= 1; // Shift in the next bit in the data byte bit = ((u8Data & dcdBitMask) == dcdBitMask); *crcReg |= bit; // XOR the polynomial if (xorFlag) { *crcReg = *crcReg ^ poly; } // Shift over the dcd mask dcdBitMask >>= 1; } } Merci!!!
Tout sur une ligne, je ne lis pas.
Un bel exemple de "code obfuscation"?
C'est fou, un tout petit quelque chose manque à un texte, et il devient illisible.
Non, c'est juste le post qui est foireux, d'autant que ce n'est qu'un calcul CRC.
Il y a 1456 utilisateurs connus et inconnus. Pour voir la liste des connectés connus, cliquez ici.
