1

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?

asked Dec 8, 2019 at 14:56
3
  • Arduinos cannot be programmend in Nodejs. You need to write C/C++ or Assembler. Commented Dec 8, 2019 at 15:18
  • @chrisl, it's not about programming (code is c-generated one) it's about calling compiler from js Commented Dec 8, 2019 at 15:40
  • 1
    Ah, ok. But you can also upload sketches with arduino-cli. If you can use it, you can also upload sketches Commented Dec 8, 2019 at 16:14

1 Answer 1

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.

answered Dec 8, 2019 at 17:06
5
  • Okay then I will use extension for hex code uploading. Then how can I compile it using only in-browser js? Commented Dec 8, 2019 at 17:15
  • I mean: source code -> String -> Compiler -> Hex-string -> Extension -> Uploading Commented 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. Commented 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 computer Commented 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? Commented Nov 22, 2022 at 9:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.