Can the Firmata protocol be implemented in MicroBlocks VM?

Issue #492 resolved
Sean shao created an issue

Can the Firmata protocol be implemented in MicroBlocks VM?
This would make it easier for existing systems and libraries that support Firmata to communicate directly with MicroBlocks VM.

Any suggestions?

Comments (5)

  1. John Maloney repo owner

    The MicroBlocks IDE communicates with the board using a protocol that is quite different from Firmata. Since the two protocols are incompatible, it's not possible to use both of them over the same USB-serial connection.

    Could you say more about what you have in mind? Which existing systems and libraries are you interested in?

    It is definitely possible to create MicroBlocks programs that allow a board to be used as a peripheral for a program such as Snap! running on a laptop or desktop computer. One example is the "Signata" progam in the Examples /Network folder.

    Here are some Wiki articles about ways to interact between MicroBlocks and programs running on other computers:

    https://wiki.microblocks.fun/en/snap

    While these articles focus on Snap!, the techniques could be applied to other programming systems.

  2. Sean shao reporter

    Thanks for your reply.

    Some scenarios that can be thought of:
    Getting sensor data from an Arduino device via the firmata protocol.
    Integration with platforms like blokdots or proto-pie.
    Support for js libraries like johnny-five to interact with VMs.

  3. John Maloney repo owner

    Getting sensor data from an Arduino device via the firmata protocol.

    For this, the board would be acting as the controller for the Arduino. It would send commands to Firmata to control the board.

    In the other two scenarios, MicroBlocks would b acting as a Firmata-based peripheral.

    For both of these cases, the most flexible approach is to implement the Firmata protocol as a MicroBlocks library. The Firmata protocol is actually pretty simple. It is a variation of MIDI, where messages consist of a command byte with a one in the high-order bit followed by some number data bytes with a zero in their high order bit. This design makes it very easy to detect the start of a message in the byte stream and it is also very easy to skip messages that are not implemented. See:

    https://github.com/firmata/protocol

    for further details.

    In other words, you don't need to implement Firmata into the virtual machine, you can implement it entirely in MicroBlocks.

  4. Log in to comment