Révision 906
Ajouté par ahkurklu il y a environ 4 ans
branch/KURKLU/sp4c12/sp4c12/sp4c12/rectrame.c | ||
---|---|---|
|
||
int rectrame(char * Buffer){
|
||
int i=0;
|
||
int b = 0;
|
||
int resultatChecksum;
|
||
char c[2];
|
||
char checksum = 0;
|
||
int trameOK = 0;
|
||
while(uart0_rx()!='$');
|
||
while(uart0_rx()!='*'){
|
||
Buffer[i]= uart0_rx() ;
|
||
Buffer[i]= uart0_rx();
|
||
checksum = checksum ^ Buffer[i];
|
||
i=i+1;
|
||
}
|
||
c[0] = uart0_rx();
|
||
c[1] = uart0_rx();
|
||
|
||
b= hex2int(c);
|
||
if (b=122){
|
||
uart0_tx('X');
|
||
uart0_tx('X');
|
||
resultatChecksum = hex2int(c);
|
||
if(checksum == resultatChecksum ){
|
||
trameOK = 1 ;
|
||
}
|
||
|
||
else{
|
||
trameOK = 0;
|
||
}
|
||
|
||
return i;
|
||
}
|
||
|
||
... | ... | |
if(c[0]>=48 && c[0]<=57){
|
||
c1 = c[0]-48;
|
||
}
|
||
else if(c[0]>=10 && c[0]<=15){
|
||
c1 = c[0];
|
||
else if(c[0]>=65 && c[0]<=70){
|
||
c1 = c[0]-55;
|
||
}
|
||
|
||
if(c[1]>=48 && c[1]<=57){
|
||
c2 = c[1]-48;
|
||
}
|
||
else if(c[1]>=10 && c[1]<=15){
|
||
c2 = c[1];
|
||
else if(c[1]>=65 && c[1]<=70){
|
||
c2 = c[1]-55;
|
||
}
|
||
|
||
resultat = c2+16*c1;
|
branch/KURKLU/sp4c12/sp4c12/sp4c12/SessionM32C_E8a_SYSTEM.ini | ||
---|---|---|
[Target]
|
||
M32C E8a SYSTEM=Renesas Communications
|
||
[USER_DATA]
|
||
RESET=fe0000
|
||
RESET=fe0004
|
branch/KURKLU/sp4c12/sp4c12/sp4c12/rectrame.h | ||
---|---|---|
/***********************************************************************/
|
||
|
||
int rectrame(char * Buffer);
|
||
int hex2int(char * c);
|
||
|
||
|
||
|
branch/KURKLU/sp4c12/sp4c12/sp4c12/sp4c12.c | ||
---|---|---|
i=rectrame(tab);
|
||
|
||
|
||
|
||
|
||
//initialisation
|
||
/*
|
Formats disponibles : Unified diff
Correction fonction hex2int