Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of 2014FEB4_Vibrometro_Xbee by
Revision 2:a2b90ac0b81b, committed 2013-07-11
- Comitter:
- jlpalaci
- Date:
- Thu Jul 11 00:31:52 2013 +0000
- Parent:
- 1:3349d1ea05a2
- Child:
- 3:8125d6b7afff
- Commit message:
- Protocolo de comunicaci?n establecido mediante el env?o de caracteres: s, inicia conversi?n y almacenamiento de datos; o, abre el archivo de datos; r, lee el buffer y envia un paquete de 504 caracteres; c, cierra el archivo.
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Jul 09 01:19:28 2013 +0000
+++ b/main.cpp Thu Jul 11 00:31:52 2013 +0000
@@ -15,11 +15,12 @@
//Comunicación Xbee
Serial xbee(PTA2,PTA1);
-
+#define muestreo 2
FILE * fp1;
FILE * fp2;
-int inicio=0;
-int fin=0;
+int inicio = 0;
+int fin = 0;
+int j = 0;
char read [64] = {0};
char readvar [64] = {0};
@@ -30,26 +31,34 @@
g_sel = 0; //Ajusta la sensibilidad a 1.5g (cambiar a 1 para ajustar sensibilidad a 6g)
while(1) {
- while(read[0]==0) {
- if(xbee.readable()) read [0] = xbee.getc();
- }
read [0] = 0;
+ while(read[0]==0) if(xbee.readable()) read [0] = xbee.getc();
- fp1 = fopen ("/sd/test.txt","w");
+ switch(read[0]) {
+ case 's':
+ fp1 = fopen ("/sd/test.txt","w");
- reloj.start();
- inicio=reloj.read_us();
+ reloj.start();
+ inicio=reloj.read_us();
- for (int i=0;i<100;i++) fprintf (fp1,"%04X%04X%04X\n",ain_x.read_u16(),ain_y.read_u16(),ain_z.read_u16());
- fin = reloj.read_us ();
- fprintf (fp1,"%012d\n",fin-inicio);
- fclose (fp1);
-
- fp2 = fopen ("/sd/test.txt","r");
- for (int i=0;i<101;i++) {
- fscanf (fp2,"%s",readvar);
- xbee.printf("%s",readvar);
+ for (int i=0; i<125; i++) fprintf (fp1,"%04X%04X%04X\n",ain_x.read_u16(),ain_y.read_u16(),ain_z.read_u16());
+ fin = reloj.read_us ();
+ fprintf (fp1,"%012d\n",fin-inicio);
+ fclose (fp1);
+ break;
+ case 'o':
+ fp2 = fopen ("/sd/test.txt","r");
+ break;
+ case 'r':
+ for (int i=0; i<42; i++) {
+ fscanf (fp2,"%s",readvar);
+ xbee.printf("%s",readvar);
+ }
+ xbee.putc('\n');
+ break;
+ case 'c':
+ fclose (fp2);
+ break;
}
- fclose (fp2);
}
}
\ No newline at end of file
