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