You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.
Hi, I was trying to connect a little piece of very common hardware to ScratchX using the serial. I got the "green light" when they connected but they can't communicate since for some reason set_receive_handler never gets called.
Hw/Sw info:
MacOS Sierra 10.12.2
Firefox 50.1.0
The text was updated successfully, but these errors were encountered:
set_receive_handler is something you'll need to call yourself. Conceptually the pattern is:
Your extension's deviceOpened function will be called with the new device.
In deviceOpened you should verify that the device in question is actually a device you're interested in. For example, with the PicoBoard extension we send a request for the PicoBoard to report its sensor values, and if we don't receive sensor values in a reasonable amount of time then we assume that the device must not be a PicoBoard.
Now that you know it's your device, call set_receive_handler with your extension's desired handler.
In reality, you almost certainly need to call set_receive_handler before step 2 so that you can receive the reply, and if you discover it's the wrong device you can set_receive_handler(null) as part of your "cancel" operation. I'd recommend checking out the PicoBoard extension as an example, starting at deviceOpened: https://github.com/LLK/scratchx/blob/gh-pages/scratch_extensions/picoExtension.js
Hi @cwillisf, first of all thanks for your kind reply.
Sorry for expressing the concept so bad: I wanted to say that the callback you pass as an argument in set_receive_handler is never executed.
I knew the Picoboard code: mine is very similar but it is not working for me (moreover: I only have one connection with one device).
What happens:
the device is connected and it regularly prints to the serial (I see it using CoolTerm): I click a physical button and I see it printing to the console;
Hi, I was trying to connect a little piece of very common hardware to ScratchX using the serial. I got the "green light" when they connected but they can't communicate since for some reason
set_receive_handler
never gets called.Hw/Sw info:
MacOS Sierra 10.12.2
Firefox 50.1.0
The text was updated successfully, but these errors were encountered: