Problem receiving data in Live Mode


#1

Hello all,
I’m developing a Device with Live Mode in Extension Builder. I want communicate the Device with a hardware based on Arduino Uno.
For testing the communication, I wrote a firmware that answer a string “HelloMblock” every time I send a commmand to the hardware in a block.
Every time the board send back the response, I get a “onRead(app, device)” callback call (OK) but I can read the data Ok with “device.readText()” just the first time. I can’t get the data the sucesives reads, even if the onRead callback is called. The second call and sucesives the variable “text” (see below) is empty.
Here is the onRead callback code:

// when receiving and reading byte
async onRead(app, device) {
device.setTextDecoder(‘utf8’);
let text = await device.readText();
app.log('Received from dev: ', text);
}

Note I needed to add the “async” definition to the callback to get any data. It doesn’t work without this.
I tried with readHex() but is the same, just receive the first time I send the commnad.
This is the complete console output, it shows when the callback is executed:

I checked the hardware with a serial terminal and It always sends a response.

I need to do something else to continuing receiveing data?

Thank you very much
Regards
Rodrigo


#2

Hi ralcoberro,
That is the permission issue.
We can’t open the permission for live mode.
Hope you can understand.


#3

Is it possible right now?
Can I use readHex more than once in a new device in live mode?

Thanks, regards.


#4

I think that mBlock online has a “sandbox”

Definition

(a sandbox is a code environment that only allows specific codes to run for safety reasons. Since your extension could be malicious, it is “unsandboxed” after it is reviewed by makeblock to ensure it is safe and publishable)

.
After the extension is published, it may work because it is no longer sandboxed in preview mode.


#5

It is not working on desktop app, too…


#6

I thought you said it was??? And is it published yet?


#7

I am now making tests so I can decide if I can go on with this device/extension. May I publish it anyway? it is incomplete.

I’ve tried in desktop app and web mode, and I only can get the first bytes received and no more.


#8

You can probably publish it. Just make sure words like “test” aren’t included, or they may reject it. :slight_smile:


#9

@Best_codes I’ve published and download the published version, but unfortunately it is the same behaviour. I’ve read above that it was a permissions issue in live mode. Is it resolved?


#10

You published it?
1:
image

2:
image

3:
image


#11

Yes, it is a device.


#12

It says “in review?”
Sorry, I have to go now.


#13

In my opinion the situation is clear enough. Technical support replied that the live mode is specifically blocked for non-original devices. A separate question is how to bypass this blocking. But is it worth trying? Live mode in mBlock5 works very badly. It is much more efficient for such tasks to use the Snap4arduino environment with a modified Firmata firmware.