Dummy program to demonstrate problems: working code
Dependencies: SLCD mbed-rtos mbed
Fork of MNG_TC by
Diff: ThreadFunctions.h
- Revision:
- 10:024c2ef51cb1
- Child:
- 11:109f16cc35d7
- Child:
- 13:7b27a8e9cbb4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ThreadFunctions.h Thu Jul 16 14:14:41 2015 +0000 @@ -0,0 +1,69 @@ +void reset_all(){ + printf("resetting all\r\n"); + // reset MNG_TC + MNG_TC::init(); + TC_list *tcp = VAR_SPACE::Head_node; + while(tcp != NULL){ + TC_list *temp = tcp->next_TC; + delete tcp; + tcp = temp; + } + + // reset COM_RCV_TC +// handle reset + + // reset data linked list + data_list *dataptr = VAR_SPACE::head_data; + while( dataptr != NULL ){ + data_list *temp = dataptr->next; + delete dataptr; + dataptr = temp; + } + VAR_SPACE::head_data = new data_list; + VAR_SPACE::rx_new_node = VAR_SPACE::head_data; +} + +void com_mng_fun(const void *args){ + while(true){ + + Thread::signal_wait(0x01, osWaitForever); + ledr = !ledr; + + if( VAR_SPACE::new_tc_received ){ + VAR_SPACE::new_tc_received = false; + struct data_list *haha = VAR_SPACE::head_data; + unsigned int count = 0; + while( haha != NULL ){ + ++count; + printf("%x ", haha->val); + haha = haha->next; + } + printf("\t count = %u \r\n", count); + printf("new tc received : state = %u\r\n", VAR_SPACE::rx_state); + if( VAR_SPACE::rx_state == 0 ){ + VAR_SPACE::data_node = VAR_SPACE::head_data; + COM_RCV_TC::rx_rcv_tc(); + MNG_TC::start_with(); + if( MNG_TC::check_for_missing_TC() ){ + printf("everything pass\r\n"); + VAR_SPACE::rx_state = 1; + MNG_TC::execute_TC(); + } + } + else if( VAR_SPACE::rx_state == 3 ){ + VAR_SPACE::data_node = VAR_SPACE::head_data; + COM_RCV_TC::rx_rcv_tc(); + MNG_TC::start_with(); + if( MNG_TC::check_for_missing_TC() ){ + VAR_SPACE::execute_obosc = true; + VAR_SPACE::rx_state = 2; + MNG_TC::execute_TC(); + } + } + else{ + // invalid state in main found reset + reset_all(); + } + } + } +} \ No newline at end of file