Problème de compilation

Bonjour,

J'ai un problème lorsque je compile mon programme qui utilise la librairie RF12.
En fait le programme se compile très bien au lycée mais lorsque je veux le compiler chez moi il me dis "RF12_initialize ... was not declared in this scope " en gros un problème de librairie . Le pire c'est qu'on utilise exactement la même qu'au lycée, on a copié collé tout le fichier librairie mais rien n'y fait le programme ce compile que sur un seul ordinateur !
Pourquoi ? =(

Merci d'avance pour votre aide

Bonjour,

Peut-être que la librairie n'est pas installer sur ton ordinateur.
Faudrait vérifier.

bonjour,
code et erreur(s)
ca serait bien pour pouvoir aider :wink:

Le code :

#include <Arduino.h>
#include <RF12.h>

#include <SPI.h>
#include <Ethernet.h>
#include <SD.h>

#define CRC_POLY 0x31
#define MAX_SENSORS 8
#define DEBUG_OFF
//#define DEBUG
#define REQ_BUF_SZ   50 // taille du buffer utilisé pour capturer les requêtes HTTP

struct Sensor {
  byte sensorId;
  byte temp;
  byte decimalTemp;
  byte hygro;
  byte resetFlag;
  byte weakBatt;
};

Sensor sensors[MAX_SENSORS];

// Adresses du shield Ethernet
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0x9D, 0xD2 }; // adresse MAC
IPAddress ip(192, 168, 5, 228);                      // adresse IP
EthernetServer server(80);                           // créé un serveur au port 80
File webFile;                                         // le fichier de la page web sur la carte SD
char HTTP_req[REQ_BUF_SZ] = {0};                     // buffered HTTP request stored as null terminated string
char req_index = 0;                                  // index into HTTP_req buffer


/*------------------------------------------------------------------------------------SETUP----------------------------------------------------------------------------------*/
void setup()
{
  Serial.begin(9600);       // initialisation du moniteur série 
 
  pinMode(10, OUTPUT);
  digitalWrite(10, HIGH);
  
  Serial.println("Initialisation de la carte SD...");
    if (!SD.begin(4)) {
      Serial.println("ERREUR - Initialisation de la carte SD impossible!"); // initialisation ratée
      return;
    }
  Serial.println("OK - Carte SD initialisee.");
  Serial.println("");  
  

  Serial.println("SUCCESS - SD card initialized.");
    // check for index.htm file
    if (!SD.exists("index.htm")) {
        Serial.println("ERROR - Can't find index.htm file!");
        return;  // can't find index file
    }
    Serial.println("SUCCESS - Found index.htm file.");
  
  
  Ethernet.begin(mac, ip);  // initialisation Ethernet
  server.begin();           // start to listen for clients
  
  // Overide settings for RFM01/IT+ compliance
  rf12_initialize(1, RF12_868MHZ, 0xd4);
  rf12_initialize_overide_ITP();
  
  #ifdef DEBUG
  Serial.println("Initialisation du RF12...");
  Serial.println("OK - RF12 initialise.");
  Serial.println("");
  #endif

}


/*------------------------------------------------------------------------------------LOOP----------------------------------------------------------------------------------*/
void loop()
{      
  
delay(500);   
EthernetClient client = server.available();  // try to get client

  if (client) {  // got client?
        boolean currentLineIsBlank = true;
        while (client.connected()) {
            if (client.available()) {   // client data available to read
                char c = client.read(); // read 1 byte (character) from client
                // buffer first part of HTTP request in HTTP_req array (string)
                // leave last element in array as 0 to null terminate string (REQ_BUF_SZ - 1)
                if (req_index < (REQ_BUF_SZ - 1)) {
                    HTTP_req[req_index] = c;          // save HTTP request character
                    req_index++;
                }
                // last line of client request is blank and ends with \n
                // respond to client only after last line received
                if (c == '\n' && currentLineIsBlank) {
                    // send a standard http response header
                    client.println("HTTP/1.1 200 OK");
                    // remainder of header follows below, depending on if
                    // web page or XML page is requested
                    // Ajax request - send XML file
                    if (StrContains(HTTP_req, "ajax_inputs")) {
                        // send rest of HTTP header
                        client.println("Content-Type: text/xml");
                        client.println("Connection: keep-alive");
                        client.println();
                        // send XML file containing input states
                        XML_response(client);
                        webFile = SD.open("index.htm");
                    }
                    else if (StrContains(HTTP_req, "GET /nuage.png")) {
                        webFile = SD.open("nuage.png");
                        if (webFile) {
                            client.println("HTTP/1.1 200 OK");
                            client.println();
                        }
                    else {  // web page request
                        // send rest of HTTP header
                        client.println("Content-Type: text/html");
                        client.println("Connection: keep-alive");
                        client.println();
  
                        // send web page
                        webFile = SD.open("index.htm");        // open web page file     
                        
                     delay(1000);//debug
                     Serial.println (webFile);//debug                    
                     
                     if (webFile) {
                          Serial.println ("index.htm ouvert");//debug
                            while(webFile.available()) {
                                client.write(webFile.read()); // send web page to client                          
                            }
                            webFile.close();
                        }      
                     
                    } 
                    // display received HTTP request on serial port
                    Serial.print(HTTP_req);
                    // reset buffer index and all buffer elements to 0
                    req_index = 0;
                    StrClear(HTTP_req, REQ_BUF_SZ);
                    break;
                }
                // every line of text received from the client ends with \r\n
                if (c == '\n') {
                    // last character on line of received text
                    // starting new line with next character read
                    currentLineIsBlank = true;
                } 
                else if (c != '\r') {
                    // a text character was received from client
                    currentLineIsBlank = false;
                }
            } // end if (client.available())
        } // end while (client.connected())
        delay(1);      // give the web browser time to receive the data
        client.stop(); // close the connection
    } // end if (client) 
    
}

Et l'image de l'erreur Screenshot - a35dbd6eaa928a1d1e9b5d1d0b3e3d05 - Gyazo

Et Uzuma la librairie est bien installé comme je l'ai dis j'ai tout mis comme l'autre ordi :wink:

La suite du code parce que tout ne rentrer pas :

/*------------------------------------------------------------------------------------FONCTIONS RF12-----------------------------------------------------------------------------*/
/*
 * Try to decode the CRC from the packet to check
 * if it's a TX29 one.
 * 
 * Protocol : http://fredboboss.free.fr/tx29/
 * Implementation : http://gcrnet.net/node/32
 */
boolean CheckITPlusCRC() {
  byte nbBytes = 5;
  byte reg = 0;
  byte curByte, curbit, bitmask;
  byte do_xor;
  
  while (nbBytes != 0) {
    curByte = rf12_buf[5-nbBytes];
    nbBytes--;
    bitmask = 0b10000000;
    while (bitmask != 0) {
      curbit = ((curByte & bitmask) == 0) ? 0 : 1;
      bitmask >>= 1;
      do_xor = (reg & 0x80);
      reg <<=1;
      reg |= curbit;
      if (do_xor) {
        reg ^= CRC_POLY;
      }
    }
  }
  
  return (reg == 0);
}

/*
 * The CRC has been check, this method decode the TX29
 * packet to extract the data, then store it into the
 * sensors array.
 */ 
int ReadITPlusValue() {
  byte temp, decimalTemp, sensorId, resetFlag, hygro, weakBatt;
  int pos = -1;
  
  sensorId = (((rf12_buf[0] & 0x0f) << 4) + ((rf12_buf[1] & 0xf0) >> 4)) & 0xfc;
  // Reset flag is stored as bit #6 in sensorID.
  resetFlag = (rf12_buf[1] & 0b00100000) << 1;
  temp = (((rf12_buf[1] & 0x0f) * 10) + ((rf12_buf[2] & 0xf0) >> 4));
  decimalTemp = rf12_buf[2] & 0x0f;

  // IT+ add a 40° offset to temp, so < 40 means negative
  if (temp >= 40) {
    temp -= 40;
  } else {
    if (decimalTemp == 0) {
      temp = 40 - temp;
    } else {
      temp = 39 - temp;
      decimalTemp = 10 - decimalTemp;
    }
    // Sign bit is stored into bit #7 of temperature. 
    temp |= 0b10000000;
  }
  
  //weak battery indicator is the first bit, the rest is hygro
  weakBatt = rf12_buf[3] & 0x80;
  hygro = rf12_buf[3] & 0x7f;
  
  //check the Sensors array to find a empty space
  for (int i = 0 ; i < MAX_SENSORS && pos < 0 ; i++) {
    if (sensors[i].sensorId == 0 || sensors[i].sensorId == sensorId) {
      //that's a free space, store values in it
      pos = i;
      sensors[i].sensorId = sensorId;
      sensors[i].temp = temp;
      sensors[i].decimalTemp = decimalTemp;
      sensors[i].hygro = hygro;
      sensors[i].resetFlag = resetFlag;
      sensors[i].weakBatt = weakBatt;
    }
  }
  
}

/*
 * Print a number into hex format
 */
void printHex(byte data) {
  if (data < 16) Serial.print('0');
  Serial.print(data, HEX);
}

/*------------------------------------------------------------------------------------FONCTIONS ETHERNET-------------------------------------------------------------------------*/
void XML_response(EthernetClient cl)
{
      //lecture du code sur le RF12
    if (rf12_recvDone())
      {
      //we receive a packet, let's check if it's an IT+ one
		if (ITPlusFrame && CheckITPlusCRC())
                  {
		  ReadITPlusValue();
		  }     
      }  
  
  
    //int analog_val;
    
    cl.print("<?xml version = \"1.0\" ?>");
    cl.print("<inputs>");
    // read analog pin A2
    //analog_val = analogRead(2);
    cl.print("<analog>");
    //cl.print(analog_val);
    cl.print(sensors[0].temp & 0x7f, DEC);
    cl.print(".");
    cl.println(sensors[0].decimalTemp, DEC);
    cl.print("</analog>");
    cl.print("<analog>");
    //cl.print(analog_val);
    cl.print(sensors[1].temp & 0x7f, DEC);
    cl.print(".");
    cl.println(sensors[1].decimalTemp, DEC);
    cl.print("</analog>");
    cl.print("</inputs>");
}

// sets every element of str to 0 (clears array)
void StrClear(char *str, char length)
{
    for (int i = 0; i < length; i++) {
        str[i] = 0;
    }
}

// searches for the string sfind in the string str
// returns 1 if string found
// returns 0 if string not found
char StrContains(char *str, char *sfind)
{
    char found = 0;
    char index = 0;
    char len;

    len = strlen(str);
    
    if (strlen(sfind) > len) {
        return 0;
    }
    while (index < len) {
        if (str[index] == sfind[found]) {
            found++;
            if (strlen(sfind) == found) {
                return 1;
            }
        }
        else {
            found = 0;
        }
        index++;
    }

    return 0;
}

Ganew:
Et Uzuma la librairie est bien installé comme je l'ai dis j'ai tout mis comme l'autre ordi :wink:

Il vient peut être de là le problème car ça m'étonnerais que "l*'ordi de chez toi soit identique à celui du lycée*" :smiley:

L'erreur renvoyée vient du fait que ta libraire est pas trouvée, soit tu ne l'a pas mise au bon endroit, soit tu en as deux identiques mais il y a quelque chose qui ne va pas de ce côté, c'est sur.

John j'ai prit le fichier arduino complet sur l'ordi ou ca marche et je l'ai collé sur le mien don aucune raison et ca sur n'importe quel ordinateur on a essayer au lycée sur d'autre ordi et ça ne marche pas non plus...

Je viens de compiler ton programme avec la bibliothèque installer et effectivement il y a un problème à ce niveau.
Ce que je peux dire c'est qu'il doit y avoir un fichier installer sur l'autre ordinateur mais qui ne l'est pas sur le tient.

Oui mais lequel ?

Je ne vois pas l'image de l'erreur, pourrais-tu remettre tout le texte de l'erreur, il doit t'indiquer une ligne pour l'erreur normalement?

Donc l'erreur c'est :

'rf12_initialize_overide_ITP' was not declared in this scope
programme_final.ino : in function 'void setup() ' :
programme_final:65 error 'rf12_initialize_overide_ITP' was not declared in this scope
programme_final.ino: In function 'void loop()':
programme_final:171: error: a function-definition is not allowed here before '{' token

Suffit de lire ce qu'il dit : il manque une accolade } à ton loop()

Non non ^^
Je rappelle que ce programme marche parfaitement au lycée

Si si, il manque un } de ton loop.

Si tu copie/colle le programme tu verras que la dernière accolade correspond à ton IF Client et pas à ton loop

Je l'ai testé mais cela ne résout pas son problème. La première erreur survient dans void setup.

Tu as installé quelle version de l'IDE Arduino ?
Car il y a des petits trucs qui changent, comme par exemple des librairies automatiquement dans le pack ou pas.

Effectivement j'ai du la coupé en copiant le programme et en effet le problème viens d'abord du voidsetup : 'rf12_initialize_overide_ITP' was not declared in this scope

Ce sont aussi les même version 1.0.5

La fonction existe nulle part alors ce qui m'étonne c'est la compilation au lycée

Mais en fait elle sort d'où cette ligne:
rf12_initialize_overide_ITP();
Dans quel soft tu l'as trouvé.