Proyecto de Tesis en Mecatrónica. Universidad Técnica del Norte. Ernesto Palacios <mecatronica.mid@gmail.com>
Dependencies: EthernetNetIf HTTPServer QEI_hw RPCInterface mbed
main.cpp
- Committer:
- Yo_Robot
- Date:
- 2012-04-03
- Revision:
- 8:958dfe5052b9
- Parent:
- 7:d9aca501126f
- Child:
- 9:6976ac1a430e
File content as of revision 8:958dfe5052b9:
// GENERADOR DE FRECUENCIAS #include "mbed.h" #include "setup.h" #include "EthernetNetIf.h" #include "HTTPServer.h" #include "RPCFunction.h" #include "RPCVariable.h" #include "SerialRPCInterface.h" LocalFileSystem fs("webfs"); EthernetNetIf eth; HTTPServer svr; void setFq( char * input, char * output ); //Cambiar frecuencia void setPTO( char * input, char * output ); // Encender/Apagar Pulse Train Output //Set up custom RPC RPCFunction SetFQ(&setPTO, "PTO"); RPCFunction SetAout(&setAOUT, "AOUT"); int main() { Base::add_rpc_class<AnalogIn>(); Base::add_rpc_class<AnalogOut>(); Base::add_rpc_class<DigitalIn>(); Base::add_rpc_class<DigitalOut>(); Base::add_rpc_class<DigitalInOut>(); Base::add_rpc_class<PwmOut>(); Base::add_rpc_class<Timer>(); Base::add_rpc_class<BusOut>(); Base::add_rpc_class<BusIn>(); Base::add_rpc_class<BusInOut>(); Base::add_rpc_class<Serial>(); printf("\nSetting Up...\n"); EthernetErr ethErr = eth.setup(); if( ethErr ) { printf( "Error %d in setup\n", ethErr ); return -1; } printf("Configuracion Correcta\n"); FSHandler::mount("/webfs", "/files"); //Mount /webfs path on /files web path FSHandler::mount("/webfs", "/"); //Mount /webfs path on web root path svr.addHandler<SimpleHandler>("/hello"); svr.addHandler<RPCHandler>("/rpc"); svr.addHandler<FSHandler>("/files"); svr.addHandler<FSHandler>("/"); //Default handler //Example : Access to mbed.htm : http://a.b.c.d/mbed.htm or http://a.b.c.d/files/mbed.htm svr.bind(80); setTimer2(); printf("Listening...\n"); while(1) { Net::poll(); } } void setAOUT( char * input, char * output ) { int vout = atoi( input ); aout = (float)( vout + 100 ) / 200; sprintf(" Ok, Aout = %f ", aout.read() ); } void setPTO( char * input, char * output ) { int freq = atoi( input ); if( freq != 0 ) { LPC_TIM2->TC = 0x00; // Resetear Timer setMR2( getMRvalue( frequency ) ); //Cambiar frefuencia startTimer2(); sprintf( output, "Ok, Freq = %d", frequency); } else { LPC_TIM2->TC = 0x00; // Resetear Timer stopTimer2(); sprintf( output, "Ok, ALTO" ); } }