This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

data logger

#include "RTE_Device.h" // Keil::Device:Startup
#include "RTE_Components.h" // Component selection
#include "LPC17xx.h" // Device header
enum 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;
}

}
}


}

Parents
  • As  says, you haven't actually asked any question!

    The standard approach is to consider the following:

    1. What did you intend to happen ?
    2. What is actually happening ?
    3. What investigation / testing / debugging have you done to find the problem(s) ?

    How To Debug.

    You should also specify what version of the tools you are using.

Reply
  • As  says, you haven't actually asked any question!

    The standard approach is to consider the following:

    1. What did you intend to happen ?
    2. What is actually happening ?
    3. What investigation / testing / debugging have you done to find the problem(s) ?

    How To Debug.

    You should also specify what version of the tools you are using.

Children
No data