Comment controller la réponse d'une commande
bonjour à tous,
j'ai une fonction qui va envoyer une commande et ca marche bien, sauf que....
voici la commande (regarder surtout serial.println(response
j'ai une fonction qui va envoyer une commande et ca marche bien, sauf que....
voici la commande (regarder surtout serial.println(response
- )code: [select]
int8_t morse::sendatcommand(char* atcommand, char* expected_answer, unsigned int timeout){
uint8_t x=0, answer=0;
char response[100];
unsigned long previous;
memset(response, '\0', 100); // initialice string
delay(100);
while( _cell.available() > 0) _cell.read(); // clean input buffer
if (atcommand[0] != '\0')
{
_cell.println(atcommand); // send @ command
}
x = 0;
previous = millis();
// loop waits answer
do{
if(_cell.available() != 0){ // if there data in uart input buffer, reads , checks asnwer
response[x] = _cell.read();
serial.println(response[x]);
x++;
if (strstr(response, expected_answer) != null) // check if desired answer (ok) in response of module
{
answer = 1;
}
}else{
}
}while((answer == 0) && ((millis() - previous) < timeout)); // waits asnwer time out
return answer;
}
quand je fais ceci, il m'affiche "gps ready"code: [select]if(sendatcommand("at","gps ready",2000)){
serial.println("gps ready\n");
};
par contre quand je faiscode: [select]if(sendatcommand("at","call ready",2000)){
serial.println("call ready\n");
};
il me retourne rien.
en fait , ceci serial.println(response - ); affichequote
c
a
l
l
r
e
a
s
y
[vide]
[vide]
avec deux vide.
c'est pourca qu'il n'affiche rien.
je ne comprends pas car la fonction sendatcomdwait à cette fonctioncode: [select]strstr(response, expected_answer)
donc normalement, dès que ca coincide, il doit retourner true???
bon, ben non!!!
alors comment je peux faire pour qu'il ne considère pas les espace après la chaine de caractere demandée, (s'il y des expaces)?
comme pourrais-je optimiser ceci?
milles mercis
Arduino Forum > International > Français (Moderators: jfs, Snootlab) > Comment controller la réponse d'une commande
arduino
Comments
Post a Comment