Avatar for fanoush


Member since Jul 2018 • Last active Jul 2019
  • 3 conversations

Most recent activity

  • in Puck.js, Pixl.js and MDBT42
    Avatar for fanoush

    someone have tested serial and i2c over same pins with ds-d6 fitness tracker (which only have 2 gpios available without taking it apart and by default it is serial console) and switching to i2c worked fine. ttl serial is high when idle so pull up configuration should be similar with i2c and ttl serial.

    I guess it uses just internal configurable pull ups and not resistors on board but even if there are pull up resistors in ds-d6 the requirement for them should be similar for i2c and serial (?) so in general this combination should work.

  • in Tutorials
    Avatar for fanoush

    Very nice, thanks for confirming this. I feared that even wireless and ssh could affect the reliability. BTW, those stlink clones are in fact generic stm32f103c8t6 boards in small usb stick like package so they are also quite versatile but Zero (W) is definitely better and far more flexible.

    Can openocd run as a daemon without attaching to device immediately? Then one could run it on the Zero W automatically at boot time so one would not need to login over ssh to it since it runs as server already. And if it is not possible out of box maybe it can be proxied over inetd so it would try to start and attach each time one opens network connection to openocd port.

  • in Tutorials
    Avatar for fanoush

    Indeed it is poor man's SWD for free if you have the Pi. However when Pi is used also as a desktop the connection is very unreliable. I tried this or Pi 3B+ and when just moving window the opened SWD connections breaks. But when just using already opened terminal window it works fine. Maybe it is also because dynamic CPU scaling as there are some hardcoded numbers expecting specific CPU frequency in the config.

    But I guess Zero as a dedicated device over e.g. serial or USB could be quite reliable in this. In fact just reliable as those <$2 STLINK clones from aliexpress are :-)

  • in ESP8266
    Avatar for fanoush

    Oh, they have this sandboxed 70Kb minimized javascript interpreter written in javascript to allow this. Looks a bit heavy for Espruino.

  • in ESP8266
    Avatar for fanoush

    Yes, while it looks sensible, what you did in fact does not makes sense in event based system like espruino. The while block is useful only for short code that finishes quickly and not with true condition and not with any wait inside.

    Your blocks would translate well to e.g. micropython. Yes it is confusing and your case perfectly shows how those blocks are hiding the true nature of event based javascript and Espruino. The first generated code is in fact complete nonsene, which is not your fault. Your fix is well meant but not really helping, check e.g. this explanation

    Maybe the block->code generation could be much smarter to create illusion that this works but it looks like currently it is not clever enough.

  • Avatar for fanoush

    you could add something like a 1/2 AA Lithium (Lithium Thionyl Chloride or similar) battery

    Interesting, thanks, never heard of this chemistry and form factor. In some datasheet it says "open-circuit voltage of 3.67 V and an operating voltage of 3.60 V" Do you connect it directly to VDD or use LDO or diode or something? nrf52832 specfications says Flexible power management 1.7 V–3.6 V supply voltage range

  • in General
    Avatar for fanoush

    One example is this short code

    E.enableWatchdog(6, false);
    var wdint=setInterval(()=>{if(!D1.read())E.k­ickWatchdog();},1000);


    Uncaught SyntaxError: Got ';' expected ','
     at line 1 col 77

    It happens also with more complex lambdas with parameters like (x,y)=>

  • in General
    Avatar for fanoush

    This is known issue with Esprima https://github.com/espruino/EspruinoTool­s/issues/64
    I hit it very quickly when using lambdas too so I am currently torn between not using lambdas and switching to closure online minifier (which is sometimes slow).

    The bug is from december 2018 and last comment suggests using terser in WebIDE in future. Terser is used e.g. in webpack.

  • in Projects
    Avatar for fanoush

    Oh, so I can have both? Two lines of watchdog pinging in .boot0 and rest in .bootcde? And the IDE will not clear the other one at upload? That would be best. Will try. Thanks.
    It works, I saved just watchdog setup and kicking code into .boot1 and it gets run together with main code, IDE does not touch it and uploading works also with reset before upload! Also as a bonus when I hold button for 6 seconds it reboots and does not start .bootcde because I still hold the button at boot time. So the code is not automatically started which is what is best when there is some bug that needs watchdog reset. All this still without your recent changes.
    Your changes however fix the auto mode that could cause similar unexpected isssues after reset()

  • in Projects
    Avatar for fanoush

    I guess it'd make sense to stop the watchdog inside jshReset (or ensure that 'auto' watchdog stayed working) to avoid this sort of problem?

    I guess you can't disable watchdog without doing reboot which is the point of having reset() call (so it works e.g. over BLE connection without disconnecting). So if upload could find that manual watchdog mode is enabled, then switch to automatic mode (if possible) or just refuse upload. Or at leasrt disable 'reset before upload', or .... it is complicated due to different upload modes (to ram vs to storage). I guess upload to storage does not need reset before upload checkbox enabled. It just writes .bootcde and then could reset after upload an load it. Reset before upload makes more sense with upload to RAM since it is full and stuff is otherwise modified in place (?).
    BTW, I find all those settings for code upload scattered over all other IDE setings hard to manage as I want to change them often. Would prefer the 'send to espruino' button pop up small dialog (maybe only when holding the button longer?) with just few options : reset before upload,save on send mode, set time and maybe minify yes/no. Sometime I would even only check 'set time' without any code upload.

    Come to think of it, should auto watchdog cause Espruino to automatically wake up in time to kick the watchdog? It'd seem sensible.

    Well, yes but the empty setInterval workaround solves it too, depend how much work and code it is.

    I wouldn't have thought Espruino would get 'stuck' executing code since it should break out with an exception when it hits the first 0xff

    Yes sounds strange. I don't know what is was, just that both serial and NUS console was not available after that watchdog reboot. The device was still advertising but web ide could no connect. So after trying it for few minutes I left it alone and tried later.

    but you may have been unlucky in that the part of the code that was saved may have enabled watchdog, but then the bit that actually kicked it didn't get loaded?

    It was like this:
    I uploaded code with first two lines added like this

    E.enableWatchdog(6, false);
    var wdint=setInterval(function(){if(!BTN1.re­ad())E.kickWatchdog();},1000);

    and then my other code. This worked fine and after testing it and doing some changes in IDE I wanted upload another version with changes. And unfortunately I had 'Reset before Send' setting enabled. So it called reset() and then started upload which was longer that 6 seconds.

    And so my guess is that it rebooted with inconsistent storage with half of code and rest of 0xff and additionally after reboot and running through this, the serial console was further flooded with the rest of uploaded code.