arduino ethernet, IDE 1.0.1 libreria FLASH e funzione memcpy()

Ciao a tutti,

ieri ho fatto delle prove per liberare SRAM dalla mia arduino ethernet mediante la libreria FLASH....
ho dichiarato le variabili come descritto nei vari esempi, ho utilizzato memcpy() per il recupero dei dati e tutto sembra funzionare correttamente...

sembra però!!!

di seguito il caso specifico:
1- dichiaro la variabile di appogio per i dati provenienti dalla flash

uint8_t* bufAddr;

2- dichiaro la mia flash_table come segue, tipo=unint8_t, nome=FbofAddr, len=8

FLASH_TABLE(uint8_t, FbufAddr, 8, { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                               { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F });

3- recupero i dati dalla flash e li appoggio su bufAddr dichiarato in precedenza ed attivo la lettura dei sensori...

for (int i=0; i<12; ++i){
   memcpy(&bufAddr,&FbufAddr[i],8); //<<-- punto in questione
   datastreams_meas[i].setFloat(ReadDS18x20(bufAddr));
   Serial.print("index: ");
   Serial.println(i, DEC);
   printData(bufAddr);
   }

a questo punto, la funzione memcpy(&bufAddr,&FbufAddr*,8); mi restituisce un array di 8 byte che dovrebbero essere gli stessi contenuti in FLASH_TABLE partendo da un indice 0 fino a indice 11 ossia 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F , bèh i dati ci sono..., da indice 0 a indice 11, ma non sono minimamente correlati a quelli presenti in flash...*
mi sfugge qualcosa? devo effettuare uno shift register di 2 byte per il puntatore (credo, visto che sizeof(&FbufAddr*); mi restituisce 2)*
credo che mi sto perdendo in un nun nulla...
grazie ancora :slight_smile:
saluti
kattivik76

Non so risolvere il problema di cui sopra, ma ti segnalo che è uscita l'IDE 1.0.3 che risolve alcuni bug della 1.0.1 e 1.0.2.

ARDUINO 1.0.3 - 2012.12.10

[hardware]

* Added support for the Arduino Esplora

[environment]

* Signed application for MacOSX 10.8

[core]

* Fixed power-up-starts-bootloader in Leonardo (and derivative) 
  bootloaders. (Kristian Lauszus)
  (https://github.com/arduino/Arduino/pull/118)

* Fixed digital_pin_to_timer_PGM array in Leonardo variant.

* Published updated Wifi firmware

* Updated source code for atmega8 bootloader

[libraries]

* Added 600 baud support in SoftwareSerial (Sébastien Jean)
  (http://github.com/arduino/Arduino/issues/1146)

ARDUINO 1.0.2 - 2012.11.05

[hardware]

* Added support for the Arduino Micro.

* Added support for the LilyPad Arduino USB.

* For Arduino Mega, having avrdude use "wiring" not "stk500v2" for
  uploads (to improve auto-reset behavior). 
  http://code.google.com/p/arduino/issues/detail?id=806

[environment]

* Find-In-Reference now works whether or not text is selected.
  http://code.google.com/p/arduino/issues/detail?id=940

* Not generating prototypes for functions that already have them.
  (Lars J. Nielsen).
  http://code.google.com/p/arduino/issues/detail?id=973

* Improved line numbers for error messages. (Paul Stoffregen)
  http://code.google.com/p/arduino/issues/detail?id=907

* Automatically create libraries folder in the sketchbook.
  (Paul Stoffregen)
  http://code.google.com/p/arduino/issues/detail?id=986

* Tutorial on installing libraries (linked from readme.txt in the
  libraries folder). (Limor Fried)

* Fix to allow selection of Norwegian. (Rune Fauske)

* Fix to race condition / occasional error in compilation. (gandrewstone)
  http://code.google.com/p/arduino/issues/detail?id=950

* Don't break long C++ comments during auto-format.
  http://code.google.com/p/arduino/issues/detail?id=255

[core / libraries]

* Included WiFi library and wifi shield firmware.

* Added ability to specify serial configuration (data bits, stop bits
  and parity check) in Serial.begin(). (Alarus)
  http://code.google.com/p/arduino/issues/detail?id=770

* Avoided overruns of the incoming serial (CDC) buffer on the Leonardo.
  (Peter Van Hoyweghen)

* Avoided auto-reset of the Leonardo when opening serial port after
  upload without specifying a baud rate. (Peter Van Hoyweghen)

* Fix for tone() on the Leonardo. (Shigeru Kanemoto)
  http://code.google.com/p/arduino/issues/detail?id=960

* Fix for SD library on Leonardo.
  http://code.google.com/p/arduino/issues/detail?id=931

* Added other write functions on Leonardo.
  http://code.google.com/p/arduino/issues/detail?id=958

* Added support for Leonardo interrupts 2 and 3. (Kristian Lauszus)

* Print ovf, inf, or nan accordingly in Serial.print(). (Nick Gammon)
  http://code.google.com/p/arduino/issues/detail?id=946
  http://code.google.com/p/arduino/issues/detail?id=961
  http://code.google.com/p/arduino/issues/detail?id=967

* Fix initialization of SPI data lines. (gandrewstone)
  http://code.google.com/p/arduino/issues/detail?id=888

* Serial.flush() waits for last byte to transmit. (michele.mazzucchi)
  http://code.google.com/p/arduino/issues/detail?id=871

* Adding overloads so Serial.write(0) works.
  http://code.google.com/p/arduino/issues/detail?id=1006

[build]

* Fix Linux arduino script when there are spaces in directory name.

* Pass Linux command line arguments from arduino script through to the
  Java code. (Allows specifying sketch to open on command line.)

[examples]

* Included examples for the starter kit.

Posso sapere a titolo informativo cosa ti serve leggere la flash del chip w5100? è di questo che stai parlando no?

ciao

no no, memorizzo le costanti in progmem utilizzando la libreria flash.h ma sempre di arduino, non del w5100 :wink:

tutto questo perchè, avendo memoria limitata, a volte mi si resetta e riparte... e non va bene :slight_smile:

saluti
kattivik76

soluzione, magari non proprio pulitissima...

dichiarazioni iniziali:

#include <HttpClient.h>
#include <Cosm.h>
#include <Ethernet.h>
#include <SPI.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <EEPROM.h>
#include "EEPROMAnything.h"
#include <Flash.h>

// arrays to hold device addresses 28126A080300007F
DeviceAddress bufAddr;   //<---

FLASH_TABLE(uint8_t, FbufAddr, 8, { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },   //<---
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F },
                                  { 0x28,0x12,0x6A,0x08,0x03,0x00,0x00,0x7F });

// Define the strings for our datastream IDs
CosmDatastream datastreams_meas[] = {
  CosmDatastream("0", strlen("0"), DATASTREAM_FLOAT),
  CosmDatastream("1", strlen("1"), DATASTREAM_FLOAT),
  CosmDatastream("2", strlen("2"), DATASTREAM_FLOAT),
  CosmDatastream("3", strlen("3"), DATASTREAM_FLOAT),
  CosmDatastream("4", strlen("4"), DATASTREAM_FLOAT),
  CosmDatastream("5", strlen("5"), DATASTREAM_FLOAT),
  CosmDatastream("6", strlen("6"), DATASTREAM_FLOAT),
  CosmDatastream("7", strlen("7"), DATASTREAM_FLOAT),
  CosmDatastream("8", strlen("8"), DATASTREAM_FLOAT),
  CosmDatastream("9", strlen("9"), DATASTREAM_FLOAT),
  CosmDatastream("10", strlen("10"), DATASTREAM_FLOAT),
  CosmDatastream("11", strlen("11"), DATASTREAM_FLOAT),
};

effettuo il setup delle sonde e recupero gli indirizzi da FbufAddr, che ho scoperto essere semplicemente un array bidimensionale :slight_smile:

void Setup_DS18x20(void)

{
  // Start up the library
  sensors.begin();
  
  // set the resolution to N bit
  for (int t=0; t<12; ++t){            //<---
    for (uint8_t i = 0; i < 8; i++){   //<---
      bufAddr[i] = FbufAddr[t][i];   //<---
    }
    sensors.setResolution(bufAddr, TEMPERATURE_PRECISION);   //<---
  }
}

di conseguenza aggiorno i datastream con i dati provenienti dalle sonde 1wire

void COSM_DataOut() {
        //free(bufAddr);
	Serial.println("+++++++++++++++++++++++++++++++++++++++++++++++++");
        for (int t=0; t<12; ++t){             //<---
          for (uint8_t i = 0; i < 8; i++){    //<---
             bufAddr[i] = FbufAddr[t][i];   //<---
          }
          datastreams_meas[t].setFloat(ReadDS18x20(bufAddr));   // <---
            switch (t){
              case 0:
                T_Pozzo1 = ReadDS18x20(bufAddr);
                // statements
              break;
              case 1:
                T_Pozzo2 = ReadDS18x20(bufAddr);
                // statements
              break;
              default: 
              // statements
              break;
            }
          //Serial.print("index: ");
          //Serial.println(i, DEC);
          printData(bufAddr);
         }
    
        datastreams_state[0].setInt(my_status.ST_RL_vlv3vie);
        datastreams_state[1].setInt(my_status.ST_sel_estate_inverno);
        
        Serial.println("Uploading meas it to Cosm");

        int ret = cosmclient.put(feed_meas, cosmKey);
        Serial.print("cosmclient.put returned ");
        Serial.println(ret);
	delay(5000);
        Serial.println("Uploading states it to Cosm");
        ret = cosmclient.put(feed_state, cosmKey);
        Serial.print("cosmclient.put returned ");
        Serial.println(ret);
        delay(5000);
}

il tutto funziona correttamente :slight_smile: ecco il link: http://ctfbarzon.altervista.org/

saluti
kattivik76