From: Xavier L. <Ba...@us...> - 2010-03-16 22:57:53
|
This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "krobot". The branch, master has been updated via cfc472d8d590b902b4cd16f2d931f62f5677666d (commit) from edf08efe16e1a8a7154641c1fd3005da2f729eeb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- commit cfc472d8d590b902b4cd16f2d931f62f5677666d Author: Xavier Lagorce <Xav...@cr...> Date: Sat Mar 13 18:22:30 2010 +0100 The packet's checksum should be verified before using informations contained in the packet ----------------------------------------------------------------------- Changes: diff --git a/USB_Module/Robot_Interface/Firmware/ax12.c b/USB_Module/Robot_Interface/Firmware/ax12.c index e165cbf..ba1f9cb 100644 --- a/USB_Module/Robot_Interface/Firmware/ax12.c +++ b/USB_Module/Robot_Interface/Firmware/ax12.c @@ -55,7 +55,7 @@ void interruptAX12(void) { // On commence la reception d'un paquet si le buffer de reception est vide if (idx == 0 && !glbReceived) write = 1; - + // Si l'on est en train de recevoir, on traite l'octet en cours if (write == 1) { glbBuffer[idx] = buf; @@ -71,24 +71,28 @@ void interruptAX12(void) { len = buf+3; if (idx >= 3 && idx == len) { - if (glbBuffer[4] != 0) - // Il y a une erreur... - error(ERR_AX12_ERROR); - // Calcul du checksum // Check Sum = ~ (ID + Length + Instruction + Parameter1 + ... Parameter N) chksum = 0; for (i = 2; i < len; i++) - chksum+= glbBuffer[i]; + chksum+= glbBuffer[i]; if (glbBuffer[len] != (~chksum)) { error(ERR_AX12_CHKSUM); glbReceived = 0; } else { + // Le paquet est valide, on peut tester le renvoi d'erreur par l'AX12 + if (glbBuffer[4] != 0) + // Il y a une erreur... + error(glbBuffer[len]); + error(ERR_AX12_ERROR); + // Un paquet a re glbReceived = 1; } + + // On reinitialise les varaibles statiques pour le prochain paquet write = 0; idx = 0; } hooks/post-receive -- krobot |