Réponse acceptée !
Salut,
Je te donne le code pour le CRC en c++ à toi de le convertir :
void THbus::CRC (unsigned int deb, unsigned int fin,unsigned char *controle,unsigned char Position)
{
unsigned __int16 c0 = 0; //initiation de toutes les valeurs
unsigned __int16 c1 = 0;
unsigned __int16 c2 = 0;
CRTL1=CRTL2=0;
for (i=deb;i<=fin+2;i++)
{
c0 = (c0 + controle[i]) % 255;
c1 = (c0 + c1) % 255;
}
if (c0 < c1)
c2 = c0 + 255;
else
c2 = c0;
CRTL1 = (c2 - c1) % 255;
while (c1 < 2*c0) c1 = c1 + 255;
CRTL2 = (c1 - 2*c0) % 255;
controle[Position]=CRTL1;
controle[Position+1]=CRTL2;
}
Bon coding
S.L.B.