Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

CRC 8

2 réponses
Avatar
sylvain.robert
Bonjour,

JE traduit cette routine de C vers Windev j'ai un doute sur
l'op=E9rateur >>=3D. J'ai besoin de calcul=E9 le CRC pour de petite trame et=

ce sur un unit=E9 mobile (Windev mobile). Ou si quelqu'un =E0 d=E9j=E0 une
fonction Windev pour le CRC 8 elle est le bienvenue ! :)

Quelqu'un peut m'aider
/* CalcCRC8(): Computes the CCITT-CRC-8 of the indicated character,
the starting value will be the indicated CRC value. The function
must be called up, for every byte of the string, using the value of
the preceding call as a starting value. The starting value of the
first call is always 0x00.

static char CalcCRC8 ( char CRC, char character )
{ unsigned char Count;
for ( Count =3D 0; Count < 8; ++ Count )
{ if ( (CRC & 0x01) ^ (character & 0x01) !=3D 0 )
{ CRC ^=3D 0x70;
CRC >> =3D 1;
CRC |=3D 0x80;
}
else
{ CRC >>=3D 1;
CRC &=3D 0x7F;
}
Zeichen >>=3D 1;
}
return ( CRC );
}

MErci

2 réponses

Avatar
Romain PETIT
Le 23/01/2008, a supposé :
Bonjour,

JE traduit cette routine de C vers Windev j'ai un doute sur
l'opérateur >>


Décalage de bit à droite (division par 2 à chaque décalage) et
affectation du résultat dans la variable.
(comme c+=2 par exemple)

CRC >> = 1 correspond en W-Langage à CRC = CRC/2

A+

--
Romain PETIT
http://cerbermail.com/?O16kfXOFcq
(cliquez sur le lien ci-dessus pour me contacter en privé)
Avatar
patrice
attention que les crc se calcule sur des champs de bit et non des nombres
donc le "char" (usuellement 7bit+signe) de la routine doit être en fait un
"BYTE" (entier non signé sur 1 octets)

a écrit dans le message de
news:
Bonjour,

JE traduit cette routine de C vers Windev j'ai un doute sur
l'opérateur >>=. J'ai besoin de calculé le CRC pour de petite trame et
ce sur un unité mobile (Windev mobile). Ou si quelqu'un à déjà une
fonction Windev pour le CRC 8 elle est le bienvenue ! :)

Quelqu'un peut m'aider
/* CalcCRC8(): Computes the CCITT-CRC-8 of the indicated character,
the starting value will be the indicated CRC value. The function
must be called up, for every byte of the string, using the value of
the preceding call as a starting value. The starting value of the
first call is always 0x00.

static char CalcCRC8 ( char CRC, char character )
{ unsigned char Count;
for ( Count = 0; Count < 8; ++ Count )
{ if ( (CRC & 0x01) ^ (character & 0x01) != 0 )
{ CRC ^= 0x70;
CRC >> = 1;
CRC |= 0x80;
}
else
{ CRC >>= 1;
CRC &= 0x7F;
}
Zeichen >>= 1;
}
return ( CRC );
}

MErci