Downloading code to Espruino without WebIDE #5145
Replies: 1 comment
-
Posted at 2015-11-13 by DrAzzy Press the up arrow from left side of ide after uploading ;) that'll show you what's been sent over. Compiled code gets compiled broke sending. Modules required get fetched and sent over with a call to add to cache. I think Gordon mentioned a command-line tool a while back... Posted at 2015-11-13 by @allObjects @dennis, who would trigger your task runner? a) - grunt live --xyz.. based on changes? JS = as far as for me - is a more interactive / instant thing... With JS taking on like crazy as THE client side platform, all the heavy-build version came into place again... In the browser world, I see no issues with it to use the built technology to create dedicated, performing chunks of code if the development process still can work directly based on the fine granular source. The browser has perfect cache to handle that (...sure, it will load comments as well and parse takes longer... but I still prefere it over builds...) In Espruino / IoT world, the uplaod does already a lot of crunching so only the minimum of code is uploaded... and compared to the amount of 'code' a large, comple (single page) Web app does, it is peanuts,... penny to the dollars. A build system that can create (and conserve) the context of modules and applications available through the IDE - settings - project - sandbox folder could though be helpful... The IDE could leave traces about what file is loaded and the build system could create trigger info for the IDE to inform it - and to user - about the new version to upload or - configurable - just do it - and configurable - also even save / start the app. I'd prefere to have the IDE as the link, because it allows to separate the dev/build space from the execution/monitoring space. The IDE is a JS thing and can 'easily' be modified. May be this view is a bit limiting, but I could see it as good start. Posted at 2015-11-13 by Dennis @drazzy: Thank you! Aha, simple trick but works :) So it appears it's sending
Looking back with the up-arrow shows the code from the editor not in one chunk but in several chunks, where each function or each top-level line of code is one chunk... but it seems there's nothing special about sending code that way, it seems to be only related to retrieving code from the command history with the up-arrow. How do I know? Well, if I copy a js file to the espruino tty device, it's certainly sent in one chunk but yet it also appears as several chunks in the command history. So... how should I parse code for Posted at 2015-11-13 by DrAzzy I don't know the state of the commandline tools - I think in terms of making Espruino a "real platform", though, we do need a commandline tool that will do what the IDE does, in terms of converting requires to modules and compiling functions with the "compiled"; keyword, and running it through a minifier... Posted at 2015-11-13 by Dennis @allObjects: you have quite a few good ideas there. I like the idea of having a flexible build system that works tightly integrated with the IDE. The main reason why I don't want to use the IDE this time is that I want to code in CoffeeScript and I cannot do that in the IDE because its syntax highlighting is for JavaScript and the IDE also does not support pre-processing. Posted at 2015-11-14 by the1laz I think this is what you want: https://github.com/espruino/espruino-tools It seems to work well. It handles module loading off the espruino website, but if you have local modules it won't add them for you. If you can get something to bundle your code into one file (like browserify does), then use espruino-tools to send it across, you should be set. Posted at 2015-11-14 by Dennis @the1laz: Yes!!! This is exactly what I need! But it won't run :( After I fixed a few bugs in the code that caused it to crash, espruinotool now at least reports an error that the port was not found. I called Posted at 2015-11-14 by Dennis I fixed another bug (see github discussion with @gfwilliams about my changes) and now finally I'm talking to Espruino. But for some reason I'm not getting the correct return values and console output from Espruino. I have a file
Now when I call espruino tool, I get the following:
I expected it to return 123 for the first statement, then write 124 to the console and then return undefined for the second statement. The console output is nowhere to be found and undefined is not the correct result. But if I now use WebIDE, I can verify that a really has the value 123, so the code has been executed. Posted at 2015-11-14 by @allObjects @dennis, I see where you're going... and it will provide all the means to make the code robust: TDD / XP. For certain things I started to develop in a browser environment - next would be adding node.js - where all the whistles and bells can be applied EEPROM/MRAM/FRAM related memory manager with garbage collect. html file linked/uploaded in the post can be run directly in the browser with regression test visualization (see attached screen shot). Some of the code is already structured towards port to Espruino HW. To complte the story a core is piece missing: Espruiono Standard/Pico emulator... may be at one time it will be there. Until then a smart layering to separate 'logiciel' from 'meteriel' - SW from HW - can help to test with great coverage. There is some memory price to pay for layering, but as long the few bytes are available, it may well be worth. Additional optimization can always be built into the build and deploy steps. Attachments: Posted at 2015-11-16 by @gfwilliams Hi - I'll take a look at it now and will try and see why it's not printing. Sorry about all the issues - I'm not sure how that got so broken... I think I probably only tested it very roughly when I changed the Serial API, and didn't try explicitly specifying a port. Posted at 2015-11-16 by Dennis Cool, thanks :) I suppose the reason is that the WebIDE and the command-line tool share common code but they use it in different ways, and when the WebIDE was improved, this common code was changed in a way that breaks only the command-line tool but works for the WebIDE. Posted at 2015-11-16 by @gfwilliams Ok, I think I've fixed it now:
Seems strange - looks like the code that listened for the return value expected a String, when it was getting an ArrayBuffer. Not sure how that ever worked at all really. If you update from GitHub now, it should be better? Posted at 2015-11-16 by Dennis I will try it! By the way, I see you are communicating over a tty device. I noticed that on my Mac, the tool recognizes only the cu ports but not the corresponding tty ports. The cu ports work, but I cannot have another terminal program connected and reading at the same time because access is exclusive. Posted at 2015-11-16 by @gfwilliams Ahh, interesting - I thought it was the opposite (that I'm actually working on Linux, where there don't seem to be |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2015-11-13 by Dennis
What exactly does the WebIDE do when the button "send to Espruino" is pressed? Especially, how does it handle
and what does it send over the serial interface?
The reason for my question is that I would like to use a task runner (such as grunt) to generate JavaScript from other stuff and deploy it to Espruino, since it would be bothersome to always copy and paste the result into the WebIDE. I basically need a command-line version of the send-to-Espruino button... what would it have to do?
Beta Was this translation helpful? Give feedback.
All reactions