Avatar for ChristianW

ChristianW

Member since Nov 2016 • Last active Oct 2021
  • 18 conversations
  • 149 comments

German IT developer who found his long lost love for electronics and connected devices...

Most recent activity

    • 17 comments
    • 2,844 views
  • in Projects
    Avatar for ChristianW

    Thanks @Gordon, there was not much time left before the race and I had to hack everything together to get a semi-working setup.
    It actually worked to a point, but unfortunately the race was called off during warmup because of the wet weather conditions making the track slippery.
    Maybe there is another date in the next weeks, that may give me some time for improvements...

  • in Projects
    Avatar for ChristianW

    Yes, it's reproducable.
    This is/was the actual line:

    Flash.s.write(Flash.NAME, [CONST.LAP_DATA_SIZE], 0, 1 + CONST.LAP_DATA_SIZE * CONST.LAPS_STORAGE)
    

    Being Flash.NAME = 'laps', LAP_DATA_SIZE=8, LAPS_STORAGE=2000 which would be:

    write('laps', [8], 0, 16001)
    

    which worked perfectly fine in the console, but not when called via a setWatch() callback when a button was pressed.
    I even changed all the this. references to absolute ones in case the context got lost inside the method.

  • in Projects
    Avatar for ChristianW

    Maybe I'll just switch back to RAM and just use binary, reserved data for now.

    Is there a way to safely acquire memory without crashing the system?
    Something like:

    1. determine how much memory we have left process.memory().free
    2. subtract some margin of memory left unallocated (how much would you suggest?)
    3. calculate how big my ArrayBuffer can get (any clues here?)

    Or I'll just do it via trial + error and put the hardcoded numbers in...

  • in Projects
    Avatar for ChristianW

    Another issue:
    If I keep my storage file in flash and try to upload new code (minified + direct to flash), it gives me this:

    No errors. Minified 23072 bytes to 14425 bytes.
    >
     ____                 _
    |  __|___ ___ ___ _ _|_|___ ___
    |  __|_ -| . |  _| | | |   | . |
    |____|___|  _|_| |___|_|_|_|___|
             |_| espruino.com
     2v09 (c) 2021 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >fficial boards and donations:
    http://espruino.comds and do$>DgGAMABgAOD4AAAwwEgBgAwAkBhgAAYACAAg­APAIAIAYAAAEGCFBEgkQUIMEAAH/yAJAEAAYADAA­YADAAYAAQBIAn/wAAGAMAYADAAYAAAAIAEACABAA­gAQAIAAQAEAAAADAKQFICkA+AAD/gIQEICEA8AAA­PAIQEICEAkAAAPAIQEICEP+AAAPAKQFICkA0AAAQ­A/wkASAIAAAAPAISEJCEh/gAD/gIAEACAA+AAAQB­PwAAABAAggSfwAA/4AQAYASAQgAAgAf8AAA/AQAI­AD4CABAAfAAAPwEACABAAfAAAHgEICEBCAeAAAP+­EICEBCAeAAAHgEICEBCA/4AAPwCACABAAQAAAEQF­ICkBKAiAAAIAfwCEBCABAAAPgAIAEACA/AAAMABg­AMAYAwAAAPAAYAYAwAGABgPAAACEAkAMAJAIQAAD­5ACQBIAkP8AACEBGAlAUgMQAAAgAQD3iAJAEAAf/­AAEASAI94BAAgAAAIAIAEADAAgAQAQAAAFAHwFUC­qBBARAAAACAOAAAAQQI/4kASAAAADgAAA4AAAEAA­ABAAAAQAAEACAH/AgAQAAAFACgH/AoAUAAAEAEAE­ABAAQAAAGMAYAwBjAAAAwAADEKRDIiiQRIEYAAAI­AKAIgAAH4ECCBA/AkQSIIEAACDFChiRSIKEGCAAD­AAQAAAEAMAAADAAQAwAEAAABADAAQAwAAAAQAcAf­AHABAAAAQAIAEACABAAAAQAIAEACABAAgAQAAAgA­gAIAIAAACAB4AgAAAPAGADwAAAEQlIKkJKAiAAAI­gCgAgAAAeAQgIQDwCkBSAaAAAIQkYKUJSAxAAAYA­CAQgAOEIAIAYAAAL8AAAeAQgf4EIBIAAATA+gkQS­IAEAABBAfAIgEQCIB8BBAAAwAEgBQAeAUASAwAAA­ffAADCCYhKQjIIYAAEAAABAAAAH4ECCZBSgpQQIH­4AAAQBUAqAPAAAAQAUAVAFAEQAAAQAIAEADwAAH4­ECC9BU",1024);
    

    The only way to get new code flashed is removing the storage file first it seems.

    >require('Storage').getFree()
    =12116
    >require('Storage').list()
    =[
      "laps",
      ".bootcde"
     ]
    
  • in Projects
    Avatar for ChristianW

    @Gordon I'd like to have a method to do a reset "in the field", meaning starting everything new when I have to.

    What is working is calling my reset() method via commandline.
    What does not work is calling it through a handler after a button was pressed.

    The method does this:

      reset: function() {
        console.log('reset');
        if(!Flash.s.write(Flash.NAME, [CONST.LAP_DATA_SIZE], 0, 1 + CONST.LAP_DATA_SIZE * CONST.LAPS_STORAGE)) {
          throw new Error('could not reserve storage');
        }
        Flash.pos = 0;
      },
    

    manual call:

    >Flash.reset()
    reset
    =undefined
    

    through handler:

    reset
    Uncaught Error: Unable to find or create file
     at line 1 col 114
    ...ATA_SIZE*CONST.LAPS_STORAGE))throw new Error('could not reserve stor...
                                          ^
    in function "reset" called from line 1 col 15
    a&&Flash.reset(),Object.keys(this.macs).­forEach(c=>{const d=this.macs[c];...
                               ^
    in function "init" called from line 1 col 122
    ...tons.BTN_MID]&&(Race.init(!0),ErrorLo­g.log=[]),this.objects.forE...
                                      ^
    in function "wakeup" called from line 1 col 16
    a?Power.wakeup():Power.sleep()
                   ^
    in function "onOff" called from line 1 col 37
    ...N?Buttons.onOff(a,b.state==0):Buttons­.event(a,b.state==0)
                                    ^
    in function called from system
    
  • in Projects
    Avatar for ChristianW

    OK - something works. I can somehow create a storage and fill it up with data.
    What does not work is removing it at runtime.

    So how to erase and recreate a Storage file on runtime?

    I can storage.eraseAll() but that would remove my code too.

    I can

    storage.write('name', [data], 0, large_value)
    

    but that gives me

    Uncaught Error: Unable to find or create file
    

    even if I 'overwrite' my current file.

    So I'll try to

    storage.erase('name');
    storage.compact(); // this seems to be necessary to actually free up the space
    storage.write('name', [data], 0, large_value):
    
    

    but run into errors too.

    Is Storage buggy or am I doing something wrong here?

  • in Projects
    Avatar for ChristianW

    Thanks @allObjects, but since the day of the track race is already next Sunday there is not much time left to try something with external hardware.

    @Gordon I tried to implemented Storage yesterday, but it gave me headaches.

    EDIT: another error found. Don't put something like require('Storage').eraseAll() as first line in your code on upload... oh my.

  • in Projects
    Avatar for ChristianW

    PS:
    I blew up another MDBT42Q because I inserted the battery upside down... Only one spare left.
    The others are at FRAport waiting for customs.
    Hope they arrive this week, since the race is next Sunday.

    Thanks to Brexit shipping times are degraded back to the Napoleonic era...

Actions