-
• #2
Sun 2019.11.10
Hello @user104751
While I don't have a definitive response just yet, I did notice in L#13 that variable 'a' doesn't appear to be defined. What is that line supposed to do? (EDIT: see edit pp below)
ref: https://www.w3schools.com/jsref/jsref_map.asp
'Note: map() does not execute the function for array elements without values.'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Arrow_functions
https://codeburst.io/javascript-arrow-functions-for-beginners-926947fc0cdcIs it possible that 'a' is defined in a separate module?
EDIT:
After re-reading the definition for map() it's argument *is* the arrow function defined there. So it isn't necessary to define 'a' using the 'var' keyword
but, . . . if the contents passed to the map() function are undefined or null still might be throwing an error as indicated in the note above just below the ref linkIf 'a' becomes undefined might be a possible reason. One could wrap the guts of the setInterval function with a try/catch block to see if any errors could be trapped that are just bubbling up and missed.
Is L#17
setInterval()
intended to execute five times a second?Has
process.memory()
been run and how much free memory does remain. Is it possible the above snippet is using and not freeing all available memory?
Just found this-Another user had the same error recently using setWatch(). See end of post:Let's start with the basics, what is the result of
process.env
? Please post for flashed version verification. -
• #3
The example comes from here: http://www.espruino.com/Puck.js+Infrared.
Here's the output of process.memory() before and after loading the code.
process.env follows.
process.memory()
={ free: 2217, usage: 33, total: 2250, history: 12,
gc: 0, gctime: 3.23486328125, "stackEndAddress": 536924008, flash_start: 0, "flash_binary_end": 419924,
"flash_code_start": 442368, flash_length: 524288 }
| |_ ___ ___ _ ||___ ___
| |_ -| . | _| | | | | . |
||_| || |_|||_|_||_| espruino.com
2v04 (c) 2019 G.Williams
process.memory()
={ free: 2180, usage: 70, total: 2250, history: 46,
gc: 0, gctime: 3.2958984375, "stackEndAddress": 536924008, flash_start: 0, "flash_binary_end": 419924,
"flash_code_start": 442368, flash_length: 524288 }process.env
={
VERSION: "2v04",
GIT_COMMIT: "3956264e",
BOARD: "PUCKJS",
FLASH: 524288, RAM: 65536,
SERIAL: "f4801353-1c650745",
CONSOLE: "Bluetooth",
MODULES: "Flash,Storage,hea" ... "S,crypto,neopixel",
EXPTR: 536882364 }It is possible that the IR signals are not properly formulated i.e. more than a few transitions.
But I doubt the stream of data would overflow d[]. -
• #4
@user104751, I think you get some noise and may be additional signals that makes your interrupt buffer to overflow...
If your receiver is just sticked into puck's thru holes and the leads do not make good contact, lightest vibration - even from loud sound / music - give you additional signals and buffer overruns.
With additional signals may come from other sources or reflections.
Also, if you keep sending the buffer may overflow.
-
• #5
I did just stick the IR pins without soldering!
Just curious how I could look into the size of the interrupt buffer? What would be the function call?
Thanks.
-
• #6
You can check the error flags - https://www.espruino.com/Reference#l_E_getErrorFlags - but more details you would have to access with peek... where though is not known to me... may be it can be figured out looking at the firmware / source code...
You can bend / spread the leads a bit to get better contact.
Check also the battery of your puck...
Some architectural detail:
Espruino has mainly two interrupt driven activities:
Low level hardware activities that pick up pin changes and when watched it puts details it into an interrupt/event queue (similar do timeouts and intervals and completions of some low level functions, like receiving or sending data). This has highest priority and interrupts the other level of activities.
High level javascript activities that pick up what is in the event/interrupt queue and executes the piece of javascript that is tied to it. When done with one piece, it checks for the next one and executes it until all is done and then it goes to sleep / idle.
Since hardware events can happen much quicker than javascript can act on it, the events are put in the event queue. To not miss any events in JavaScript, JavaScript pieces should be as short/small as possible... after all, you have only one processor...
While running the following (example) code to read IR signals
I get this after a few reads:
What seems to be the issue?
How do I go about to debug this?
Thanks!