Dummy program to demonstrate problems: working code
Dependencies: SLCD mbed-rtos mbed
Fork of MNG_TC by
Diff: main.cpp
- Revision:
- 5:a5a5300d7d49
- Parent:
- 4:f95195748a0c
- Child:
- 6:6e9ae3b44e60
--- a/main.cpp Wed Jun 24 12:04:43 2015 +0000 +++ b/main.cpp Thu Jun 25 10:10:23 2015 +0000 @@ -1,5 +1,8 @@ #include "mbed.h" +#include "SLCD.h" +SLCD lcd; + #define TIMEOUT_LIMIT 15 Serial PC(USBTX, USBRX); @@ -29,6 +32,9 @@ struct data_list *head_data; data_list *data_node; + +// remove +// unsigned char *data; } unsigned int rx_bytes = 0; @@ -58,24 +64,71 @@ VAR_SPACE::rx_state = 1; } +//remove +//void pc_isr(){ +// PC.attach(NULL); +// VAR_SPACE::rx_state = 1; +// rx_timer.start(); +//} + +//using namespace VAR_SPACE; + int main(){ +// 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]; + +// 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"); + while(true){ ledg = !ledg; 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); } } @@ -89,6 +142,7 @@ else if( VAR_SPACE::rx_state == 3 ){ // printf("calling mng tc\r\n"); + lcd.printf("0123"); MNG_TC::init( VAR_SPACE::Head_node ); MNG_TC::start_with(); @@ -101,6 +155,7 @@ rx_new_node = rx_new_node->next; delete temp; } +// printf("successfully sent data\r\n"); } } }