You are reading a single comment by @ChristianW and its replies. Click here to read the full conversation.
  • I'd like to have a method to do a reset "in the field", meaning starting everything new when I have to.

    Yes, that should be fine...

    Uncaught Error: Unable to find or create file

    Strange... Could you print the arguments you're giving to Flash.s.write? It might help to figure out if anything is 'off'.

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

    Wow, I haven't seen that before. And it's reproducable?

    I guess maybe Espruino ends up compacting, but that compaction takes so long it causes the flow control to time out. Does the upload take a long time at that point? Do you get a FIFO_FULL message? Although I guess you might have got that at some point in the past.

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

    You should be able to do something like:

    m=process.memory();myArray = new Uint8Array((m.free-100)*m.blocksize)

    So then you're leaving ~100 memory blocks free for execution. But you may well have to tweak that so you don't get out of memory errors

  • 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.

About

Avatar for ChristianW @ChristianW started