-
Notifications
You must be signed in to change notification settings - Fork 68
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
Port List could display product name #34
Comments
Here's an updated version. I suggest putting the PID/VID array in its own document, but I don't know how you'd like to organize things. Also, I recommend listing manufacturer name when you list, so that if the device type isn't in this array, at least the user can know the vendor and guess at the device from there. There's probably a way to pull product name using the PID from USB.org, but I don't know how.
|
from @tigoe
Attached is a kluge for getting port's board name.
A real version could look for the user’s ~/Library/Arduino15/packages, and in each package folder keep looking for boards.txt files, and take any line with .pid in it and pull the pid for comparison.
But this will get the names for now.
ListPorts.js
/*
Lists serial ports.
Copied from https://github.com/voodootikigod/node-serialport readme
refactored to get rid of anonymous functions, to make it clearer for
those new to JavaScript
*/
var pids = [{productName : 'Yún', productId : 0x0041},
{productName : 'Yún', productId : 0x8041},
{productName : 'Yún', productId : 0x0041},
{productName : 'Yún', productId : 0x8041},
{productName : 'Uno', productId : 0x0043},
{productName : 'Uno', productId : 0x0001},
{productName : 'Uno', productId : 0x0043},
{productName : 'Uno', productId : 0x0243},
{productName : 'Mega', productId : 0x0010},
{productName : 'Mega', productId : 0x0042},
{productName : 'Mega', productId : 0x0010},
{productName : 'Mega', productId : 0x0042},
{productName : 'Mega', productId : 0x0210},
{productName : 'Mega', productId : 0x0242},
{productName : 'Mega ADK', productId : 0x003f},
{productName : 'Mega ADK', productId : 0x0044},
{productName : 'Mega ADK', productId : 0x003f},
{productName : 'Mega ADK', productId : 0x0044},
{productName : 'Leonardo', productId : 0x0036},
{productName : 'Leonardo', productId : 0x8036},
{productName : 'Leonardo', productId : 0x0036},
{productName : 'Leonardo', productId : 0x8036},
{productName : 'Micro', productId : 0x0037},
{productName : 'Micro', productId : 0x8037},
{productName : 'Micro', productId : 0x0037},
{productName : 'Micro', productId : 0x8037},
{productName : 'Micro', productId : 0x0237},
{productName : 'Micro', productId : 0x8237},
{productName : 'Esplora', productId : 0x003C},
{productName : 'Esplora', productId : 0x803C},
{productName : 'Esplora', productId : 0x003C},
{productName : 'Esplora', productId : 0x803C},
{productName : 'LilyPad USB', productId : 0x9207},
{productName : 'LilyPad USB', productId : 0x9208},
{productName : 'Robot Control Board', productId : 0x0038},
{productName : 'Robot Control Board', productId : 0x8038},
{productName : 'Robot Control Board', productId : 0x0038},
{productName : 'Robot Control Board', productId : 0x8038},
{productName : 'Robot Motor Board', productId : 0x0039},
{productName : 'Robot Motor Board', productId : 0x8039},
{productName : 'Robot Motor Board', productId : 0x0039},
{productName : 'Robot Motor Board', productId : 0x8039},
{productName : 'Gemma', productId : 0x0c9f},
{productName : 'Arduino Zero (Programming Port)', productId : 0x2157},
{productName : 'Arduino Zero native', productId : 0x804d},
{productName : 'Arduino Zero native', productId : 0x004d},
{productName : 'Arduino Zero native', productId : 0x824d},
{productName : 'Arduino Zero native', productId : 0x024d},
{productName : 'MKR1000', productId : 0x804e},
{productName : 'MKR1000', productId : 0x004e},
{productName : 'MKR1000', productId : 0x824e},
{productName : 'MKR1000', productId : 0x024e},
{productName : 'Arduino 101', productId : 0x0AB6},
{productName : 'Flora8', productId : 0x8004},
{productName : 'Bluefruit Micro', productId : 0x800A},
{productName : 'Feather 32u4', productId : 0x800C},
{productName : 'Adafruit 32u4', productId : 0x8001},
{productName : 'Circuit Playground 32u4 cat', productId : 0x8011},
{productName : 'Adafruit feather M0', productId : 0x800B},
{productName : 'Adafruit feather M0', productId : 0x000B},
{productName : '#Adafruit radio M0', productId : 0x8014},
{productName : '#Adafruit radio M0', productId : 0x0014},
{productName : '#Adafruit metro M0', productId : 0x8013},
{productName : '#Adafruit metro M0', productId : 0x0013},
{productName : 'Blend', productId : 0x0036},
{productName : 'Blend', productId : 0x8036},
{productName : 'Blend Micro 8', productId : 0x2404},
{productName : 'Blend Micro 16', productId : 0x2404}];
var serialport = require("serialport");
var myName = "unknown";
// list serial ports:
serialport.list(listPorts);
function listPorts(error, ports) {
ports.forEach(printPort);
}
The text was updated successfully, but these errors were encountered: