Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void search_frame()
- {
- if(Busy_Rx != Empty_Rx)
- {
- static char c;
- c = getchar_BuffRx();
- switch(frame_state)
- {
- case WAIT_START:
- {
- if(c == END)
- {
- clear_data();
- frame_state = MESSAGE;
- }
- break;
- }
- case MESSAGE:
- {
- if(c == END)
- {
- if(idx>0)
- {
- analyze_frame(command);
- clear_data();
- frame_state = MESSAGE;
- }
- else
- {
- clear_data();
- frame_state = MESSAGE;
- }
- }
- else if(c == ESC)
- {
- frame_state = AFTER_ESCAPE;
- }
- else
- {
- command[idx] = c;
- if (idx>=256)
- {
- frame_state = WAIT_START;
- SendFrame("INVALID DATA E2");
- break;
- }
- else
- {
- idx++;
- }
- }
- break;
- }
- case AFTER_ESCAPE:
- {
- if(c == ESC_END)
- {
- command[idx] = END;
- if (idx>=256)
- {
- USART_fsend("TUTAJ");
- frame_state = WAIT_START;
- SendFrame("INVALID DATA E2");
- break;
- }
- else
- {
- idx++;
- }
- }
- else if(c == ESC_ESC)
- {
- command[idx] = ESC;
- if (idx>=30)
- {
- frame_state = WAIT_START;
- SendFrame("INVALID DATA E2");
- break;
- }
- else
- {
- idx++;
- }
- }
- else if(c == END)
- {
- clear_data();
- frame_state = MESSAGE;
- break;
- }
- else
- {
- frame_state = WAIT_START;
- SendFrame("INVALID DATA E3");
- break;
- }
- frame_state = MESSAGE;
- break;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement