Dummy program to demonstrate problems: working code

Dependencies:   SLCD mbed-rtos mbed

Fork of MNG_TC by Shreesha S

Committer:
shreeshas95
Date:
Thu Jul 16 14:14:41 2015 +0000
Revision:
10:024c2ef51cb1
Child:
11:109f16cc35d7
Child:
13:7b27a8e9cbb4
kinda working with threads

Who changed what in which revision?

UserRevisionLine numberNew contents of line
shreeshas95 10:024c2ef51cb1 1 void reset_all(){
shreeshas95 10:024c2ef51cb1 2 printf("resetting all\r\n");
shreeshas95 10:024c2ef51cb1 3 // reset MNG_TC
shreeshas95 10:024c2ef51cb1 4 MNG_TC::init();
shreeshas95 10:024c2ef51cb1 5 TC_list *tcp = VAR_SPACE::Head_node;
shreeshas95 10:024c2ef51cb1 6 while(tcp != NULL){
shreeshas95 10:024c2ef51cb1 7 TC_list *temp = tcp->next_TC;
shreeshas95 10:024c2ef51cb1 8 delete tcp;
shreeshas95 10:024c2ef51cb1 9 tcp = temp;
shreeshas95 10:024c2ef51cb1 10 }
shreeshas95 10:024c2ef51cb1 11
shreeshas95 10:024c2ef51cb1 12 // reset COM_RCV_TC
shreeshas95 10:024c2ef51cb1 13 // handle reset
shreeshas95 10:024c2ef51cb1 14
shreeshas95 10:024c2ef51cb1 15 // reset data linked list
shreeshas95 10:024c2ef51cb1 16 data_list *dataptr = VAR_SPACE::head_data;
shreeshas95 10:024c2ef51cb1 17 while( dataptr != NULL ){
shreeshas95 10:024c2ef51cb1 18 data_list *temp = dataptr->next;
shreeshas95 10:024c2ef51cb1 19 delete dataptr;
shreeshas95 10:024c2ef51cb1 20 dataptr = temp;
shreeshas95 10:024c2ef51cb1 21 }
shreeshas95 10:024c2ef51cb1 22 VAR_SPACE::head_data = new data_list;
shreeshas95 10:024c2ef51cb1 23 VAR_SPACE::rx_new_node = VAR_SPACE::head_data;
shreeshas95 10:024c2ef51cb1 24 }
shreeshas95 10:024c2ef51cb1 25
shreeshas95 10:024c2ef51cb1 26 void com_mng_fun(const void *args){
shreeshas95 10:024c2ef51cb1 27 while(true){
shreeshas95 10:024c2ef51cb1 28
shreeshas95 10:024c2ef51cb1 29 Thread::signal_wait(0x01, osWaitForever);
shreeshas95 10:024c2ef51cb1 30 ledr = !ledr;
shreeshas95 10:024c2ef51cb1 31
shreeshas95 10:024c2ef51cb1 32 if( VAR_SPACE::new_tc_received ){
shreeshas95 10:024c2ef51cb1 33 VAR_SPACE::new_tc_received = false;
shreeshas95 10:024c2ef51cb1 34 struct data_list *haha = VAR_SPACE::head_data;
shreeshas95 10:024c2ef51cb1 35 unsigned int count = 0;
shreeshas95 10:024c2ef51cb1 36 while( haha != NULL ){
shreeshas95 10:024c2ef51cb1 37 ++count;
shreeshas95 10:024c2ef51cb1 38 printf("%x ", haha->val);
shreeshas95 10:024c2ef51cb1 39 haha = haha->next;
shreeshas95 10:024c2ef51cb1 40 }
shreeshas95 10:024c2ef51cb1 41 printf("\t count = %u \r\n", count);
shreeshas95 10:024c2ef51cb1 42 printf("new tc received : state = %u\r\n", VAR_SPACE::rx_state);
shreeshas95 10:024c2ef51cb1 43 if( VAR_SPACE::rx_state == 0 ){
shreeshas95 10:024c2ef51cb1 44 VAR_SPACE::data_node = VAR_SPACE::head_data;
shreeshas95 10:024c2ef51cb1 45 COM_RCV_TC::rx_rcv_tc();
shreeshas95 10:024c2ef51cb1 46 MNG_TC::start_with();
shreeshas95 10:024c2ef51cb1 47 if( MNG_TC::check_for_missing_TC() ){
shreeshas95 10:024c2ef51cb1 48 printf("everything pass\r\n");
shreeshas95 10:024c2ef51cb1 49 VAR_SPACE::rx_state = 1;
shreeshas95 10:024c2ef51cb1 50 MNG_TC::execute_TC();
shreeshas95 10:024c2ef51cb1 51 }
shreeshas95 10:024c2ef51cb1 52 }
shreeshas95 10:024c2ef51cb1 53 else if( VAR_SPACE::rx_state == 3 ){
shreeshas95 10:024c2ef51cb1 54 VAR_SPACE::data_node = VAR_SPACE::head_data;
shreeshas95 10:024c2ef51cb1 55 COM_RCV_TC::rx_rcv_tc();
shreeshas95 10:024c2ef51cb1 56 MNG_TC::start_with();
shreeshas95 10:024c2ef51cb1 57 if( MNG_TC::check_for_missing_TC() ){
shreeshas95 10:024c2ef51cb1 58 VAR_SPACE::execute_obosc = true;
shreeshas95 10:024c2ef51cb1 59 VAR_SPACE::rx_state = 2;
shreeshas95 10:024c2ef51cb1 60 MNG_TC::execute_TC();
shreeshas95 10:024c2ef51cb1 61 }
shreeshas95 10:024c2ef51cb1 62 }
shreeshas95 10:024c2ef51cb1 63 else{
shreeshas95 10:024c2ef51cb1 64 // invalid state in main found reset
shreeshas95 10:024c2ef51cb1 65 reset_all();
shreeshas95 10:024c2ef51cb1 66 }
shreeshas95 10:024c2ef51cb1 67 }
shreeshas95 10:024c2ef51cb1 68 }
shreeshas95 10:024c2ef51cb1 69 }