summaryrefslogtreecommitdiff
path: root/2004/n/asserv/src
diff options
context:
space:
mode:
authorschodet2003-12-13 23:08:30 +0000
committerschodet2003-12-13 23:08:30 +0000
commitf5dc1b604b0fa17f0be6c5368e7841e841ef9cea (patch)
tree6de4b9675ec62645dd5baecf89153678fd0083d1 /2004/n/asserv/src
parentbbd4ad1a1034dd4776db3d364b5fa268923124c1 (diff)
Correction d'un bug horrible dans serial_unreliable_send.
Implémentation du rapport des compteurs.
Diffstat (limited to '2004/n/asserv/src')
-rw-r--r--2004/n/asserv/src/motor.c11
-rw-r--r--2004/n/asserv/src/serial.c14
-rw-r--r--2004/n/asserv/src/serial.h20
3 files changed, 44 insertions, 1 deletions
diff --git a/2004/n/asserv/src/motor.c b/2004/n/asserv/src/motor.c
index c820cc0..b529e87 100644
--- a/2004/n/asserv/src/motor.c
+++ b/2004/n/asserv/src/motor.c
@@ -39,6 +39,7 @@ unsigned int motor_pid_int; /* Compteur d'interruptions 2 entre deux
short motor_stat; /* Report motor stats. */
unsigned int motor_stat_delay; /* Delay between stats. */
unsigned int motor_stat_delay_cpt; /* Delay counter. */
+short motor_cpt; /* Report motors counters. */
/* Moteurs. */
signed int motor_g_vdes, motor_g_vacc; /* Vitesse désirée, actuelle. */
@@ -64,6 +65,7 @@ motor_init (void)
motor_stat = 0;
motor_stat_delay = 101;
motor_stat_delay_cpt = 0;
+ motor_cpt = 0;
motor_g_vdes = 0; motor_g_vacc = 0;
motor_d_vdes = 0; motor_d_vacc = 0;
motor_g_cpt_av = 0; motor_g_cpt_ar = 0;
@@ -368,6 +370,11 @@ TIMER2_isr ()
motor_update_left_speed ();
motor_update_right_speed ();
serial_parse ();
+ if (motor_cpt)
+ {
+ serial_send_motor_cpt (motor_g_cpt, motor_d_cpt);
+ serial_unreliable_send_eob ();
+ }
}
motor_pid_int++;
}
@@ -408,6 +415,10 @@ motor_parse (void)
serial_recv_bool (motor_stat);
serial_send_ok ('m');
return 1;
+ case 'c':
+ serial_recv_bool (motor_cpt);
+ serial_send_ok ('c');
+ return 1;
case 'g':
serial_recv_bool (motor_asservi);
motor_toggle_asservi ();
diff --git a/2004/n/asserv/src/serial.c b/2004/n/asserv/src/serial.c
index 0c113e7..ef18c02 100644
--- a/2004/n/asserv/src/serial.c
+++ b/2004/n/asserv/src/serial.c
@@ -196,6 +196,18 @@ serial_send_motor_stat (char side, unsigned int vacc, unsigned long &e, unsigned
serial_unreliable_send_char (CRLF);
}
+/* Envois les compteurs moteurs. */
+void
+serial_send_motor_cpt (signed long &g, signed long &d)
+{
+ serial_unreliable_send_char ('!');
+ serial_unreliable_send_char ('c');
+ serial_unreliable_send_long (g);
+ serial_unreliable_send_char (',');
+ serial_unreliable_send_long (d);
+ serial_unreliable_send_char (CRLF);
+}
+
/* Envoie un caractère. */
void
serial_send_char (char c)
@@ -223,7 +235,7 @@ serial_unreliable_send_char (char c)
/* Drop si une transmission est en cours. */
if (serial_send_full || serial_unreliable_send_full) return;
/* Ajoute le caractère. */
- serial_send_buf[serial_send_buf_n++] = c;
+ serial_unreliable_send_buf[serial_unreliable_send_buf_n++] = c;
/* Si fin de buffer, on envois. */
if (c == EOB)
{
diff --git a/2004/n/asserv/src/serial.h b/2004/n/asserv/src/serial.h
index e954c75..0dfbf9d 100644
--- a/2004/n/asserv/src/serial.h
+++ b/2004/n/asserv/src/serial.h
@@ -77,18 +77,38 @@ serial_send_ok (char c);
void
serial_send_motor_stat (char side, unsigned int vacc, unsigned long &e, unsigned long &pwm);
+/* Envois les compteurs moteurs. */
+void
+serial_send_motor_cpt (signed long &g, signed long &d);
+
/* Envoie un caractère. */
void
serial_send_char (char c);
+/* Envoie un caractère non-fiable. */
+void
+serial_unreliable_send_char (char c);
+
/* Envoie un long. */
void
serial_send_long (unsigned long &value);
+/* Envoie un long non-fiable. */
+void
+serial_unreliable_send_long (unsigned long &value);
+
/* Envoie un int. */
void
serial_send_int (unsigned int &value);
+/* Envoie un int non-fiable. */
+void
+serial_unreliable_send_int (unsigned int &value);
+
+/* Termine le bloc non-fiable. */
+void
+serial_unreliable_send_eob (void);
+
/* -AutoDec */
#endif /* serial_h */