Bonjour à tous,
Je deviens fouououuuu.
Et j’ai peur de ne pas pouvoir être prècis, mais je vais essayé.
J’ai un code qui m’affiche ceci:
2|4|5|6|7|8|9|10|11|12|13|
Ca affiche correctment ce que je peux. J’ai mis un pipe pour distinguer les chiffres.
Simplement, je ne fais que d’afficher un chiffre et j’aimerais le mettre dans un buffer/array pour l’exploiter plus tard.
Donc j’aimerais avoir
char message_pos_buff;
message_pos_buff[0]=2
message_pos_buff[1]=4
message_pos_buff[2]=5
message_pos_buff[3]=6
message_pos_buff[4]=7
message_pos_buff[5]=8
message_pos_buff[6]=9
message_pos_buff[7]=10
message_pos_buff[8]=11
message_pos_buff[9]=12
message_pos_buff[10]=13
Et je n’y arrive pas, évidemment
Mon code est le suivant
do{
if(Serial1.available() > 0){
if(x < BUFFERSIZE-1) // Do not fill the buffer more the it size
{
buffer[x] = Serial1.read(); // response
//delay(500);
//Serial.print(x); Serial.print(F(":")); Serial.println(buffer[x]);
if(y)
{
/*
QUAND IL NE RENCONRE PAS DE VIRGULE, IL VA COMMENCER A AFFICHER 2.
APRWS 2 IL Y A UNE VIRGULE, DONC IL VA AFFICHER LE PIPE. CA C'EST BON!
J AIMERAIS QU'IL N'AFFICHE PAS LE 2 MAIS QU'IL LE METTRE DANS UN BUFFER.
ET AU LIEUX D'AFFICHER LE PIPE, IL INCREMENT LE BUFFER.
DONC APRES IL MET EN BUFFER LE 4 ET VU QU'APRES LE 4 IL Y A UNE VIRGULE, IL INCREMENT LE BUFFER.
IDEM POUR LE 10.
APRES LE 1 du 10, IL Y A PAS DE VIRGULE, DONC IL n'INCREMENTE PAS LE BUFFER. APRES, ARRIVE LE 0. IL FAUT QU'IL AJOUTE 0 A 1, POUR AVOIR 10. APRES LE ZERO, IL Y A UNE VIRGULE. DONC AU LIEUX D'AFFICHER LE PIPE, IL INCREMENT LE BUFFER
J AI ESSAYER DE METTRE DANS UN SUBBUFFER (message_pos_buff),LE 2, CONVERTIR EN IT POUR LE METTRE DANS LE BUFFER.
IDEM POUR LE 4,5,6 ETC.
POUR LE 10, J AI ESSAYE DE METTRE LE 1 ET LE 0 DANS UN SUBBUFFER, POUR CONVERTIR LA VALEUR DU SUBBUFFER EN INT ET DE METTRE 10 DANS LE BUFFER.
NEANT, PAS REUSSI. POURVEZ-VOUS MA'IDER?
*/
if(buffer[x] == ',')
{
/*
Serial.print(F(".("));
Serial.print(message_pos_buff_index);
Serial.print(F(")."));
Serial.print(F("***"));
for(int bbb=0; bbb < message_pos_buff_index; bbb++)
{
Serial.print(message_pos_buff[bbb]);
}
Serial.print(F("***"));
*/
message_pos_buff_index=0;
Serial.print(F("|"));
count_message++;
y=0;
}
else
{
Serial.print(buffer[x]);
/*
message_pos_buff[message_pos_buff_index] = buffer[x];
message_pos_buff_index++;
//Serial.print(F("-"));
//Serial.print(message_pos_buff[message_pos_buff_index++]);
Serial.print(F("("));
Serial.print(message_pos_buff_index);
Serial.print(F(")"));
*/
}
}
...suite du code et fermeture de do....
J’espère que vous allez comprendre mon explication et mon code. J’ai ajouté un commentaire en majuscule dans le code.
Milles merci