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
Diff: main.cpp
- Revision:
- 8:1814fd00a71e
- Parent:
- 7:d1eba8f22f3e
diff -r d1eba8f22f3e -r 1814fd00a71e main.cpp
--- a/main.cpp Wed Jan 08 05:13:45 2014 +0000
+++ b/main.cpp Wed Feb 05 00:18:59 2014 +0000
@@ -1,4 +1,6 @@
#include "mbed.h"
+#include <string>
+#include <iostream>
#include "SDFileSystem.h"
//#include <string>
@@ -15,6 +17,7 @@
SDFileSystem sd(PTD2, PTD3, PTD1, PTD0,"sd");
//Comunicación Xbee
Serial xbee(PTA2,PTA1);
+
//Serial xbee(USBTX,USBRX);
@@ -26,29 +29,73 @@
int samples = 1;
char read [64] = {0};
char readvar [512] = {0};
+int imax;
+int delay=27;
+
int main()
{
+ std::string readvarstr;
+ std::string xbeeout;
//xbee.baud(9600);
xbee.baud(115200);
reloj.start();
slp = 1; //Habilitado el modo de operación normal (MMA7361L)
g_sel = 0; //Ajusta la sensibilidad a 1.5g (cambiar a 1 para ajustar sensibilidad a 6g)
+
while(1) {
//char read [64] = {0};
//char readvar [512] = {0};
xbee.scanf("%s",read); //Espera la recepción de caracteres
+
switch(read[0]) {
case 'r': //Lee la información de la memoria SD y la envía mediante Xbee
//if(read[1]=='1') { //Nombre para modulo 1...
fp2 = fopen ("/sd/test.txt","r");
- for (int i=0; i<samples/3; i++) {
- fscanf (fp2,"%s",readvar);
- xbee.printf("%s",readvar);
- xbee.putc('\n');
+
+ //El numero de muestras debe ser multiplo de 42
+ imax=samples/42;
+
+ xbee.printf("%s %d \n","numero de lineas",imax);
+
+ reloj.start();
+
+ for (int i=1; i<=imax; i++) {
+ fscanf (fp2,"%s \n",readvar);
+
+ for(int l=1;l<=5;l++){
+ xbee.printf("%s",string (readvar,100*(l-1),100));
+ wait_ms(28); //pausa entre paquetes
+ }
+ xbee.printf("%s \n",string (readvar,501,504));
+ wait_ms(28); ////pausa entre paquetes
}
+ xbee.printf("%d \n",reloj.read_us());
+
+/* for(int k=0; k<5; k++) {
+ for(int j=1; j<=100; j++) {
+ xbeeout[j]=readvar[100*k+j];
+ }
+ xbee.printf("%s",xbeeout)
+ wait_ms(27);
+ }
+*/
+/* for(int j=1; j<=4; j++) {
+ xbeeout[j]=readvar[500+j];
+ }
+
+ xbee.printf("%s",xbeeout);
+ wait_ms(27);
+ xbee.putc('\n');
+ */
+
+// xbee.printf("%s",readvar);
+// xbee.putc('\n');
+
+
+
fclose (fp2);
//}
break;
@@ -65,7 +112,7 @@
//Ciclo de lectura de los ejes x, y, z del acelerómetro triaxial MMA7361L
for(int i=1; i<=samples; i++) {
fprintf (fp1,"%04X%04X%04X",ain_x.read_u16(),ain_y.read_u16(),ain_z.read_u16());
- if((i>=42) && (i%3==42)) fprintf (fp1,"\n"); //cambiar a 3 para longitud de 12 caracteres
+ if((i>=42) && (i%42==0)) fprintf (fp1,"\n"); //permite escribir en la memoria SD líneas cada una con 42 muestras ó 502 caracteres
}
//Tiempo transcurrido desde la ejecución del reloj
fin = reloj.read_us();
