Dummy program to demonstrate problems: working code
Dependencies: SLCD mbed-rtos mbed
Fork of MNG_TC by
Diff: main.cpp
- Revision:
- 6:6e9ae3b44e60
- Parent:
- 5:a5a5300d7d49
- Child:
- 7:e71ecfe3a340
--- a/main.cpp Thu Jun 25 10:10:23 2015 +0000 +++ b/main.cpp Sat Jul 04 13:22:07 2015 +0000 @@ -1,4 +1,5 @@ #include "mbed.h" +#define ENDL "\r" << endl #include "SLCD.h" SLCD lcd; @@ -33,8 +34,7 @@ struct data_list *head_data; data_list *data_node; -// remove -// unsigned char *data; + unsigned char *data; } unsigned int rx_bytes = 0; @@ -64,49 +64,39 @@ VAR_SPACE::rx_state = 1; } -//remove -//void pc_isr(){ -// PC.attach(NULL); -// VAR_SPACE::rx_state = 1; -// rx_timer.start(); -//} - -//using namespace VAR_SPACE; +using namespace VAR_SPACE; int main(){ -// printf("welcome to mng_tm_tc\r\n"); + printf("welcome to mng_tm_tc\r\n"); ledr = 1; PC.baud(9600); -// PC.attach(&pc_isr); rx1m.baud(1200); rx1m.attach(&callback); VAR_SPACE::head_data = new data_list; rx_new_node = VAR_SPACE::head_data; - -// remove -// VAR_SPACE::data = new unsigned char[100]; + lcd.printf("0"); -// data[0] = 0x7e; -// data[1] = 0x01; -// data[2] = 0xa1; -// data[3] = 0x61; -// data[4] = 0x01; -// data[5] = 0x02; -// data[6] = 0xef; -// data[7] = 0x96; -// data[8] = 0x80; -// data[9] = 0x00; -// data[10] = 0x4b; -// data[11] = 0xee; -// data[12] = 0x9f; -// data[13] = 0x9f; -// data[14] = 0x80; + data = new unsigned char [15]; + data[0] = 0x7e; + data[1] = 0x01; + data[2] = 0xa1; + data[3] = 0x61; + data[4] = 0x01; + data[5] = 0x02; + data[6] = 0xef; + data[7] = 0x96; + data[8] = 0x80; + data[9] = 0x00; + data[10] = 0x4b; + data[11] = 0xee; + data[12] = 0x9f; + data[13] = 0x9f; + data[14] = 0x80; - - lcd.printf("0"); + VAR_SPACE::rx_state = 2; while(true){ ledg = !ledg; @@ -114,26 +104,22 @@ if(VAR_SPACE::rx_state == 1){ lcd.printf("01"); -// remove -// while( rx_timer.read() < 15 ){ -// if( PC.readable() ){ -// VAR_SPACE::data[bytes] = PC.getc(); -// } -// } -// PC.attach(&pc_isr); -// VAR_SPACE::rx_state = 2; -// endremove - if( rx_timer.read() > TIMEOUT_LIMIT ){ //~ TIMEOUT REACHED MOVE ON TO RX_RCV_TC VAR_SPACE::rx_state = 2; lcd.printf("012"); -// printf("received %u bytes\r\n", rx_bytes); + printf("received %u bytes\r\n", rx_bytes); + + rx_new_node = VAR_SPACE::head_data; + for(int i = 0 ; i < rx_bytes ; ++i){ + printf("%02x ", rx_new_node->val); + rx_new_node = rx_new_node->next; + } } } else if( VAR_SPACE::rx_state == 2 ){ -// printf("Calling rcv_tc\r\n"); + printf("Calling rcv_tc\r\n"); VAR_SPACE::data_node = VAR_SPACE::head_data; RCV_TC::RX_RCV_TC(); VAR_SPACE::rx_state = 3; @@ -141,7 +127,7 @@ } else if( VAR_SPACE::rx_state == 3 ){ -// printf("calling mng tc\r\n"); + printf("calling mng tc\r\n"); lcd.printf("0123"); MNG_TC::init( VAR_SPACE::Head_node ); MNG_TC::start_with(); @@ -155,7 +141,7 @@ rx_new_node = rx_new_node->next; delete temp; } -// printf("successfully sent data\r\n"); + printf("successfully sent data\r\n"); } } }