We are running a survey to help us improve the experience for all of our members. If you see the survey appear, please take the time to tell us about your experience if you can.
#include "RTE_Device.h" // Keil::Device:Startup#include "RTE_Components.h" // Component selection#include "LPC17xx.h" // Device headerenum states {aa,a5a5,aa55,aa55bb,AA,BB,A5A5,idle_state,IDLE_STATE,AA55};int dl[3],ch[3],times=1;void form_table(uint8_t table[]){ if(table[2]==dl[0]){ if(table[9]==ch[0]) { s }} } void validation(uint8_t v_pack[],int ps,int pos){ int j;int sum=0;int check_sum; for(j=pos-13;j<pos-2;j++) { sum+=v_pack[j]; } sum -=v_pack[pos];//remove check sum sum &=0x000000ff; check_sum=v_pack[pos-1]; if(sum==check_sum) { form_table(v_pack); }}int main(){int i,ps;uint8_t packet[]={0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0xbb,}; ps=idle_state;for(i=0;packet[i]!='\0';i++) { switch(ps) { idle_state: { switch(packet[i]){ aa: ps=AA;i++;break; default: i++;break; } break; } AA:{ switch(packet[i]){ a5a5: ps=AA55;i+=14;break; default: ps=idle_state;i++;break; } break; } AA55: { switch(packet[i]){ bb: ps=aa55bb;i++;validation(packet,ps,i);break; default: ps=idle_state;i++;break; } break; } } } }
Whats your question?
As rkopsch says, you haven't actually asked any question!
The standard approach is to consider the following:
How To Debug.
You should also specify what version of the tools you are using.