This application translates HTTP GET requests into the proper RS232 commands to control a Sharp Aquos TV

Dependencies:   EthernetInterface mbed-rtos mbed

Committer:
davisw00
Date:
Tue Jul 29 23:01:55 2014 +0000
Revision:
0:427a14ebab60
Child:
2:3637af74f7f0
Initial working copy of HTTP-to-RS232 server for a Sharp Aquos TV

Who changed what in which revision?

UserRevisionLine numberNew contents of line
davisw00 0:427a14ebab60 1 #ifndef _DebugPort
davisw00 0:427a14ebab60 2 #define _DebugPort
davisw00 0:427a14ebab60 3 #include "mbed.h"
davisw00 0:427a14ebab60 4
davisw00 0:427a14ebab60 5 class DebugPort {
davisw00 0:427a14ebab60 6 protected:
davisw00 0:427a14ebab60 7 //Serial m_pc(USBTX, USBRX);
davisw00 0:427a14ebab60 8 Serial* m_pc;
davisw00 0:427a14ebab60 9 DigitalOut* led_red;
davisw00 0:427a14ebab60 10 DigitalOut* led_green;
davisw00 0:427a14ebab60 11 DigitalOut* led_blue;
davisw00 0:427a14ebab60 12
davisw00 0:427a14ebab60 13 public:
davisw00 0:427a14ebab60 14 void setLED(bool r, bool g, bool b) {
davisw00 0:427a14ebab60 15 *led_red = !r;
davisw00 0:427a14ebab60 16 *led_green = !g;
davisw00 0:427a14ebab60 17 *led_blue = !b;
davisw00 0:427a14ebab60 18 }
davisw00 0:427a14ebab60 19
davisw00 0:427a14ebab60 20 DebugPort() {
davisw00 0:427a14ebab60 21 m_pc = new Serial(USBTX,USBRX);
davisw00 0:427a14ebab60 22 led_red = new DigitalOut(LED_RED);
davisw00 0:427a14ebab60 23 led_green = new DigitalOut(LED_GREEN);
davisw00 0:427a14ebab60 24 led_blue = new DigitalOut(LED_BLUE);
davisw00 0:427a14ebab60 25
davisw00 0:427a14ebab60 26 m_pc->baud(115200);
davisw00 0:427a14ebab60 27 m_pc->format(8,SerialBase::None,1);
davisw00 0:427a14ebab60 28 setbuf(*m_pc,NULL); // turn off buffering of printf output
davisw00 0:427a14ebab60 29 setLED(0,0,0);
davisw00 0:427a14ebab60 30 }
davisw00 0:427a14ebab60 31 ~DebugPort() {
davisw00 0:427a14ebab60 32 delete led_red;
davisw00 0:427a14ebab60 33 delete led_green;
davisw00 0:427a14ebab60 34 delete led_blue;
davisw00 0:427a14ebab60 35 delete m_pc;
davisw00 0:427a14ebab60 36 }
davisw00 0:427a14ebab60 37 void send(const char* msg, int level=0) {
davisw00 0:427a14ebab60 38 m_pc->printf(msg);
davisw00 0:427a14ebab60 39 if(level>0) { // major fail. stop processing and toggle led
davisw00 0:427a14ebab60 40 while(true) {
davisw00 0:427a14ebab60 41 setLED(0,0,0);
davisw00 0:427a14ebab60 42 wait(0.1);
davisw00 0:427a14ebab60 43 setLED(1,0,0);
davisw00 0:427a14ebab60 44 wait(0.1);
davisw00 0:427a14ebab60 45 }
davisw00 0:427a14ebab60 46 }
davisw00 0:427a14ebab60 47 }
davisw00 0:427a14ebab60 48
davisw00 0:427a14ebab60 49 };
davisw00 0:427a14ebab60 50
davisw00 0:427a14ebab60 51
davisw00 0:427a14ebab60 52 #endif