Help reading from device in Live mode


Hello makeblock friends,
I need some help for reading data from the device in Extension Builder in LIVE mode.
I’m doing my own device (arduino based) and implemented on it a protocol (similar to FF55 protocol) for communicating with the device. The protocol is tested using a simple Terminal, so it is working Ok.
The block is a Boolean and in this example I try to get data from a Digital Pin.
The code implemented in bock’s Live Mode Handler (onRun) is:
(args, app, device, block) => {
app.log(Get block ${block.opcode} is checked to trigger);

var bytes = [0xaa, 0x55, 4, 0, 1, 30,];   // Make the bytes for get the boolean data
device.writeRaw(bytes);    // Send the bytes

let data = device.readRaw();   // Try to read the response
for (let i = 0; i < data.length; ++i) {
    app.log(`data[${i}]`, datas1[i]);   // Never execute this part


The problem is I never get the response data, even if the Device is sending the data.

Also I put logs in the Extension Handler onRead:
onRead(app, device) {
let data = device.readRaw(false);
app.log(“Reading Byte from device”);
for (let i = 0; i < data.length; ++i) {
app.log(Byte[${i}], datas1[i]);
And I get some response but aldo the “length” of data variable seems to be Zero, because the for loop never execute. This is what I get in the log:
mBlock log: Get block control_if_else is checked to trigger
mblock-mscratch.js?v5.1.5-3:1 mBlock log: Reading Byte from device

Also, I put the blocks I’m using for testing. I noted the flow does not execute correctly when I add my boolean block (get digital pin) in the if-else block. May be this is related to the problem above


Hi, happy new year~
Please receive the data from Extension Event Handler>>>>> onRead, see the picture below:




Hello and happy new year.
I’m currently receiving data in onRead Extension Event Handler. But the data received must go to the onRun block handler, I think…
There isn’t documentation about how the data arriving from the device must be processed to ensure the correct behavior of the block.
For the example I wrote above:

  • I send a command to the device “read digital pin x” in the block’s onRun
  • The device send the response back with the digital pin value
    How to read and pass the value to the block and/or to the app to process the data and the workflow continues ok?
    Can you put an real example of this?

Thank you very much!


Hi ralcoberro,

Thanks for reaching out to us. We’re indeed currently working on providing an example showing how the data receiving and sending in live-mode work. Please be patient, and we will get back to you soon.




Hello Allen!
Thanks for the response. Do you now when you could provide the example, aprox?

Thanks again

Create a simple mblock5 block for mbot

Hi ralcoberro,

Thanks for asking about the progress. In fact, when we’re writing the demo. We realized due to some restriction of our extension builder, we had to resolve some issues first.

To differentiate official developers (our inner developers) and the third-party developers, we adopted some mechanisms to do so and restricted third-party user’s access to some APIs. When we wrote demos recently for you, some issues were revealed. We had to first solve them, otherwise the demo won’t work if you try to follow it.

In fact, at this time the issues have been resolved, but as a company providing stable services, every update has to formally go through testing and then be released in the version bugfix version. However, we don’t have sufficient resources to do it now, the next publish plan for this bug is postponed to February (mBlock Web) and March (mBlock PC). I think we’re possibly able to provide working demo for you around February if you wish to test it only on Web first.

We’re so sorry for this delay, and we have been working on it all the time. Please do understand that we’re focusing on the new incoming release for mBlock PC around January recently, but we will not ignore this important concern and will keep working this then.