New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maker: Prefer Circuit Playground over other serial port devices #13312

Merged
merged 2 commits into from Feb 18, 2017

Conversation

Projects
None yet
2 participants
@islemaster
Member

islemaster commented Feb 17, 2017

@alicesteinglass brought me a teacher's laptop today that was failing to connect to the Circuit Playground board even though all the setup instructions had been followed correctly. This change makes that laptop (and probably many like it) connect successfully.

The first odd thing I noticed on this computer was that the maker setup page reported success for the "Board plugged in" step before I plugged the board in. Turns out it's running something called Intel Active Management Technology which uses a "Serial-Over-Lan (SOL) driver." That driver shows up in the serialport list on the machine, and our site was trying to connect to it, thinking it was the Adafruit board.

multiple_serialports

You can see here that the Adafruit Circuit Playground board is also listed, it's just listed after the SOL port which is why we were missing it. At the bottom of that screenshot you can see the op: "construct", path: "COM3" call that shows we were selecting the wrong port.

The solution is to teach Maker Toolkit to be much smarter about which of the available ports it connects to. Adafruit boards (and most USB devices) report a vendor id (VID) and a product id (PID) to help identify the connected device. We now read these ids on the available ports and pick the best one to connect to, searching in this order.

  1. Look for a port that reports the Adafruit Circuit Playground VID and PID (this is going to be the majority case in schools).
  2. If a Circuit Playground isn't found, look for another device reporting the Adafruit VID - it might be compatible.
  3. If no Adafruit device is found, try a device that as a serialport-like port name and has any valid (nonzero) VID and PID.

These rules should catch not just this case, but probably a lot of cases we don't know about yet where some other software or hardware on the machine would have looked vaguely connectable.

@islemaster islemaster requested review from pcardune and Hamms Feb 17, 2017

@Hamms

Hamms approved these changes Feb 17, 2017

Beautiful test cases!

export const ADAFRUIT_VID = '0x239a';
/** @const {string} The Circuit Playground product id as reported by Circuit playground boards */
export const CIRCUIT_PLAYGROUND_PID = '0x8011';

This comment has been minimized.

@Hamms

Hamms Feb 17, 2017

Contributor

how stable are these? If they were to change, do we have a good way of finding out that they did so?

@Hamms

Hamms Feb 17, 2017

Contributor

how stable are these? If they were to change, do we have a good way of finding out that they did so?

This comment has been minimized.

@islemaster

islemaster Feb 17, 2017

Member

I gather (here, here, here, here) that these IDs are broadly considered stable and are the standard way to identify a USB device and look up drivers. It sounds like the Adafruit vendor id was purchased/reserved by them from the USB developers group and that they guarantee product id to be unique within their vendor id.

These IDs are kept in this configuration file in this repo to make them available to the Arduino IDE, and while I'm not sure this is good evidence there is very low churn on that file.

More generally, I think my next change should introduce some metrics around connected boards. I want to have the maker setup page survey automatically include information about the chosen serialport in cases where we report "Board Plugged In" but not "Board Connectable" to catch conflicts like this in the future, and it'd be interesting to anonymously report port info for successfully connected boards out to GA or someplace.

@islemaster

islemaster Feb 17, 2017

Member

I gather (here, here, here, here) that these IDs are broadly considered stable and are the standard way to identify a USB device and look up drivers. It sounds like the Adafruit vendor id was purchased/reserved by them from the USB developers group and that they guarantee product id to be unique within their vendor id.

These IDs are kept in this configuration file in this repo to make them available to the Arduino IDE, and while I'm not sure this is good evidence there is very low churn on that file.

More generally, I think my next change should introduce some metrics around connected boards. I want to have the maker setup page survey automatically include information about the chosen serialport in cases where we report "Board Plugged In" but not "Board Connectable" to catch conflicts like this in the future, and it'd be interesting to anonymously report port info for successfully connected boards out to GA or someplace.

pnpId: "",
locationId: "",
vendorId: "0x239a",
productId: "0x8011"

This comment has been minimized.

@Hamms

Hamms Feb 17, 2017

Contributor

is there a reason these aren't using the constants from BoardController.js?

@Hamms

Hamms Feb 17, 2017

Contributor

is there a reason these aren't using the constants from BoardController.js?

This comment has been minimized.

@islemaster

islemaster Feb 17, 2017

Member

I was torn about this; on the one hand, this file is sort of a clean, dependencyless fixture and I didn't want to mess with that. In fact, I wonder if this should somehow be converted to json to show that it's purely data. On the other hand, DRY...

@islemaster

islemaster Feb 17, 2017

Member

I was torn about this; on the one hand, this file is sort of a clean, dependencyless fixture and I didn't want to mess with that. In fact, I wonder if this should somehow be converted to json to show that it's purely data. On the other hand, DRY...

@islemaster islemaster merged commit 195005b into staging Feb 18, 2017

2 checks passed

ci/circleci Your tests passed on CircleCI!
Details
hound No violations found. Woof!

@islemaster islemaster deleted the maker-picky-port-picker branch Feb 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment