Fallen at the first #2741
Replies: 24 comments
-
Posted at 2018-07-14 by the1laz Hi Nick, are you typing this into the left hand side or right hand side of the IDE? Most modules aren't built into the firmware, the IDE loads it onto the board when you upload code from the right hand side. You could try typing the same code into the right hand side, or type
into the right hand side and click upload, which will load the module, then type your code into the left hand side. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-14 by Nickax Thanks very much That'll almost certainly be it - as I am pasting code into the left, 'immediate' window. I don't imagine I'm the first - or will be the last to make this mistake. Will try later - I would take silence as - it's working. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-14 by the1laz No problem. :) Yeah, I've seen a few other people miss that before. FYI, the left side is running commands directly on the board via a console, if a module isn't on the board yet, the board can't grab it. The right side will search your code for "require" and send the modules you need to the board before uploading your code. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-14 by Nickax In fairness - the example even says to paste on the right - I just jumped the gun in my excitement to get something working. Perhaps you can help with the next problem - I wired up the DS18b20 and after stripping the whitespace - which broke the pasted code I upload and run this (from the right window!) :-
Which - might be working - but it certainly isn't outputting anything to either the left window or the Pixl's screen So I thought i'd add a console.log to the Setinterval callback - like this:-
When I upload and run this .. there is a very short delay (probably the 1000ms) .. then it throws (on the left)
It seems incredibly fragile - and like anything I write breaks it - I've seen other posts where peoples program are getting corrupted - Am I suffering with that? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-15 by the1laz Hmm, not sure about that one. The code looks good, but the error message is indicating some of the code didn't make it, no idea why, I've never had an issue with sending code (to official boards) before. Might need @gfwilliams 's help. I'd recommend power cycling both your computer and the Pixl if you try again in the meantime, might be a Bluetooth connection issue. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by @allObjects @NickAx, sad to hear your tough start... so lucky me, it was a no brainer to leave A..o (and other decade old fun with Z8) aline and enjoy very much iot w/ JS on Espruino. To cut to the chase: copy-paste can have its issues since sometimes invisible rendering sequences make it into the code and mess it up. Take a look at some of these conversations... Temperature Web Monitor (you going for BLE), Developing Modules... latter uses the DS18B20 but just as an example to discuss the topic. Furthermore, as a general thing: 'never ever' - even though never ever say 'never ever' - do active things in level 0 - like Therefor, safest approach is using Take a look at simple explanation how to save code that espruino run on start? conversation. Even though a bit outdated, provides some insight what happens on upload and saving of code. btw, if you put posted code between lines that have three (3) back-ticks (accent-grave) with a blank line before and after, your code because easy to read... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by Nickax Thanks allObjects I will try moving my code into onInit() and restarting the board after each upload - although that seems like the bad old days. If OTA is so flaky - why is there no wired option for the Pixl ? - rhetorical question don't worry. I can see how it should work - and if it did - it would be a thing of beauty - But I have stumbled on some really silly fundamental problems. I understand about copy and paste - and invisible whitespace characters - (carriage returns, line feeds etc).. that caught me out early on but I have enough experience to spot it. The 'Level 0' setInterval() thing - I will need to read up on - I took setInterval() to be the primary mechanism for running asynchronous code - I'm just surprised and frustrated the upload mechanism is so fundamentally flawed. Again thanks for your reply Nick |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by @gfwilliams Sorry it's been such a pain to get started. Out of interest, did you go through http://www.espruino.com/Quick+Start+Code ? It seems modules and If data is getting lost, something is definitely going wrong (that's not normal at all!). I think it's possible that you may have got a As @allObjects says, the issue is likely that the code example isn't expecting to be executed at upload time, and some part of it takes a while to execute. It'd explain why everything is feeling so flaky - whitespace shouldn't cause any issues at all, but by reducing it you're reducing the amount of code that is sent after the Maybe try this - the difference is that
or your other option is to just use the If you're uploading code in future, please could you just highlight it and click the 'code' button in the editor? It makes it way easier for us to read :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by @gfwilliams It seems my reply was a bit late, but:
It's a frustrating combination of power usage, cost, and not enough pins on the microcontroller. However if you have a USB-TTL dongle handy it's just 4 wires away
The IDE itself should strip those out when you paste into it (especially on the right-hand side). The other issues you're having are I think a symptom of what's described above.
That shouldn't be an issue at all - it's actually the code that comes before it...
If you turn on It's just a bit unfortunate really as the vast majority of things you'd upload would work just fine - it's just the DS18B20/OneWire stuff pauses for some time when it is called. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by Nickax Hi Gordon Nice to meet you .. I (potentially) love what you are doing and have high hopes for my Pixl. I did indeed see that FIFO buffer error at least once .. but definitely not every time. I will try both of your suggestions - I'm not sure of the rationale for executing each line as it uploads - I can see that any setInterval could fire for a function not yet defined - or for that matter simple function calls could fail. Maybe I misunderstand (entirely). I could see I was getting syntax error on code I hadn't written - some sort of corruption. Apologies for my bad manners in code formatting. My laptop is an HP Spectre 360 - it has Bluetooth but I don't know if it's 'LE' - could that have anything to do with it ? BTW I'm using the native IDE not the web one .. I will see if it has a save on send option. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by Nickax Right... the fix appears to be to use the 'throttle send' option in the communications section of settings. Without it - I get stupid syntax errors about EOF encountered and expecting } - when all my braces are present and correct. With it .. worked first time (This is with the code refactored as per @gfwilliams 's suggestion - but I suspect the original may work) (Well, I say worked - my temperature comes back as null all the time but that's a different problem) I feel like I'm in with a chance now. Thanks everyone |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by @gfwilliams Hi! I don't generally work at the weekend so I'm afraid I'm a bit slow to offer any help here.
Yes, you wouldn't - once reported it doesn't get sent again unless the error flags are explicitly cleared (as generally repeatedly reporting it just compounds any overflow issues).
Basically on a microcontroller you haven't got a whole bunch of RAM available. If you had to store the whole program in memory and then run it, you'd be extremely limited by what you can get in - you basically need double the amount of memory (one for the text version, one for the version that's just been interpreted). You can save to flash with It's a bit of a compromise because we're trying to cram a JS engine into sometimes quite limited microcontrollers - but hopefully when you're used to it you'll find it's worth it!
This is almost certainly your code, but with sections missing? Or errors can get thrown from modules like DS18B20 but they're unlikely to be syntax errors.
If it's connected to the Pixl via Bluetooth then you can be pretty sure it's got Bluetooth LE. I haven't heard of cases where BLE is working and connecting but losing some data, so I think given what you've got so far, you're probably fine. I just tried the code I posted above and it works fine with the DS18B20 between GND and 3.3v. However, one thing to watch out of is that the OneWire implementation is software-based, and unfortunately the Bluetooth stack has to take absolute priority or the Bluetooth connection will drop out. It means that while you're connected by bluetooth, |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by Nickax Thanks again for another comprehensive reply. I have a 4k7 (yellow,purple, red,gold) resistor between 3.3v and Data and the sensor accross D13 and GND I think this is as per your example page - but maybe I misread somewhere |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by @gfwilliams Could you just double-check the 3.3v connection? It should be 2nd or 4th from the end of the Arduino connection : http://www.espruino.com/Pixl.js#pinout You don't actually need the 4k7 resistor now (we use the internal resistor in software) but it won't hurt. 85 is the magic number you get when the sensor has just initialised - which is what you might expect if it wasn't powered all the time. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by Nickax My (dumb) mistake ... I was caught out by the unused pin 25.9375 C Hurrah ! What's a software resistor ? - sounds like the kind of thing you send the apprentice down to the stores for - like a long weight, or green oil for the starboard lamp. Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by Wilberforce
|
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-16 by Nickax Thanks ... I have a lot to learn |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-17 by @allObjects ...in deed, it is JS... and that got my excitement going a while ago... and still goes on, even though I just made - at work -a very deep plunge into python - still trying to swim and not to drown (I mean to code and not to err out) ...and there are (micro) pythons similar to espruinos out there... and if power and size is not an issue, raspberry pi is the perfect platform (have to confess - to @gfwilliams - that I just received my 1st ordered berry... connected it - 3 B+ to display and mouse, and was blown away by it: just works, and a nice Linux is there... had not connected keyboard yet, but still could play a game (reversi). The plan is to use id from now on... as possible Espruino IDE environment and BLE bridge to WiFi / LAN - either with node.js or python... after all, I got that also going on for me...).
That's kind of an interesting comment... As @gfwilliams points out, RAM is not there to store and forward and do all the things... so this is what I see happening on upload:
You can see that by using arrow up after an upload: echo on and sent program come 'up'... that's also why after an upload you cannot get easily back to your last console command... @NickAx, keep sharing the pit falls we so glaringly glance over... RTM - Read The Manual, and more timely - WTY - Watch The Youtube can not be skipped to get the best out of any situation... No doubt, I can say for me - and @gfwilliams as well? - that we enjoy your excitement... it is received as rewards... no kidding: it spars to get and do even better than already good. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-17 by Nickax Hi again Just to repeat that the thing that solved it for me was the 'throttle send' option in the communications section of settings. All (well, most) of the problems melt away once it actually runs the code you send. Interestingly - I was also able to go back to the original code sample - with the require() up-front, and it worked just fine. I think the lesson here is to rule out the simplest causes first. The real question is why do some people 'experience lost characters' and what is the real fix. I don't know how common the problem is - common enough for there to be a tickbox. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-17 by Nickax I have an r-pi ... two in fact - and my experience with those has been equally, if not more frustrating - the plethora of languages and versions - and the sea of incompatible out out of date samples made it more or less impossible to work with. The elegance and simplicity of Espruino are what drew me to it - JS is NOT my favourite language but a year of writing TypeScript as a day job has softened my hatred slightly. What I can see is that for someone with no prior knowledge it is relatively easy to pick up as it is fairly compact. For someone from an OO background its a more difficult switch. I have limited spare time so I make the classic mistake of trying to skip the examples and videos - but I will try and avoid that temptation and get a better understanding of how it all works. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-17 by @gfwilliams
That's great - but you should be aware that it hasn't solved the underlying problem, so at some point you might have code that takes a lot longer to execute, and that'll cause you similar issues. It's good to hear what issues people hit when they just dive right in. I'll see if I can find a way of making the Web IDE detect common errors on the left-hand side and offer advice (eg. 'try this on the right-hand side, or do you want to upload the module?') The upload issue is unfortunate - on the USB-based boards there's flow control within the USB com port, so lost characters really aren't a problem. However the Bluetooth LE UART implementation doesn't have any flow control. That's rarely a problem since the transfer rate is pretty slow, but in some cases (which you just hit!) one command will take long enough to execute that it's still enough to cause problems. I'll see if I can get some flow control implemented for the uploads on top of Bluetooth for the next version though, which should avoid issues like this. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-17 by @gfwilliams Just to add - new versions of Espruino do implement |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-17 by Nickax Thanks |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-17 by @allObjects
...oops - or - OOPSLA/ECOOP - SIGPLAN... ok, my favorite is BD or ME... but I'd not like to explain (those or myself). Any language I can express myself in and makes my vis-a-vis to get me, is my favorite (for communication) - and of course, fluency (and walking the mile in my vis-a-vis shoes) is on me. All the rest is the pic(ture) in my head - and (unfortunately), when that pic is messed up, no language ever solved it for me. When it comes to JS, I'm not thinking flow or structured - from flow or structured languages - but OO and Lambda - and that's the (language) pic(k) in my head (hence my screen name). In the end, hybrid is what the world is made of for me - and sometimes a elaborate concepts and their tool are just plain overkill. Under the gun of limited resources - space AND cycles - JS has for me in an optimized way what I need and Espruino HW gets me... most of the time. After all, JS is the language @gfwilliams made for and taught his babies - I don't mean the real one(s)... I have a sone named Pascal, but that did't help much: he skipped that part, which was my 1st love... ;-) I know that green thumbs help with gardening, but I don't what kind of color thumbs help with programming MCs. Something is for sure: when TS will blow my way, I know where and from whom I can get professional help. If you still find some time, take a (reading) look at Man a Machine |
Beta Was this translation helpful? Give feedback.
-
Posted at 2018-07-14 by Nickax
Hi Gordon
I've recently purchased a Pixel JS for a specific project
I'm converting a minibus to a campervan - and want to run (temperature control) the fridge (off a UPS) , Switch the Inverter out as the fridge starts, Run hot and cold water pumps (mix), and pumps to scavenge waste heat from the exhaust to heat water.
I'm not having the greatest user experience with the Pixel .. the latest in a line of frustrations is that it doesn't appear to find any of the 'requred' modules
here's the output - using a one of your simple examples
I haven't updated the firmware - as I hoped that as shipped it might be able to run such a simple example.
I'm sure i'm doing something stupid
I have had the flashing LED example working
I'm using the native IDE on a Windows 10 Machine
My module extensions are set thus:-
Module URL
Where to search online for modules when
require()
is usedhttps://www.espruino.com/modules
Module Extensions
The file extensions to use for each module. These are checked in order and the first that exists is used. One or more file extensions (including the dot) separated by
|
.min.js|.js
Hope you can help put me on track
Nick
Beta Was this translation helpful? Give feedback.
All reactions