-
• #2
does anyone have any ideas how to fix this?
-
• #3
Sat 2021.02.20
How many sensors are attempted to be traversed using the
forEach
?'does anyone have any ideas how to fix this'
I do not have this hardware sensor. I do however note the following:
When L5 in the second code snippet was inserted inside thesetInterval()
, a connect object is being created once each second. Eventually memory runs out as has been discovered.From your link
beneath heading 'Multiple sensors' uses an array of exactly three connect objects to which the data reads are applied.
Has the code in that section been used verbatim and what were those results?
The module source is here, if that helpsFunction
getTemp()
uses a callback which potentially could be null andsetTimeout()
function call.Does lengthening the interval in L14 reduce the number of ASSERT's?
-
• #4
How many sensors are attempted to be traversed using the forEach?
About 8 sensors.
I do not know enithing , i only use code from example
-
• #5
Sun 2021.02.21
re post #3 'Has the code in that section been used verbatim and what were those results?'
re post #4 'i only use code from example'L3 of the first code block in post #1 does not match the three sections below heading 'Multiple sensors' as the 'sensors' array definition is missing.
My inquiry was to see what errors occurred when using those three code blocks. ( me thinks none )
To prove this to yourself, add a
console.log( "Line 6: " + sensors );
(modify to your choosing) statement at L6 of the first code block to determine if your eight sensors are recognized.re: 'I do not know enithing' (sic)
May I ask how many years of Javascript & coding experience you have so that we may provide other tutorials to assist.
-
• #6
I'em frontend developer, and I know JS pretty well.
everything works, the sensors are detected. The problem is that in one example ASSERT is an error, in the second one runs out of memory.
you don't even need to look at my code, the same problem will be copying the example from the espuino websiteASSERT(jsvGetLocks(var) < 15) FAILED AT src/jsvar.c:721
this error also occurs if you call the ws.send("....") 15 times (by https://www.espruino.com/ws#websocket-server)
.... var server = require('ws').createServer(onPageRequest); var clients = []; server.listen(8000); server.on("websocket", function(ws) { clients.push(ws); ws.on('message',function(msg) { print("[WS] "+JSON.stringify(msg)); }); ws.send("Hello from Espruino!"); }); setInterval(function(){ clients.forEach(ws => ws.send('....')); //after 14 events ERROR ASSERT(jsvGetLocks(var) < 15) FAILED AT src/jsvar.c:721 },5000); .....
This dirty example helps, but not nice
setInterval(function(){ var cc = clients.map(ws => { ws.send('....'); return ws.clone(); } ); clients =cc; },5000);
Any implementation works poorly, each approach has different problems
this example by https://www.espruino.com/DS18B20
After several seconds the error:
If sensors search put to set Interval this problem disappears , but other appears
This code fills all RAM in time and device stops working
Interval time increase does not have any influence, it only delays the time of crash