Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Firefox, MacOS, the serial #106

Closed
githubhero opened this issue Jan 4, 2017 · 3 comments
Closed

Firefox, MacOS, the serial #106

githubhero opened this issue Jan 4, 2017 · 3 comments
Labels
Milestone

Comments

@githubhero
Copy link

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

@cwillisf
Copy link
Contributor

cwillisf commented Jan 5, 2017

set_receive_handler is something you'll need to call yourself. Conceptually the pattern is:

  1. Your extension's deviceOpened function will be called with the new device.
  2. 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.
  3. 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

@githubhero
Copy link
Author

githubhero commented Jan 6, 2017

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;

  • the device apparently gets connected to ScratchX (green color):
    Object { id: "/dev/tty.usbmodem1432", open: SerialDevice/this.open(), close: SerialDevice/this.close(), send: SerialDevice/this.send(), set_receive_handler: SerialDevice/this.set_receive_handler() }

  • ScratchX is not printing/sending/writing to the serial;

  • ScratchX is not receiving anything (I'm supposing I can catch something coming from the serial via set_receive_handler);

  • _deviceRemoved never fires;

@thisandagain thisandagain added this to the Backlog milestone Jan 10, 2017
@jerryyip
Copy link

I have the same problem here. What should I do now? @thisandagain @cwillisf

@colbygk colbygk closed this as completed Apr 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

5 participants