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:
Sat Sep 06 23:47:21 2014 +0000
Revision:
2:3637af74f7f0
Parent:
0:427a14ebab60
Implemented Channel commands.  Wait for response is not working; therefore commands are followed by a 50ms wait

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 2:3637af74f7f0 13 int m_level;
davisw00 2:3637af74f7f0 14
davisw00 0:427a14ebab60 15 public:
davisw00 0:427a14ebab60 16 void setLED(bool r, bool g, bool b) {
davisw00 0:427a14ebab60 17 *led_red = !r;
davisw00 0:427a14ebab60 18 *led_green = !g;
davisw00 0:427a14ebab60 19 *led_blue = !b;
davisw00 0:427a14ebab60 20 }
davisw00 0:427a14ebab60 21
davisw00 0:427a14ebab60 22 DebugPort() {
davisw00 2:3637af74f7f0 23 m_level = 0;
davisw00 2:3637af74f7f0 24
davisw00 0:427a14ebab60 25 m_pc = new Serial(USBTX,USBRX);
davisw00 0:427a14ebab60 26 led_red = new DigitalOut(LED_RED);
davisw00 0:427a14ebab60 27 led_green = new DigitalOut(LED_GREEN);
davisw00 0:427a14ebab60 28 led_blue = new DigitalOut(LED_BLUE);
davisw00 0:427a14ebab60 29
davisw00 0:427a14ebab60 30 m_pc->baud(115200);
davisw00 0:427a14ebab60 31 m_pc->format(8,SerialBase::None,1);
davisw00 0:427a14ebab60 32 setbuf(*m_pc,NULL); // turn off buffering of printf output
davisw00 0:427a14ebab60 33 setLED(0,0,0);
davisw00 0:427a14ebab60 34 }
davisw00 0:427a14ebab60 35 ~DebugPort() {
davisw00 0:427a14ebab60 36 delete led_red;
davisw00 0:427a14ebab60 37 delete led_green;
davisw00 0:427a14ebab60 38 delete led_blue;
davisw00 0:427a14ebab60 39 delete m_pc;
davisw00 0:427a14ebab60 40 }
davisw00 0:427a14ebab60 41 void send(const char* msg, int level=0) {
davisw00 0:427a14ebab60 42 m_pc->printf(msg);
davisw00 2:3637af74f7f0 43 m_level=level;
davisw00 2:3637af74f7f0 44 if(m_level>0) { // major fail. stop processing and toggle led
davisw00 2:3637af74f7f0 45 for(int i =0; i<10; ++i) {
davisw00 0:427a14ebab60 46 setLED(0,0,0);
davisw00 0:427a14ebab60 47 wait(0.1);
davisw00 0:427a14ebab60 48 setLED(1,0,0);
davisw00 0:427a14ebab60 49 wait(0.1);
davisw00 0:427a14ebab60 50 }
davisw00 0:427a14ebab60 51 }
davisw00 0:427a14ebab60 52 }
davisw00 2:3637af74f7f0 53
davisw00 2:3637af74f7f0 54 int level() {
davisw00 2:3637af74f7f0 55 int ret=m_level;
davisw00 2:3637af74f7f0 56 m_level=0;
davisw00 2:3637af74f7f0 57 return ret;
davisw00 2:3637af74f7f0 58 }
davisw00 0:427a14ebab60 59
davisw00 0:427a14ebab60 60 };
davisw00 0:427a14ebab60 61
davisw00 0:427a14ebab60 62 #endif