austinbv/dino

Question: Can I Burn the Ruby Script to Arduino Device?

Closed this issue · 1 comments

How can I burn my ruby script to the device so it will run automatically the next time it is powered up (not connected to my computer).

I think normally an arduino will start executing the last sketch that was 'uploaded' to it when it is powered on. When I use dino to write my sketches in ruby, it doesn't really seem to do anything. Is there a way to do this in ruby or is it a limitation of this approach?

No. This gem isn't about transcompiling Ruby code to Arduino code. All the included Arduino bootstrapper does is provide an API for calling low-level Arduino functions and libraries over a serial connection. The Ruby gem wraps this API and adds logic for common components. All your program logic is in Ruby and needs the board to be connected.

The bootstrapper is written as an Arduino library, so what you're asking might be possible. Try this:

  • Right now the library only reads one character at a time and has an internal buffer. It only does anything when a whole command is in the buffer. Add a function to let it accept an entire API command at once and process it immediately.
  • Transcompile your Ruby script into a combination of Arduino C (for control flow), and API calls to the above function (the actual IO).
  • Drop that into the existing loop function of the bootstrapper, after everything that's already there.

In theory, that will give you a board with the standalone functionality you transcompiled and burnt onto it, while still being able to control it over serial with the dino API. Replacing everything in loop will let you disable external control.

Check out rad for Ruby -> Arduino transcompiling: https://github.com/atduskgreg/rad