cs_kevin16
Messages postés13Date d'inscriptionsamedi 16 septembre 2006StatutMembreDernière intervention21 octobre 2007
-
20 oct. 2007 à 20:10
Profil bloqué -
21 oct. 2007 à 14:08
Bonsoir à tous !
Je dois calculer un CRC16 avec le polynome x16+x15+x2+1 ( MODBUS ) et hélas mon programme ne marche pas. Pouvez me dire ou se trouve l'erreur et si mon polynome est correctement traduit.
Merci d'avance.
CODE:
Private Sub cmdCalculer_Click()
Dim crc16 As Long
Dim n As Long
Dim poly As Long
Dim i As Integer
Dim octet(0 To 1) As String
Dim ret As Byte
poly = 98309
i = 0
crc16 = 65535
n = 0
crc16 = crc16 Xor Hex(Val(txtCRC(i).Text))
n = 0
While n < 7
ret = crc16 Mod 2
crc16 = crc16 / 2
If ret <> 0 Then
crc16 = crc16 Xor poly
End If