confronto stringhe c18
Salve a tutti,
Devo confrontare un array che ottengo via USART con una stringa definita in precedenza ma non so come fare.... Questo è quello che ho scritto:
Devo confrontare un array che ottengo via USART con una stringa definita in precedenza ma non so come fare.... Questo è quello che ho scritto:
- Codice: Seleziona tutto
unsigned char speed[]= "A001F5D0F67";
unsigned char data[];
unsigned char input;
unsigned char output;
unsigned int ver=2;
//PROTOTIPI DI FUNZIONE
int reader (void);
void main (void){
// 8 bit
// 9600 bit/s
// 1 bit stop
// 0 bit parità
OpenUSART( USART_TX_INT_OFF &
USART_RX_INT_OFF &
USART_ASYNCH_MODE &
USART_EIGHT_BIT &
USART_CONT_RX &
USART_BRGH_HIGH,
129 );
// Invio la stringa al terminale
putrsUSART ("Connessione avvenuta");
reader();
}
//*****READER*****************************
int reader (void)
{
while(1) {
input = 0;
output = 0;
// Leggo il dato dal buffer di ricezione
HomeLCD();
for (input=0; input<15; input++)
{
data[input] = ReadUSART();
//Attendo che la USART sia libera
while(!DataRdyUSART( ));
}
// Invio il carattere al display
for (output=3; output<15; output++)
{
WriteCharLCD(data[output]);
while (BusyUSART());
}
//Verifica idtransponder
if (data==speed )
{
GotoLineLCD(2);
WriteStringLCD("OK!");
} else
{GotoLineLCD(2);
WriteStringLCD("NO!");
}
}
}
