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?

caxapexac
  • 111
  • 4

1 Answers1

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.

Edgar Bonet
  • 39,449
  • 4
  • 36
  • 72
  • Okay then I will use extension for hex code uploading. Then how can I compile it using only in-browser js? – caxapexac Dec 08 '19 at 17:15
  • I mean: source code -> String -> Compiler -> Hex-string -> Extension -> Uploading – caxapexac Dec 08 '19 at 17:16
  • @caxapexac: Building a C++ compiler in JavaScript is not a trivial task. You may try to port avr-g++ using [Emscripten](https://emscripten.org/). – Edgar Bonet Dec 08 '19 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 – chrisl Dec 08 '19 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 Nov 22 '22 at 09:17