Most recent activity
-
- 20 comments
- 5,249 views
-
- 45 comments
- 5,500 views
-
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... -
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 thethis.
references to absolute ones in case the context got lost inside the method. -
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:- determine how much memory we have left
process.memory().free
- subtract some margin of memory left unallocated (how much would you suggest?)
- 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...
- determine how much memory we have left
-
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$>DgGAMABgAOD4AAAwwEgBgAwAkBhgAAYACAAgAPAIAIAYAAAEGCFBEgkQUIMEAAH/yAJAEAAYADAAYADAAYAAQBIAn/wAAGAMAYADAAYAAAAIAEACABAAgAQAIAAQAEAAAADAKQFICkA+AAD/gIQEICEA8AAAPAIQEICEAkAAAPAIQEICEP+AAAPAKQFICkA0AAAQA/wkASAIAAAAPAISEJCEh/gAD/gIAEACAA+AAAQBPwAAABAAggSfwAA/4AQAYASAQgAAgAf8AAA/AQAIAD4CABAAfAAAPwEACABAAfAAAHgEICEBCAeAAAP+EICEBCAeAAAHgEICEBCA/4AAPwCACABAAQAAAEQFICkBKAiAAAIAfwCEBCABAAAPgAIAEACA/AAAMABgAMAYAwAAAPAAYAYAwAGABgPAAACEAkAMAJAIQAAD5ACQBIAkP8AACEBGAlAUgMQAAAgAQD3iAJAEAAf/AAEASAI94BAAgAAAIAIAEADAAgAQAQAAAFAHwFUCqBBARAAAACAOAAAAQQI/4kASAAAADgAAA4AAAEAAABAAAAQAAEACAH/AgAQAAAFACgH/AoAUAAAEAEAEABAAQAAAGMAYAwBjAAAAwAADEKRDIiiQRIEYAAAIAKAIgAAH4ECCBA/AkQSIIEAACDFChiRSIKEGCAADAAQAAAEAMAAADAAQAwAEAAABADAAQAwAAAAQAcAfAHABAAAAQAIAEACABAAAAQAIAEACABAAgAQAAAgAgAIAIAAACAB4AgAAAPAGADwAAAEQlIKkJKAiAAAIgCgAgAAAeAQgIQDwCkBSAaAAAIQkYKUJSAxAAAYACAQgAOEIAIAYAAAL8AAAeAQgf4EIBIAAATA+gkQSIAEAABBAfAIgEQCIB8BBAAAwAEgBQAeAUASAwAAAffAADCCYhKQjIIYAAEAAABAAAAH4ECCZBSgpQQIH4AAAQBUAqAPAAAAQAUAVAFAEQAAAQAIAEADwAAH4ECC9BU",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" ]
-
@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),ErrorLog.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
-
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? -
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. -
German IT developer who found his long lost love for electronics and connected devices...