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.
Revision 2:ff11ef31aee5, committed 2015-11-21
- Comitter:
- marlonfulla
- Date:
- Sat Nov 21 22:09:52 2015 +0000
- Parent:
- 1:273b1f91d518
- Commit message:
- Version 2.0 Paper Point-to-point 2015-11-21
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Nov 21 21:48:39 2015 +0000
+++ b/main.cpp Sat Nov 21 22:09:52 2015 +0000
@@ -1,60 +1,54 @@
+/*
+Este programa realiza el envio de ntransacciones, cada una conteniendo una cantidad de bytes igual a ncaracteres, donde cada
+uno de ellos corresponde a un caracter que por defecto es la letra A. Entre transacciones existe una pausa de tiempo igual a delay para
+estudiar el proceso de liberación del buffer de recepción.
+*/
#include "mbed.h"
-//#include "SDFileSystem.h"
-//#include <iostream>
#include <string>
-//using namespace std;
-
Serial xbee(USBTX,USBRX);
Timer reloj;
-string caracter,tira;
-int npack,delay,ncharacters;
+string caracter,transaccion;
+int ntransacciones,delay,ncaracteres;
char read[64];
int tiempo;
int main()
{
-
- xbee.baud(115200);
- caracter="A";
- tira="";
-
+ xbee.baud(115200); // se define la velocidad del UART
+ caracter="A";
+ transaccion=""; //se inicializa el string transaccion
+
while(1) {
-// cin>>caracteres;
-/* xbee.scanf("%d",caracteres);
- */
- xbee.scanf("%s",read);
- ncharacters=atoi(read);
+ xbee.scanf("%s",read); // se lee el puerto
+ ncaracteres=atoi(read); // se solicita el numero de caracteres que se empaquetarán en la transacción
+ //se contruye la cadena de caracteres
for(int s=1; s<=ncharacters ;s++) {
tira=tira.append(caracter);
}
-
xbee.scanf("%s",read);
- npack=atoi(read);
+ ntransacciones=atoi(read); // se solicita el numero de transacciones
xbee.scanf("%s",read);
- delay=atoi(read);
+ delay=atoi(read); // se solicita el tiempo de pausa entre transacciones
-// cin>>recibido;
-// cin>>delay;
-
- reloj.start();
+ reloj.start(); // se inicia el cronometro
- for(int i=1; i<=npack ;i++) {
- //cout<<tira<<'\n';
- xbee.printf("%s",tira);
- wait_us(delay);
+ for(int i=1; i<=ntransacciones ;i++) {
+ xbee.printf("%s",transaccion); // se envia la tira
+ wait_us(delay); // espera la pausa entre transacciones
}
- reloj.stop();
+ reloj.stop();
tiempo=reloj.read_us();
-
- xbee.printf("%d",tiempo);
- tira="";
- reloj.reset();
+ xbee.printf("%d",tiempo); // se reporta el tiempo de envio
+
+ // se reinicia las variables
+ transaccion="";
+ reloj.reset();
}