You are reading a single comment by @Rook and its replies. Click here to read the full conversation.
  • Hi all:

    Recently, I am trying to collect analog data into the flash and save as a file by using MDBT42Q.
    Below is the example code in the Data collection part I used to explain my trouble:

    var storage = require("Storage");
    var FILESIZE = 65536;
    var count = 0;
    var file = {
      name : "",
      offset : FILESIZE, // force a new file to be generated at first
    };
    
    // Add new data to a log file or switch log files
    function saveData(txt) {
      var l = txt.length;
      if (file.offset+l>FILESIZE) {
        // need a new file...
        file.name = file.name=="log2"?"log1":"log2";
        // write data to file - this will overwrite the last one
        storage.write(file.name,txt,0,FILESIZE);­
        file.offset = l;
      } else {
        // just append
        storage.write(file.name,txt,file.offset)­;
        print(count);
        count += 1;
        file.offset += l;
      }
    }
    
    // Write some data
    setInterval(function() {
      saveData(getTime()+","+E.getTemperature(­)+"\n");
    }, 10);
    

    The trouble is that: When I change the FILESIZE bigger than 32*1024(32768), my Web IDE will just stuck and return nothing.
    I have try require("Storage").eraseAll(), reset() and save(), it is all useless.
    In the attachment is some information about my memory usage.

    Thank you guys very much!


    1 Attachment

    • 1597731573(1).jpg
About

Avatar for Rook @Rook started