Using xod/your arduino-cli wrapper for another project


#1

Hello again,

In parallel to XOD experiments, I’m working on helping another arduino ide project using blockly. We’d like to make an electron client and use the same arduino-cli like you did in xod. We already have a perfectly working static html-js page that generates arduino code.

  • do you think we could use xod as a base for that work?
  • how could we proceed?

Background info : I know extensively the laravel framework (php), quite a bit of javascript, concepts of nodejs, git workflows, arduino (obviously :slight_smile: ) - so as you can see I don’t know it all super-well

Thanks!


#2

Hello, @philippejadin!
Here you are: https://www.npmjs.com/package/arduino-cli
Feel free to contribute :slight_smile:


#3

That was fast :slight_smile: Thank you! Will report and contribute if I can

Any recommendation on where to put the arduino-cli binary in the context of an electron app ? (A link to a tutorial would do :slight_smile: )


#4

Really, you can place it anywhere you want :slight_smile:

We place it into Resources folder using extraResources property in package.json
However, for different OS we’re downloading and unpacking different executables, so there are no arduino-cli in our repo at all. Check out this files:

Good luck with your project!


#5

Oh my, so many things to learn still !

Did you see that : https://blog.travis-ci.com/2018-10-11-windows-early-release


#6

One last I hope. As I understand, the import syntax is newer javascript not yet natively supported by nodejs. HOw do you handle this?

The only way I made it work is this :

var arduino_cli = require('arduino-cli');




const cli = arduino_cli.default('./arduino-cli', {
  arduino_data: '~/arduino-cli/data',
  sketchbook_path: '~/arduino-cli/sketches',
});

cli.core.updateIndex().then(console.log('succeeded'));

Note the use of .default which looks strange to me.

Thank again!


#7

We’re using babel.
And compose bundles for client-side using webpack.

Also you can extract default right in place of requiring it:

var arduino_cli = require('arduino-cli').default;

#8

I’m progressing well thanks to your package. I hope it’s the right place to discuss this, tell me if not.

I’d like to be able to instantiate the arduino-cli wrapper without defining data and sketch pathes, in order to use the built-in defaults (those are the same as the arduino ide as far as I can tell). This is actually a nice feature in the arduino-cli binary because this way you share the sketches and the libs and board installed with the ide. It makes a lot of sense for our project, since it’s an introduction to real coding, (you start with visual coding -> then arduino ide later, where you find all the libs, boards, and sketches already there)

Would this be possible with arduino-cli wrapper?