I need to compile generated source code in js runtime then upload it to my device.
Compiling:
I have found arduino-cli
Uploading:
There is only avrgirl but it doesn't work in browser. What should I do?
-
Arduinos cannot be programmend in Nodejs. You need to write C/C++ or Assembler.chrisl– chrisl2019年12月08日 15:18:25 +00:00Commented Dec 8, 2019 at 15:18
-
@chrisl, it's not about programming (code is c-generated one) it's about calling compiler from jscaxapexac– caxapexac2019年12月08日 15:40:30 +00:00Commented Dec 8, 2019 at 15:40
-
1Ah, ok. But you can also upload sketches with arduino-cli. If you can use it, you can also upload sketcheschrisl– chrisl2019年12月08日 16:14:49 +00:00Commented Dec 8, 2019 at 16:14
1 Answer 1
You can't, and that's a good thing. If the browser could let a Web site access your hardware, that would be a huge security breach. You may be able to bypass this security restriction if you can write an extension (plugin) for your browser.
-
Okay then I will use extension for hex code uploading. Then how can I compile it using only in-browser js?caxapexac– caxapexac2019年12月08日 17:15:17 +00:00Commented Dec 8, 2019 at 17:15
-
I mean: source code -> String -> Compiler -> Hex-string -> Extension -> Uploadingcaxapexac– caxapexac2019年12月08日 17:16:38 +00:00Commented Dec 8, 2019 at 17:16
-
@caxapexac: Building a C++ compiler in JavaScript is not a trivial task. You may try to port avr-g++ using Emscripten.Edgar Bonet– Edgar Bonet2019年12月08日 17:42:40 +00:00Commented Dec 8, 2019 at 17:42
-
Seems for me a weird way to do everything in the browser. Normally in such a situation you are actually building a web service, so the compilation could be done server side by calling avr-g++ or arduino-cli through the nodejs code. Then you only would need to encapsule arduino-cli in an extention for uploading on the local computerchrisl– chrisl2019年12月08日 20:37:22 +00:00Commented Dec 8, 2019 at 20:37
-
I modify the code from js-stk500 to work from browser with web serial API. but I can't makr Arduino CLI to work in browser. Is that possible?M lab– M lab2022年11月22日 09:17:38 +00:00Commented Nov 22, 2022 at 9:17
Explore related questions
See similar questions with these tags.