Arduino 1.0 et la librairie Flash

Bonjour à tous,

Je viens de télécharger la nouvelle version de IDE d’arduino, soit la 1.0. Et a ma grande surprise lorsque j’ai voulu rajouter la librairie Flash, celle-ci n’a plus l’air de ne plus fonctionner…

j’essaye de compiler ce programme sans le flash:

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor 
 
 This example code is in the public domain.
 */

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
}

void loop() {
  int sensorValue = digitalRead(2);
  Serial.println(sensorValue);
}

pas de soucis, je recompile le même avec le flash:

#include <Flash.h>

/*
  DigitalReadSerial
 Reads a digital input on pin 2, prints the result to the serial monitor 
 
 This example code is in the public domain.
 */

void setup() {
  Serial.begin(9600);
  pinMode(2, INPUT);
}

void loop() {
  int sensorValue = digitalRead(2);
  Serial.println(F(sensorValue));
}

Et le bonheur commence…
erreur:

In file included from DigitalReadSerial.cpp:1:
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:22:22: error: WProgram.h: No such file or directory
In file included from DigitalReadSerial.cpp:1:
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:51: error: 'Print' has not been declared
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:82: error: 'Print' has not been declared
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:116: error: 'Print' has not been declared
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h: In member function 'void _FLASH_ARRAY<T>::print(int&) const':
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:120: error: request for member 'print' in 'stream', which is of non-class type 'int'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:122: error: request for member 'print' in 'stream', which is of non-class type 'int'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h: At global scope:
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:156: error: 'Print' has not been declared
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h: In member function 'void _FLASH_TABLE<T>::print(int&) const':
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:162: error: request for member 'println' in 'stream', which is of non-class type 'int'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h: At global scope:
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:184: error: 'Print' has not been declared
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h: In member function 'virtual void _FLASH_STRING_ARRAY::print(int&) const':
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:190: error: request for member 'println' in 'stream', which is of non-class type 'int'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h: At global scope:
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:203: error: expected initializer before '&' token
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:208: error: expected initializer before '&' token
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:211: error: expected initializer before '&' token
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:215: error: expected initializer before '&' token
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:219: error: expected initializer before '&' token
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:222: error: expected initializer before '&' token
In file included from C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/Stream.h:26,
                 from C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/HardwareSerial.h:27,
                 from C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/Arduino.h:192,
                 from DigitalReadSerial.cpp:11:
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/Print.h:33: error: redefinition of 'class _Printable'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:49: error: previous definition of 'class _Printable'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/Print.h: In member function 'void Print::println(const _Printable&)':
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/Print.h:91: error: no matching function for call to '_Printable::print(Print&) const'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:51: note: candidates are: virtual void _Printable::print(int&) const
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/Print.h: In member function 'void Print::print(const _Printable&)':
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\hardware\arduino\cores\arduino/Print.h:93: error: no matching function for call to '_Printable::print(Print&) const'
C:\Users\Jean-Baptiste\Dropbox\PPE 2011-2012\programmation\arduino-1.0\libraries\Flash/Flash.h:51: note: candidates are: virtual void _Printable::print(int&) const
DigitalReadSerial.cpp: In function 'void loop()':
DigitalReadSerial:17: error: initializer fails to determine size of '__c'

et si j’essaye de recompiler le même sans avoir changer la fenêtre en enlevant le flash plus de soucis…

Une idée ? Parce que niveau stockage de mémoire le flash m’aide vraiment… !

Merci d’avance à tous,

Jean-Baptiste

NB: Voici le lien du site où je cherche les réglages de mon flash Référence Arduino français Main/Librairie Flash Programme

et en plus voici le contenu de mon print.h après modification:

/*
  Print.h - Base class that provides print() and println()
  Copyright (c) 2008 David A. Mellis.  All right reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  Lesser General Public License for more details.

  You should have received a copy of the GNU Lesser General Public
  License along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/

#ifndef Print_h
#define Print_h

#include <inttypes.h>
#include <stdio.h> // for size_t

#include "WString.h"
#include "Printable.h"

// ------------- ajout pour librairie Flash ---------
#define ARDUINO_CORE_PRINTABLE_SUPPORT

    class Print;
    class _Printable
    {
    public:
      virtual void print(Print &stream) const = 0;
    };
// ------------- fin ajout pour librairie Flash ---------

#define DEC 10
#define HEX 16
#define OCT 8
#define BIN 2

class Print
{
  private:
    int write_error;
    size_t printNumber(unsigned long, uint8_t);
    size_t printFloat(double, uint8_t);
  protected:
    void setWriteError(int err = 1) { write_error = err; }
  public:
    Print() : write_error(0) {}
  
    int getWriteError() { return write_error; }
    void clearWriteError() { setWriteError(0); }
  
    virtual size_t write(uint8_t) = 0;
    size_t write(const char *str) { return write((const uint8_t *)str, strlen(str)); }
    virtual size_t write(const uint8_t *buffer, size_t size);
    
    size_t print(const __FlashStringHelper *);
    size_t print(const String &);
    size_t print(const char[]);
    size_t print(char);
    size_t print(unsigned char, int = DEC);
    size_t print(int, int = DEC);
    size_t print(unsigned int, int = DEC);
    size_t print(long, int = DEC);
    size_t print(unsigned long, int = DEC);
    size_t print(double, int = 2);
    size_t print(const Printable&);

    size_t println(const __FlashStringHelper *);
    size_t println(const String &s);
    size_t println(const char[]);
    size_t println(char);
    size_t println(unsigned char, int = DEC);
    size_t println(int, int = DEC);
    size_t println(unsigned int, int = DEC);
    size_t println(long, int = DEC);
    size_t println(unsigned long, int = DEC);
    size_t println(double, int = 2);
    size_t println(const Printable&);
    size_t println(void);

// ------------- ajout pour librairie Flash ---------

    void println(const _Printable &obj)
    { obj.print(*this); println(); }
    void print(const _Printable &obj)
    { obj.print(*this); }

// ------------- fin ajout pour librairie Flash ---------

};

#endif

Bonjour

Peut-être as tu eu le même soucis que moi avec la lib servo : http://arduino.cc/forum/index.php/topic,81327.0.html

Ca ressemble étrangement aux messages d'erreur que j'avais

Franck

Malheureusement non, ça me retourne ça:

DigitalReadSerial.cpp: In function 'void loop()':
DigitalReadSerial:17: error: initializer fails to determine size of '__c'

Bonjour,

Pour faire simple la version 1.0 à apporter de grosse modification à l'api arduino, le fichier WProgram.h ce nomme désormais Arduino.h, les classes Print, Serial, ... ont était modifier, ...

A l'heure actuelle [u]AUCUNE[/u] librairie réalisé pour les version 0023, 0022 ... ne peut compiler sous l'arduino IDE 1.0, la seul solution pour le moment est de rester sous arduino 0023.

J'ai bien fait un patch permettant d'utiliser sous 1.0 l'api 0023 mais c'est pas une solution viable à long terme donc pour le moment ... rester en arduino 0023 reste la seul vrai solution.

Pardon de déterrer un aussi vieux sujet mais j'ai un problème identique lorsque j'essaye d'utiliser la lib FLASH. Y a t'il une solution, je ne trouve pas de tuto.

Merci d'avance.