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.
ecocom.cpp
00001 /************************************ 00002 Software del mbed para el Ecotron. 00003 (c) Miquel Carbonell Piqueres 00004 Diciembre de 2011. 00005 ************************************/ 00006 /************************************ 00007 Arhivo: ecocom.cpp 00008 Disenyo de la clase para el puerto 00009 de comunicaciones serie empleado en 00010 el sistema Ecotron. 00011 ************************************/ 00012 00013 #include "ecocom.h" 00014 00015 ecocom::ecocom(): Serial (p28,p29){ //Pins de E/S del Ecotron. 00016 00017 baud(57600); //Velocidad convenida por defecto. 00018 format(8,Serial::None,1); //8 bits por palabra, sin paridad y 1 bit de parada. 00019 posChar=0; 00020 RxCompleta=false; 00021 attach(this,&ecocom::RxDatos,Serial::RxIrq); 00022 } 00023 00024 void ecocom::TxDatos(char *c){ 00025 00026 if (c==NULL) 00027 return; 00028 printf("$WP+DCMSG=%s\r\n",c); 00029 00030 } 00031 00032 void ecocom::RxDatos(){ 00033 00034 char c; 00035 while (readable()){ 00036 c=getc(); 00037 RxBuffer[posChar++]=c; 00038 if ((posChar==(MAX_CAD-1))||((c=='\r')||(c=='\n'))){ 00039 //Ignorar cadenas vacias: 00040 if (((c=='\r')||(c=='\n'))&&(posChar==1)){ 00041 posChar=0; 00042 return; 00043 } 00044 RxBuffer[posChar]='\x0'; 00045 posChar=0; 00046 sprintf(RxCad,RxBuffer); 00047 RxCompleta=true; 00048 break; 00049 } 00050 } 00051 } 00052
Generated on Sat Jul 23 2022 00:17:04 by
1.7.2