diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 8a989c2d8..86461b917 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -21,6 +21,13 @@ jobs:
steps:
- uses: actions/checkout@v2
+ - name: Install Linux dependencies
+ if: matrix.os == 'ubuntu-18.04'
+ run: |
+ sudo apt-get update
+ sudo apt-get install g++-multilib
+ sudo apt-get install -y build-essential
+ sudo apt-get install libudev-dev
- name: Use Node.js ${{ matrix.node-version }} and install npm dependencies
uses: actions/setup-node@v1
with:
diff --git a/README.md b/README.md
index ed61f31e8..6574b81dd 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Device Simulator Express, a Microsoft Garage project
-
+
diff --git a/locales/en/out/constants.i18n.json b/locales/en/out/constants.i18n.json
index d6c6c548a..461de0056 100644
--- a/locales/en/out/constants.i18n.json
+++ b/locales/en/out/constants.i18n.json
@@ -2,6 +2,7 @@
"dialogResponses.agreeAndRun": "Agree and Run",
"dialogResponses.acceptPrivacy": "Got it",
"dialogResponses.cancel": "Cancel",
+ "dialogResponses.select": "Select",
"dialogResponses.dontShowAgain": "Don't Show Again",
"dialogResponses.exampleCode": "Example Code on GitHub",
"dialogResponses.help": "I need help",
diff --git a/package-lock.json b/package-lock.json
index 9cf9feee9..6f3c6e09b 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -5019,6 +5019,77 @@
"integrity": "sha512-shAmDyaQC4H92APFoIaVDHCx5bStIocgvbwQyxPRrbUY20V1EYTbSDchWbuwlMG3V17cprZhA6+78JfB+3DTPw==",
"dev": true
},
+ "@serialport/binding-abstract": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/binding-abstract/-/binding-abstract-8.0.6.tgz",
+ "integrity": "sha512-1swwUVoRyQ9ubxrkJ8JPppykohUpTAP4jkGr36e9NjbVocSPfqeX6tFZFwl/IdUlwJwxGdbKDqq7FvXniCQUMw==",
+ "requires": {
+ "debug": "^4.1.1"
+ }
+ },
+ "@serialport/binding-mock": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/binding-mock/-/binding-mock-8.0.6.tgz",
+ "integrity": "sha512-BIbY5/PsDDo0QWDNCCxDgpowAdks+aZR8BOsEtK2GoASTTcJCy1fBwPIfH870o7rnbH901wY3C+yuTfdOvSO9A==",
+ "requires": {
+ "@serialport/binding-abstract": "^8.0.6",
+ "debug": "^4.1.1"
+ }
+ },
+ "@serialport/bindings": {
+ "version": "8.0.7",
+ "resolved": "https://registry.npmjs.org/@serialport/bindings/-/bindings-8.0.7.tgz",
+ "integrity": "sha512-IqudDL8ne2Y2S0W5fKA6wdgHCIA2e2OIaPVYhGy6duE6legNHFY+05CLicHAyAeTocXmHU7rVNxzVQrOG5tM4g==",
+ "requires": {
+ "@serialport/binding-abstract": "^8.0.6",
+ "@serialport/parser-readline": "^8.0.6",
+ "bindings": "^1.5.0",
+ "debug": "^4.1.1",
+ "nan": "^2.14.0",
+ "prebuild-install": "^5.3.0"
+ }
+ },
+ "@serialport/parser-byte-length": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/parser-byte-length/-/parser-byte-length-8.0.6.tgz",
+ "integrity": "sha512-92mrFxFEvq3gRvSM7ANK/jfbmHslz91a5oYJy/nbSn4H/MCRXjxR2YOkQgVXuN+zLt+iyDoW3pcOP4Sc1nWdqQ=="
+ },
+ "@serialport/parser-cctalk": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/parser-cctalk/-/parser-cctalk-8.0.6.tgz",
+ "integrity": "sha512-pqtCYQPgxnxHygiXUPCfgX7sEx+fdR/ObjpscidynEULUq2fFrC5kBkrxRbTfHRtTaU2ii9DyjFq0JVRCbhI0Q=="
+ },
+ "@serialport/parser-delimiter": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/parser-delimiter/-/parser-delimiter-8.0.6.tgz",
+ "integrity": "sha512-ogKOcPisPMlVtirkuDu3SFTF0+xT0ijxoH7XjpZiYL41EVi367MwuCnEmXG+dEKKnF0j9EPqOyD2LGSJxaFmhQ=="
+ },
+ "@serialport/parser-readline": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/parser-readline/-/parser-readline-8.0.6.tgz",
+ "integrity": "sha512-OYBT2mpczh9QUI3MTw8j0A0tIlPVjpVipvuVnjRkYwxrxPeq04RaLFhaDpuRzua5rTKMt89c1y3btYeoDXMjAA==",
+ "requires": {
+ "@serialport/parser-delimiter": "^8.0.6"
+ }
+ },
+ "@serialport/parser-ready": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/parser-ready/-/parser-ready-8.0.6.tgz",
+ "integrity": "sha512-xcEqv4rc119WR5JzAuu8UeJOlAwET2PTdNb6aIrrLlmTxhvuBbuRFcsnF3BpH9jUL30Kh7a6QiNXIwVG+WR/1Q=="
+ },
+ "@serialport/parser-regex": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/parser-regex/-/parser-regex-8.0.6.tgz",
+ "integrity": "sha512-J8KY75Azz5ZyExmyM5YfUxbXOWBkZCytKgCCmZ966ttwZS0bUZOuoCaZj2Zp4VILJAiLuxHoqc0foi67Fri5+g=="
+ },
+ "@serialport/stream": {
+ "version": "8.0.6",
+ "resolved": "https://registry.npmjs.org/@serialport/stream/-/stream-8.0.6.tgz",
+ "integrity": "sha512-ym1PwM0rwLrj90vRBB66I1hwMXbuMw9wGTxqns75U3N/tuNFOH85mxXaYVF2TpI66aM849NoI1jMm50fl9equg==",
+ "requires": {
+ "debug": "^4.1.1"
+ }
+ },
"@sheerun/mutationobserver-shim": {
"version": "0.3.2",
"resolved": "https://registry.npmjs.org/@sheerun/mutationobserver-shim/-/mutationobserver-shim-0.3.2.tgz",
@@ -6532,8 +6603,7 @@
"aproba": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz",
- "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==",
- "dev": true
+ "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw=="
},
"archy": {
"version": "1.0.0",
@@ -6541,6 +6611,15 @@
"integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=",
"dev": true
},
+ "are-we-there-yet": {
+ "version": "1.1.5",
+ "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz",
+ "integrity": "sha512-5hYdAkZlcG8tOLujVDTgCT+uPX0VnpAH28gWsLfzpXYm7wP6mp5Q/gYyR7YQ0cKVJcXJnl3j2kpBan13PtQf6w==",
+ "requires": {
+ "delegates": "^1.0.0",
+ "readable-stream": "^2.0.6"
+ }
+ },
"argparse": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
@@ -8108,8 +8187,7 @@
"base64-js": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
- "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw==",
- "dev": true
+ "integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw=="
},
"base64id": {
"version": "1.0.0",
@@ -8154,12 +8232,46 @@
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
- "dev": true,
- "optional": true,
"requires": {
"file-uri-to-path": "1.0.0"
}
},
+ "bl": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/bl/-/bl-4.0.2.tgz",
+ "integrity": "sha512-j4OH8f6Qg2bGuWfRiltT2HYGx0e1QcBTrK9KAHNMwMZdQnDZFk0ZSYIpADjYCB3U12nicC5tVJwSIhwOWjb4RQ==",
+ "requires": {
+ "buffer": "^5.5.0",
+ "inherits": "^2.0.4",
+ "readable-stream": "^3.4.0"
+ },
+ "dependencies": {
+ "buffer": {
+ "version": "5.5.0",
+ "resolved": "https://registry.npmjs.org/buffer/-/buffer-5.5.0.tgz",
+ "integrity": "sha512-9FTEDjLjwoAkEwyMGDjYJQN2gfRgOKBKRfiglhvibGbpeeU/pQn1bJxQqm32OD/AIeEuHxU9roxXxg34Byp/Ww==",
+ "requires": {
+ "base64-js": "^1.0.2",
+ "ieee754": "^1.1.4"
+ }
+ },
+ "inherits": {
+ "version": "2.0.4",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
+ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ=="
+ },
+ "readable-stream": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+ "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+ "requires": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ }
+ }
+ }
+ },
"blob": {
"version": "0.0.5",
"resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
@@ -8743,8 +8855,7 @@
"chownr": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/chownr/-/chownr-1.1.1.tgz",
- "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g==",
- "dev": true
+ "integrity": "sha512-j38EvO5+LHX84jlo6h4UzmOwi0UgW61WRyPtJz4qaadK5eY3BTS5TY/S1Stc3Uk2lIM6TPevAlULiEJwie860g=="
},
"chrome-trace-event": {
"version": "1.0.2",
@@ -8941,8 +9052,7 @@
"code-point-at": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz",
- "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c=",
- "dev": true
+ "integrity": "sha1-DQcLTQQ6W+ozovGkDi7bPZpMz3c="
},
"collect-v8-coverage": {
"version": "1.0.0",
@@ -9159,6 +9269,11 @@
"date-now": "^0.1.4"
}
},
+ "console-control-strings": {
+ "version": "1.1.0",
+ "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz",
+ "integrity": "sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4="
+ },
"constants-browserify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/constants-browserify/-/constants-browserify-1.0.0.tgz",
@@ -10141,6 +10256,14 @@
"resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz",
"integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU="
},
+ "decompress-response": {
+ "version": "4.2.1",
+ "resolved": "https://registry.npmjs.org/decompress-response/-/decompress-response-4.2.1.tgz",
+ "integrity": "sha512-jOSne2qbyE+/r8G1VU+G/82LBs2Fs4LAsTiLSHOCOMZQl2OKZ6i8i4IyHemTe+/yIXOtTcRQMzPcgyhoFlqPkw==",
+ "requires": {
+ "mimic-response": "^2.0.0"
+ }
+ },
"deep-equal": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/deep-equal/-/deep-equal-1.1.1.tgz",
@@ -10155,6 +10278,11 @@
"regexp.prototype.flags": "^1.2.0"
}
},
+ "deep-extend": {
+ "version": "0.6.0",
+ "resolved": "https://registry.npmjs.org/deep-extend/-/deep-extend-0.6.0.tgz",
+ "integrity": "sha512-LOHxIOaPYdHlJRtCQfDIVZtfw/ufM8+rVj649RIHzcm/vGwQRXFt6OPqIFWsm2XEMrNIEtWR64sY1LEKD2vAOA=="
+ },
"deep-is": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz",
@@ -10301,6 +10429,11 @@
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
+ "delegates": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz",
+ "integrity": "sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o="
+ },
"denodeify": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/denodeify/-/denodeify-1.2.1.tgz",
@@ -10335,6 +10468,11 @@
"integrity": "sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=",
"dev": true
},
+ "detect-libc": {
+ "version": "1.0.3",
+ "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-1.0.3.tgz",
+ "integrity": "sha1-+hN8S9aY7fVc1c0CrFWfkaTEups="
+ },
"detect-newline": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-2.1.0.tgz",
@@ -11717,6 +11855,11 @@
}
}
},
+ "expand-template": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/expand-template/-/expand-template-2.0.3.tgz",
+ "integrity": "sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg=="
+ },
"expand-tilde": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/expand-tilde/-/expand-tilde-2.0.2.tgz",
@@ -12266,9 +12409,7 @@
"file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
- "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
- "dev": true,
- "optional": true
+ "integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw=="
},
"filesize": {
"version": "6.0.1",
@@ -12681,11 +12822,15 @@
"readable-stream": "^2.0.0"
}
},
+ "fs-constants": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz",
+ "integrity": "sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow=="
+ },
"fs-extra": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/fs-extra/-/fs-extra-8.1.0.tgz",
"integrity": "sha512-yhlQgA6mnOJUKOsRUFsgJdQCvkKhcz8tlZG5HBQfReYZy46OwLcY+Zia0mtdHsOo9y/hP+CxMN0TU9QxoOtG4g==",
- "dev": true,
"requires": {
"graceful-fs": "^4.2.0",
"jsonfile": "^4.0.0",
@@ -12695,8 +12840,7 @@
"graceful-fs": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz",
- "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==",
- "dev": true
+ "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ=="
}
}
},
@@ -13295,6 +13439,41 @@
"integrity": "sha1-GwqzvVU7Kg1jmdKcDj6gslIHgyc=",
"dev": true
},
+ "gauge": {
+ "version": "2.7.4",
+ "resolved": "https://registry.npmjs.org/gauge/-/gauge-2.7.4.tgz",
+ "integrity": "sha1-LANAXHU4w51+s3sxcCLjJfsBi/c=",
+ "requires": {
+ "aproba": "^1.0.3",
+ "console-control-strings": "^1.0.0",
+ "has-unicode": "^2.0.0",
+ "object-assign": "^4.1.0",
+ "signal-exit": "^3.0.0",
+ "string-width": "^1.0.1",
+ "strip-ansi": "^3.0.1",
+ "wide-align": "^1.1.0"
+ },
+ "dependencies": {
+ "is-fullwidth-code-point": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-1.0.0.tgz",
+ "integrity": "sha1-754xOG8DGn8NZDr4L95QxFfvAMs=",
+ "requires": {
+ "number-is-nan": "^1.0.0"
+ }
+ },
+ "string-width": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/string-width/-/string-width-1.0.2.tgz",
+ "integrity": "sha1-EYvfW4zcUaKn5w0hHgfisLmxB9M=",
+ "requires": {
+ "code-point-at": "^1.0.0",
+ "is-fullwidth-code-point": "^1.0.0",
+ "strip-ansi": "^3.0.0"
+ }
+ }
+ }
+ },
"generic-names": {
"version": "1.0.3",
"resolved": "https://registry.npmjs.org/generic-names/-/generic-names-1.0.3.tgz",
@@ -13383,6 +13562,11 @@
}
}
},
+ "github-from-package": {
+ "version": "0.0.0",
+ "resolved": "https://registry.npmjs.org/github-from-package/-/github-from-package-0.0.0.tgz",
+ "integrity": "sha1-l/tdlr/eiXMxPyDoKI75oWf6ZM4="
+ },
"glob": {
"version": "7.1.4",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.1.4.tgz",
@@ -13529,8 +13713,7 @@
"graceful-fs": {
"version": "4.1.15",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz",
- "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA==",
- "dev": true
+ "integrity": "sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA=="
},
"growl": {
"version": "1.10.5",
@@ -13980,6 +14163,11 @@
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz",
"integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q="
},
+ "has-unicode": {
+ "version": "2.0.1",
+ "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz",
+ "integrity": "sha1-4Ob+aijPUROIVeCG0Wkedx3iqLk="
+ },
"has-value": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz",
@@ -14344,8 +14532,7 @@
"ieee754": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
- "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==",
- "dev": true
+ "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
},
"iferr": {
"version": "0.1.5",
@@ -14452,8 +14639,7 @@
"ini": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/ini/-/ini-1.3.5.tgz",
- "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw==",
- "dev": true
+ "integrity": "sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw=="
},
"inquirer": {
"version": "7.0.4",
@@ -14778,8 +14964,7 @@
"is-fullwidth-code-point": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz",
- "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=",
- "dev": true
+ "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8="
},
"is-generator-fn": {
"version": "2.1.0",
@@ -18270,7 +18455,6 @@
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
- "dev": true,
"requires": {
"graceful-fs": "^4.1.6"
}
@@ -19016,6 +19200,11 @@
"integrity": "sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg==",
"dev": true
},
+ "mimic-response": {
+ "version": "2.1.0",
+ "resolved": "https://registry.npmjs.org/mimic-response/-/mimic-response-2.1.0.tgz",
+ "integrity": "sha512-wXqjST+SLt7R009ySCglWBCFpjUygmCIfD790/kVbiGmUgfYGuB14PiTd5DwVxSV4NcYHjzMkoj5LjQZwTQLEA=="
+ },
"min-indent": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.0.tgz",
@@ -19377,9 +19566,7 @@
"nan": {
"version": "2.14.0",
"resolved": "https://registry.npmjs.org/nan/-/nan-2.14.0.tgz",
- "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg==",
- "dev": true,
- "optional": true
+ "integrity": "sha512-INOFj37C7k3AfaNTtX8RhsTw7qRy7eLET14cROi9+5HAVbbHuIWUHEauBv5qT4Av2tWasiTY1Jw6puUNqRJXQg=="
},
"nanomatch": {
"version": "1.2.13",
@@ -19406,6 +19593,11 @@
}
}
},
+ "napi-build-utils": {
+ "version": "1.0.2",
+ "resolved": "https://registry.npmjs.org/napi-build-utils/-/napi-build-utils-1.0.2.tgz",
+ "integrity": "sha512-ONmRUqK7zj7DWX0D9ADe03wbwOBZxNAfF20PlGfCWQcD3+/MakShIHrMqx9YwPTfxDdF1zLeL+RGZiR9kGMLdg=="
+ },
"natural-compare": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/natural-compare/-/natural-compare-1.4.0.tgz",
@@ -19451,6 +19643,14 @@
}
}
},
+ "node-abi": {
+ "version": "2.15.0",
+ "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-2.15.0.tgz",
+ "integrity": "sha512-FeLpTS0F39U7hHZU1srAK4Vx+5AHNVOTP+hxBNQknR/54laTHSFIJkDWDqiquY1LeLUgTfPN7sLPhMubx0PLAg==",
+ "requires": {
+ "semver": "^5.4.1"
+ }
+ },
"node-environment-flags": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/node-environment-flags/-/node-environment-flags-1.0.5.tgz",
@@ -19569,6 +19769,11 @@
}
}
},
+ "noop-logger": {
+ "version": "0.1.1",
+ "resolved": "https://registry.npmjs.org/noop-logger/-/noop-logger-0.1.1.tgz",
+ "integrity": "sha1-lKKxYzxPExdVMAfYlm/Q6EG2pMI="
+ },
"normalize-package-data": {
"version": "2.5.0",
"resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz",
@@ -19672,6 +19877,17 @@
"path-key": "^2.0.0"
}
},
+ "npmlog": {
+ "version": "4.1.2",
+ "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-4.1.2.tgz",
+ "integrity": "sha512-2uUqazuKlTaSI/dC8AzicUck7+IrEaOnN/e0jd3Xtt1KcGpwx30v50mL7oPyr/h9bL3E4aZccVwpwP+5W9Vjkg==",
+ "requires": {
+ "are-we-there-yet": "~1.1.2",
+ "console-control-strings": "~1.1.0",
+ "gauge": "~2.7.3",
+ "set-blocking": "~2.0.0"
+ }
+ },
"nth-check": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/nth-check/-/nth-check-1.0.2.tgz",
@@ -19690,8 +19906,7 @@
"number-is-nan": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz",
- "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=",
- "dev": true
+ "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0="
},
"nwsapi": {
"version": "2.2.0",
@@ -24894,6 +25109,28 @@
"uniq": "^1.0.1"
}
},
+ "prebuild-install": {
+ "version": "5.3.3",
+ "resolved": "https://registry.npmjs.org/prebuild-install/-/prebuild-install-5.3.3.tgz",
+ "integrity": "sha512-GV+nsUXuPW2p8Zy7SarF/2W/oiK8bFQgJcncoJ0d7kRpekEA0ftChjfEaF9/Y+QJEc/wFR7RAEa8lYByuUIe2g==",
+ "requires": {
+ "detect-libc": "^1.0.3",
+ "expand-template": "^2.0.3",
+ "github-from-package": "0.0.0",
+ "minimist": "^1.2.0",
+ "mkdirp": "^0.5.1",
+ "napi-build-utils": "^1.0.1",
+ "node-abi": "^2.7.0",
+ "noop-logger": "^0.1.1",
+ "npmlog": "^4.0.1",
+ "pump": "^3.0.0",
+ "rc": "^1.2.7",
+ "simple-get": "^3.0.3",
+ "tar-fs": "^2.0.0",
+ "tunnel-agent": "^0.6.0",
+ "which-pm-runs": "^1.0.0"
+ }
+ },
"prelude-ls": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/prelude-ls/-/prelude-ls-1.1.2.tgz",
@@ -24992,8 +25229,7 @@
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
- "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==",
- "dev": true
+ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw=="
},
"progress": {
"version": "2.0.3",
@@ -25201,6 +25437,17 @@
}
}
},
+ "rc": {
+ "version": "1.2.8",
+ "resolved": "https://registry.npmjs.org/rc/-/rc-1.2.8.tgz",
+ "integrity": "sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==",
+ "requires": {
+ "deep-extend": "^0.6.0",
+ "ini": "~1.3.0",
+ "minimist": "^1.2.0",
+ "strip-json-comments": "~2.0.1"
+ }
+ },
"react": {
"version": "16.12.0",
"resolved": "https://registry.npmjs.org/react/-/react-16.12.0.tgz",
@@ -27648,7 +27895,6 @@
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
"integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==",
- "dev": true,
"requires": {
"core-util-is": "~1.0.0",
"inherits": "~2.0.3",
@@ -28499,6 +28745,23 @@
"integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==",
"dev": true
},
+ "serialport": {
+ "version": "8.0.7",
+ "resolved": "https://registry.npmjs.org/serialport/-/serialport-8.0.7.tgz",
+ "integrity": "sha512-R9bfNebs2dblYf5sD/Aaa7j8+siP4X7TGT02lqHM9DF5fyjlrPGXmsLw9+LKOz1AvjGjkxf2NzBVnDpqRX7clQ==",
+ "requires": {
+ "@serialport/binding-mock": "^8.0.6",
+ "@serialport/bindings": "^8.0.7",
+ "@serialport/parser-byte-length": "^8.0.6",
+ "@serialport/parser-cctalk": "^8.0.6",
+ "@serialport/parser-delimiter": "^8.0.6",
+ "@serialport/parser-readline": "^8.0.6",
+ "@serialport/parser-ready": "^8.0.6",
+ "@serialport/parser-regex": "^8.0.6",
+ "@serialport/stream": "^8.0.6",
+ "debug": "^4.1.1"
+ }
+ },
"serve-index": {
"version": "1.9.1",
"resolved": "https://registry.npmjs.org/serve-index/-/serve-index-1.9.1.tgz",
@@ -28695,6 +28958,21 @@
"resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz",
"integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0="
},
+ "simple-concat": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/simple-concat/-/simple-concat-1.0.0.tgz",
+ "integrity": "sha1-c0TLuLbib7J9ZrL8hvn21Zl1IcY="
+ },
+ "simple-get": {
+ "version": "3.1.0",
+ "resolved": "https://registry.npmjs.org/simple-get/-/simple-get-3.1.0.tgz",
+ "integrity": "sha512-bCR6cP+aTdScaQCnQKbPKtJOKDp/hj9EDLJo3Nw4y1QksqaovlW/bnptB6/c1e+qmNIDHRK+oXFDdEqBT8WzUA==",
+ "requires": {
+ "decompress-response": "^4.2.0",
+ "once": "^1.3.1",
+ "simple-concat": "^1.0.0"
+ }
+ },
"simple-swizzle": {
"version": "0.2.2",
"resolved": "https://registry.npmjs.org/simple-swizzle/-/simple-swizzle-0.2.2.tgz",
@@ -29317,7 +29595,6 @@
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz",
"integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==",
- "dev": true,
"requires": {
"is-fullwidth-code-point": "^2.0.0",
"strip-ansi": "^4.0.0"
@@ -29326,14 +29603,12 @@
"ansi-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz",
- "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=",
- "dev": true
+ "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg="
},
"strip-ansi": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz",
"integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=",
- "dev": true,
"requires": {
"ansi-regex": "^3.0.0"
}
@@ -29375,7 +29650,6 @@
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
- "dev": true,
"requires": {
"safe-buffer": "~5.1.0"
}
@@ -29450,8 +29724,7 @@
"strip-json-comments": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-2.0.1.tgz",
- "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo=",
- "dev": true
+ "integrity": "sha1-PFMZQukIwml8DsNEhYwobHygpgo="
},
"style-inject": {
"version": "0.3.0",
@@ -29729,6 +30002,41 @@
"integrity": "sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA==",
"dev": true
},
+ "tar-fs": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/tar-fs/-/tar-fs-2.0.0.tgz",
+ "integrity": "sha512-vaY0obB6Om/fso8a8vakQBzwholQ7v5+uy+tF3Ozvxv1KNezmVQAiWtcNmMHFSFPqL3dJA8ha6gdtFbfX9mcxA==",
+ "requires": {
+ "chownr": "^1.1.1",
+ "mkdirp": "^0.5.1",
+ "pump": "^3.0.0",
+ "tar-stream": "^2.0.0"
+ }
+ },
+ "tar-stream": {
+ "version": "2.1.2",
+ "resolved": "https://registry.npmjs.org/tar-stream/-/tar-stream-2.1.2.tgz",
+ "integrity": "sha512-UaF6FoJ32WqALZGOIAApXx+OdxhekNMChu6axLJR85zMMjXKWFGjbIRe+J6P4UnRGg9rAwWvbTT0oI7hD/Un7Q==",
+ "requires": {
+ "bl": "^4.0.1",
+ "end-of-stream": "^1.4.1",
+ "fs-constants": "^1.0.0",
+ "inherits": "^2.0.3",
+ "readable-stream": "^3.1.1"
+ },
+ "dependencies": {
+ "readable-stream": {
+ "version": "3.6.0",
+ "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz",
+ "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==",
+ "requires": {
+ "inherits": "^2.0.3",
+ "string_decoder": "^1.1.1",
+ "util-deprecate": "^1.0.1"
+ }
+ }
+ }
+ },
"terminal-link": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/terminal-link/-/terminal-link-2.1.1.tgz",
@@ -30491,8 +30799,7 @@
"universalify": {
"version": "0.1.2",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
- "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==",
- "dev": true
+ "integrity": "sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="
},
"unpipe": {
"version": "1.0.0",
@@ -30648,6 +30955,27 @@
"requires-port": "^1.0.0"
}
},
+ "usb-detection": {
+ "version": "4.7.0",
+ "resolved": "https://registry.npmjs.org/usb-detection/-/usb-detection-4.7.0.tgz",
+ "integrity": "sha512-HE9y5uYfA2ebVo64BrIB0OVNaVKZ2oWkadpTItCi4YQXyZ9vD0705iqQ3B7Rz8xevcrW/RNg/85E2o2JoPFmsQ==",
+ "requires": {
+ "bindings": "^1.3.0",
+ "eventemitter2": "^5.0.1",
+ "nan": "^2.13.2",
+ "prebuild-install": "^5.1.0"
+ }
+ },
+ "usb-native": {
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/usb-native/-/usb-native-5.0.1.tgz",
+ "integrity": "sha512-FuKUVJmzgo7I6jclH0fCLuQLuOTg3jzzDvQwFgFWJM5Qe1L09snrl84adFCNvE/LGbCCCa4XjLuGGIgB7+zGQA==",
+ "requires": {
+ "fs-extra": "^8.1.0",
+ "serialport": "^8.0.7",
+ "usb-detection": "^4.7.0"
+ }
+ },
"use": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz",
@@ -30668,8 +30996,7 @@
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
- "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=",
- "dev": true
+ "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"util.promisify": {
"version": "1.0.0",
@@ -31493,11 +31820,15 @@
"resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz",
"integrity": "sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho="
},
+ "which-pm-runs": {
+ "version": "1.0.0",
+ "resolved": "https://registry.npmjs.org/which-pm-runs/-/which-pm-runs-1.0.0.tgz",
+ "integrity": "sha1-Zws6+8VS4LVd9rd4DKdGFfI60cs="
+ },
"wide-align": {
"version": "1.1.3",
"resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz",
"integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==",
- "dev": true,
"requires": {
"string-width": "^1.0.2 || 2"
}
diff --git a/package.json b/package.json
index a0175cd36..66f094cc0 100644
--- a/package.json
+++ b/package.json
@@ -7,7 +7,7 @@
"instrumentationKey": "__AIKEY__",
"icon": "assets/icon.png",
"engines": {
- "vscode": "^1.34.0"
+ "vscode": "^1.43.0"
},
"categories": [
"Other"
@@ -325,6 +325,7 @@
"socket.io": "^2.2.0",
"svg-inline-react": "^3.1.0",
"ts-jest": "^25.0.0",
+ "usb-native": "^5.0.1",
"util": "^0.12.1",
"vscode-extension-telemetry": "^0.1.1",
"vscode-nls": "^4.1.0"
diff --git a/src/constants.ts b/src/constants.ts
index 7558b7665..fa4e3e1e0 100644
--- a/src/constants.ts
+++ b/src/constants.ts
@@ -403,6 +403,9 @@ export namespace DialogResponses {
export const CANCEL: MessageItem = {
title: localize("dialogResponses.cancel", "Cancel"),
};
+ export const SELECT: MessageItem = {
+ title: localize("dialogResponses.select", "Select"),
+ };
export const HELP: MessageItem = {
title: localize("dialogResponses.help", "I need help"),
};
diff --git a/src/serialMonitor.ts b/src/serialMonitor.ts
index 17144eeb6..f3685cd58 100644
--- a/src/serialMonitor.ts
+++ b/src/serialMonitor.ts
@@ -11,7 +11,7 @@ import { logToOutputChannel } from "./extension_utils/utils";
import { SerialPortControl } from "./serialPortControl";
export interface ISerialPortDetail {
- comName: string;
+ path: string;
manufacturer: string;
vendorId: string;
productId: string;
@@ -127,7 +127,7 @@ export class SerialMonitor implements vscode.Disposable {
foundPort &&
!(this._serialPortControl && this._serialPortControl.isActive)
) {
- this.updatePortListStatus(foundPort.comName);
+ this.updatePortListStatus(foundPort.path);
}
} else {
const chosen = await vscode.window.showQuickPick(
@@ -136,7 +136,7 @@ export class SerialMonitor implements vscode.Disposable {
(port: ISerialPortDetail): vscode.QuickPickItem => {
return {
description: port.manufacturer,
- label: port.comName,
+ label: port.path,
};
}
)
@@ -160,10 +160,10 @@ export class SerialMonitor implements vscode.Disposable {
if (!this._currentPort) {
const ans = await vscode.window.showInformationMessage(
CONSTANTS.WARNING.NO_SERIAL_PORT_SELECTED,
- DialogResponses.YES,
- DialogResponses.NO
+ DialogResponses.SELECT,
+ DialogResponses.CANCEL
);
- if (ans === DialogResponses.YES) {
+ if (ans === DialogResponses.SELECT) {
await this.selectSerialPort(null, null);
}
if (!this._currentPort) {
diff --git a/src/serialPortControl.ts b/src/serialPortControl.ts
index cbc79c3bb..64d8d010a 100644
--- a/src/serialPortControl.ts
+++ b/src/serialPortControl.ts
@@ -9,7 +9,7 @@ import { CONSTANTS } from "./constants";
import { logToOutputChannel } from "./extension_utils/utils";
interface ISerialPortDetail {
- comName: string;
+ path: string;
manufacturer: string;
vendorId: string;
productId: string;
@@ -18,21 +18,16 @@ interface ISerialPortDetail {
export class SerialPortControl {
public static get serialport(): any {
if (!SerialPortControl._serialport) {
- SerialPortControl._serialport = require("../vendor/node-usb-native").SerialPort;
+ SerialPortControl._serialport = require("usb-native").SerialPort;
}
return SerialPortControl._serialport;
}
public static list(): Promise {
return new Promise((resolve, reject) => {
- SerialPortControl.serialport.list(
- (error: any, ports: ISerialPortDetail[]) => {
- if (error) {
- reject(error);
- } else {
- resolve(ports);
- }
- }
+ SerialPortControl.serialport.list().then(
+ ports => resolve(ports),
+ err => reject(err)
);
});
}
@@ -53,7 +48,7 @@ export class SerialPortControl {
}
public get isActive(): boolean {
- return this._currentSerialPort && this._currentSerialPort.isOpen();
+ return this._currentSerialPort && this._currentSerialPort.isOpen;
}
public get currentPort(): string {
@@ -66,7 +61,7 @@ export class SerialPortControl {
CONSTANTS.INFO.OPENING_SERIAL_PORT(this._currentPort)
);
return new Promise((resolve, reject) => {
- if (this._currentSerialPort && this._currentSerialPort.isOpen()) {
+ if (this._currentSerialPort && this._currentSerialPort.isOpen) {
this._currentSerialPort.close((err: any) => {
if (err) {
return reject(err);
@@ -89,8 +84,7 @@ export class SerialPortControl {
this._outputChannel.show();
this._currentSerialPort.on("open", () => {
this._currentSerialPort.write(
- CONSTANTS.MISC.SERIAL_MONITOR_TEST_IF_OPEN,
- "Both NL & CR",
+ CONSTANTS.MISC.SERIAL_MONITOR_TEST_IF_OPEN + os.EOL,
(err: any) => {
if (
err &&
diff --git a/src/usbDetector.ts b/src/usbDetector.ts
index ccff7a679..6d28bb9fb 100644
--- a/src/usbDetector.ts
+++ b/src/usbDetector.ts
@@ -42,7 +42,7 @@ export class UsbDetector {
if (os.platform() === "linux" || !enableUSBDetection) {
return;
}
- this._usbDetector = require("../vendor/node-usb-native").detector;
+ this._usbDetector = require("usb-native").detector;
if (!this._usbDetector) {
return;
diff --git a/vendor/node-usb-native/.eslintrc b/vendor/node-usb-native/.eslintrc
deleted file mode 100644
index 3ade3b9dd..000000000
--- a/vendor/node-usb-native/.eslintrc
+++ /dev/null
@@ -1,26 +0,0 @@
-{
- "extends": [
- "standard"
- ],
- "plugins": [
- "require-path-exists"
- ],
- "env": {
- "node": true,
- "mocha": true
- },
- "rules": {
- "arrow-parens": [2, "as-needed", {"requireForBlockBody": true }],
- "no-unused-vars": [2, { "vars": "all", "args": "after-used" }],
- "object-curly-spacing": [2, "always"],
- "prefer-arrow-callback": 2,
- "prefer-const": 2,
- "prefer-template": 2,
- "require-path-exists/exists": 2,
- "require-path-exists/notEmpty": 2,
- "require-path-exists/tooManyArguments": 2,
- "semi": [2, "always", {"omitLastInOneLineBlock": true}],
- "space-before-function-paren": [2, "never"],
- "standard/object-curly-even-spacing": 0
- }
-}
\ No newline at end of file
diff --git a/vendor/node-usb-native/.gitignore b/vendor/node-usb-native/.gitignore
deleted file mode 100644
index 41ace66fd..000000000
--- a/vendor/node-usb-native/.gitignore
+++ /dev/null
@@ -1,14 +0,0 @@
-$ cat .gitignore
-
-# Can ignore specific files
-.settings.xml
-.monitor
-.DS_Store
-
-# Use wildcards as well
-*~
-#*.swp
-
-# Can also ignore all directories and files in a directory.
-node_modules/
-build/
diff --git a/vendor/node-usb-native/.npmignore b/vendor/node-usb-native/.npmignore
deleted file mode 100644
index 27b90ed90..000000000
--- a/vendor/node-usb-native/.npmignore
+++ /dev/null
@@ -1,2 +0,0 @@
-node_modules/
-build/
diff --git a/vendor/node-usb-native/README.md b/vendor/node-usb-native/README.md
deleted file mode 100644
index 329164300..000000000
--- a/vendor/node-usb-native/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-This is a natvie package contains two modules: detector and serialport, detector provides the functionality of detecting usb changes and serialport provides the functionality of listing serial ports, openning serial ports and sending/receiving message to/from serial ports.
-
- require("../../../vendor/node-usb-native").SerialPort;
- require("../../../vendor/node-usb-native").detector;
diff --git a/vendor/node-usb-native/binding.gyp b/vendor/node-usb-native/binding.gyp
deleted file mode 100644
index 10be49615..000000000
--- a/vendor/node-usb-native/binding.gyp
+++ /dev/null
@@ -1,64 +0,0 @@
-{
- "targets": [
- {
- "target_name": "usb-native",
- "sources": [
- "src/detection.cpp",
- "src/detection.h",
- "src/deviceList.cpp",
- "src/combined.cpp",
- "src/serialport.cpp"
- ],
- "include_dirs": [
- " {
- // Suss out the optional parameters
- if (!pid && !callback) {
- callback = vid;
- vid = undefined;
- } else if (!callback) {
- callback = pid;
- pid = undefined;
- }
-
- return new Promise((resolve, reject) => {
- // Assemble the optional args into something we can use with `apply`
- var args = [];
- if (vid) {
- args = args.concat(vid);
- }
- if (pid) {
- args = args.concat(pid);
- }
-
- // Tack on our own callback that takes care of things
- args = args.concat((err, devices) => {
- // We call the callback if they passed one
- if (callback) {
- callback.call(callback, err, devices);
- }
-
- // But also do the promise stuff
- if (err) {
- reject(err);
- return;
- }
- resolve(devices);
- });
-
- // Fire off the `find` function that actually does all of the work
- detection.find.apply(detection, args);
- });
-};
-if (detection.registerAdded) {
- detection.registerAdded((device) => {
- detector.emit(`add:${device.vendorId}:${device.productId}`, device);
- detector.emit(`insert:${device.vendorId}:${device.productId}`, device);
- detector.emit(`add:${device.vendorId}`, device);
- detector.emit(`insert:${device.vendorId}`, device);
- detector.emit('add', device);
- detector.emit('insert', device);
-
- detector.emit(`change:${device.vendorId}:${device.productId}`, device);
- detector.emit(`change:${device.vendorId}`, device);
- detector.emit('change', device);
- });
-
- detection.registerRemoved((device) => {
- detector.emit(`remove:${device.vendorId}:${device.productId}`, device);
- detector.emit(`remove:${device.vendorId}`, device);
- detector.emit('remove', device);
-
- detector.emit(`change:${device.vendorId}:${device.productId}`, device);
- detector.emit(`change:${device.vendorId}`, device);
- detector.emit('change', device);
- });
-
- var started = true;
-
- detector.startMonitoring = () => {
- if (started) {
- return;
- }
-
- started = true;
- detection.startMonitoring();
- };
-
- detector.stopMonitoring = () => {
- if (!started) {
- return;
- }
-
- started = false;
- detection.stopMonitoring();
- };
-}
-
-module.exports = detector;
diff --git a/vendor/node-usb-native/lib/index.js b/vendor/node-usb-native/lib/index.js
deleted file mode 100644
index 09bfc7115..000000000
--- a/vendor/node-usb-native/lib/index.js
+++ /dev/null
@@ -1,2 +0,0 @@
-exports.detector = require('./detector');
-exports.SerialPort = require('./serialport');
diff --git a/vendor/node-usb-native/lib/list-unix.js b/vendor/node-usb-native/lib/list-unix.js
deleted file mode 100644
index 32e6719a9..000000000
--- a/vendor/node-usb-native/lib/list-unix.js
+++ /dev/null
@@ -1,109 +0,0 @@
-'use strict';
-
-var childProcess = require('child_process');
-var fs = require('fs');
-var path = require('path');
-
-function promisify(func) {
- return (arg) => {
- return new Promise((resolve, reject) => {
- func(arg, (err, data) => {
- if (err) {
- return reject(err);
- }
- resolve(data);
- });
- });
- };
-}
-
-function promisedFilter(func) {
- return (data) => {
- var shouldKeep = data.map(func);
- return Promise.all(shouldKeep).then((keep) => {
- return data.filter((path, index) => {
- return keep[index];
- });
- });
- };
-}
-
-var statAsync = promisify(fs.stat);
-var readdirAsync = promisify(fs.readdir);
-var execAsync = promisify(childProcess.exec);
-
-function udevParser(output) {
- var udevInfo = output.split('\n').reduce((info, line) => {
- if (!line || line.trim() === '') {
- return info;
- }
- var parts = line.split('=').map((part) => {
- return part.trim();
- });
-
- info[parts[0].toLowerCase()] = parts[1];
-
- return info;
- }, {});
-
- var pnpId;
- if (udevInfo.devlinks) {
- udevInfo.devlinks.split(' ').forEach((path) => {
- if (path.indexOf('/by-id/') === -1) { return }
- pnpId = path.substring(path.lastIndexOf('/') + 1);
- });
- }
-
- var vendorId = udevInfo.id_vendor_id;
- if (vendorId && vendorId.substring(0, 2) !== '0x') {
- vendorId = `0x${vendorId}`;
- }
-
- var productId = udevInfo.id_model_id;
- if (productId && productId.substring(0, 2) !== '0x') {
- productId = `0x${productId}`;
- }
-
- return {
- comName: udevInfo.devname,
- manufacturer: udevInfo.id_vendor,
- serialNumber: udevInfo.id_serial,
- pnpId: pnpId,
- vendorId: vendorId,
- productId: productId
- };
-}
-
-function checkPathAndDevice(path) {
- // get only serial port names
- if (!(/(tty(S|ACM|USB|AMA|MFD)|rfcomm)/).test(path)) {
- return false;
- }
- return statAsync(path).then((stats) => {
- return stats.isCharacterDevice();
- });
-}
-
-function lookupPort(file) {
- var udevadm = `udevadm info --query=property -p $(udevadm info -q path -n ${file})`;
- return execAsync(udevadm).then(udevParser);
-}
-
-function listUnix(callback) {
- var dirName = '/dev';
- readdirAsync(dirName)
- .catch((err) => {
- // if this directory is not found we just pretend everything is OK
- // TODO Depreciated this check?
- if (err.errno === 34) {
- return [];
- }
- throw err;
- })
- .then((data) => { return data.map((file) => { return path.join(dirName, file) }) })
- .then(promisedFilter(checkPathAndDevice))
- .then((data) => { return Promise.all(data.map(lookupPort)) })
- .then((data) => { callback(null, data) }, (err) => { callback(err) });
-}
-
-module.exports = listUnix;
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.4.6_ia32.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.4.6_ia32.node
deleted file mode 100644
index 9c0cd4283..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.4.6_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.4.6_x64.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.4.6_x64.node
deleted file mode 100644
index 4623a53bf..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.4.6_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.6.6_ia32.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.6.6_ia32.node
deleted file mode 100644
index 57028b867..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.6.6_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.6.6_x64.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.6.6_x64.node
deleted file mode 100644
index d2f921e58..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.6.6_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.7.3_ia32.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.7.3_ia32.node
deleted file mode 100644
index bff5f2ebe..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.7.3_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.7.3_x64.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.7.3_x64.node
deleted file mode 100644
index d5851886d..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_1.7.3_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_2.0.2_ia32.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_2.0.2_ia32.node
deleted file mode 100644
index b626c0c1a..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_2.0.2_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_2.0.2_x64.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_2.0.2_x64.node
deleted file mode 100644
index 28cb86f0e..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_2.0.2_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_3.0.10_ia32.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_3.0.10_ia32.node
deleted file mode 100644
index 36a4ed73a..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_3.0.10_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_3.0.10_x64.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_3.0.10_x64.node
deleted file mode 100644
index 54e421b31..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_3.0.10_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_4.2.5_ia32.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_4.2.5_ia32.node
deleted file mode 100644
index 0ea992b82..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_4.2.5_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_4.2.5_x64.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_4.2.5_x64.node
deleted file mode 100644
index a1d586205..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_4.2.5_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_6.1.4_ia32.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_6.1.4_ia32.node
deleted file mode 100644
index 83b71d780..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_6.1.4_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_6.1.4_x64.node b/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_6.1.4_x64.node
deleted file mode 100644
index 5e379cb9a..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_Ubuntu14.04_6.1.4_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_darwin_1.4.6_x64.node b/vendor/node-usb-native/lib/native/usb-native_darwin_1.4.6_x64.node
deleted file mode 100644
index 5a6d083c0..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_darwin_1.4.6_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_darwin_1.6.6_x64.node b/vendor/node-usb-native/lib/native/usb-native_darwin_1.6.6_x64.node
deleted file mode 100644
index e250b8a3c..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_darwin_1.6.6_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_darwin_1.7.3_x64.node b/vendor/node-usb-native/lib/native/usb-native_darwin_1.7.3_x64.node
deleted file mode 100644
index 3a4ab3cac..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_darwin_1.7.3_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_darwin_2.0.2_x64.node b/vendor/node-usb-native/lib/native/usb-native_darwin_2.0.2_x64.node
deleted file mode 100644
index ab9554d91..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_darwin_2.0.2_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_darwin_3.0.10_x64.node b/vendor/node-usb-native/lib/native/usb-native_darwin_3.0.10_x64.node
deleted file mode 100644
index 65c124d7f..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_darwin_3.0.10_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_darwin_4.2.5_x64.node b/vendor/node-usb-native/lib/native/usb-native_darwin_4.2.5_x64.node
deleted file mode 100644
index 64d8ec806..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_darwin_4.2.5_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_darwin_6.1.4_x64.node b/vendor/node-usb-native/lib/native/usb-native_darwin_6.1.4_x64.node
deleted file mode 100644
index 440a59200..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_darwin_6.1.4_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.6_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.4.6_ia32.node
deleted file mode 100644
index d4a5c46aa..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.6_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.6_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.4.6_x64.node
deleted file mode 100644
index 7a934e273..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.6_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.7_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.4.7_ia32.node
deleted file mode 100644
index bb473cbaa..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.7_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.7_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.4.7_x64.node
deleted file mode 100644
index 865eaf39c..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.4.7_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.6.6_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.6.6_ia32.node
deleted file mode 100644
index 853d52964..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.6.6_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.6.6_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.6.6_x64.node
deleted file mode 100644
index fc8dc8191..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.6.6_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.7.3_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.7.3_ia32.node
deleted file mode 100644
index 5c599c834..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.7.3_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_1.7.3_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_1.7.3_x64.node
deleted file mode 100644
index 7175fc2dd..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_1.7.3_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_2.0.2_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_2.0.2_ia32.node
deleted file mode 100644
index 35eafbd98..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_2.0.2_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_2.0.2_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_2.0.2_x64.node
deleted file mode 100644
index 7d10bd87b..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_2.0.2_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_3.0.10_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_3.0.10_ia32.node
deleted file mode 100644
index d96312f25..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_3.0.10_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_3.0.10_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_3.0.10_x64.node
deleted file mode 100644
index cee563b4f..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_3.0.10_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_4.2.5_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_4.2.5_ia32.node
deleted file mode 100644
index a5d5b53bc..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_4.2.5_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_4.2.5_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_4.2.5_x64.node
deleted file mode 100644
index cb667a70b..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_4.2.5_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_6.1.4_ia32.node b/vendor/node-usb-native/lib/native/usb-native_win32_6.1.4_ia32.node
deleted file mode 100644
index 277de25a2..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_6.1.4_ia32.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native/usb-native_win32_6.1.4_x64.node b/vendor/node-usb-native/lib/native/usb-native_win32_6.1.4_x64.node
deleted file mode 100644
index f31e6a342..000000000
Binary files a/vendor/node-usb-native/lib/native/usb-native_win32_6.1.4_x64.node and /dev/null differ
diff --git a/vendor/node-usb-native/lib/native_loader.js b/vendor/node-usb-native/lib/native_loader.js
deleted file mode 100644
index ce4e0ea22..000000000
--- a/vendor/node-usb-native/lib/native_loader.js
+++ /dev/null
@@ -1,24 +0,0 @@
-const glob = require('glob');
-const path = require('path');
-const loadLibrary = function(parentFolder, libraryName) {
- const nodegypFiles = glob(path.join(__dirname, `../build/+(Release|Debug)/${libraryName}.node`), {
- sync: true
- });
- const nodepregypFiles = glob(`${parentFolder.replace(/\\/g, '/')}/${libraryName}*${process.arch}*.node`, {
- sync: true
- });
- var binding = null;
- nodegypFiles.concat(nodepregypFiles).forEach((file) => {
- try {
- var _temp = require(file);
- binding = _temp;
- console.log('using', file);
- } catch (e) {
- }
- });
- if (!binding) {
- console.log('[Warn]', 'no library available after trying files', nodegypFiles.concat(nodepregypFiles));
- }
- return binding;
-};
-exports.load = loadLibrary;
diff --git a/vendor/node-usb-native/lib/parsers.js b/vendor/node-usb-native/lib/parsers.js
deleted file mode 100644
index 303fba50d..000000000
--- a/vendor/node-usb-native/lib/parsers.js
+++ /dev/null
@@ -1,64 +0,0 @@
-'use strict';
-
-// Copyright 2011 Chris Williams
-
-module.exports = {
- raw: function(emitter, buffer) {
- emitter.emit('data', buffer);
- },
-
- // encoding: ascii utf8 utf16le ucs2 base64 binary hex
- // More: http://nodejs.org/api/buffer.html#buffer_buffer
- readline: function(delimiter, encoding) {
- if (typeof delimiter === 'undefined' || delimiter === null) { delimiter = '\r' }
- if (typeof encoding === 'undefined' || encoding === null) { encoding = 'utf8' }
- // Delimiter buffer saved in closure
- var data = '';
- return function(emitter, buffer) {
- // Collect data
- data += buffer.toString(encoding);
- // Split collected data by delimiter
- var parts = data.split(delimiter);
- data = parts.pop();
- parts.forEach((part) => {
- emitter.emit('data', part);
- });
- };
- },
-
- // Emit a data event every `length` bytes
- byteLength: function(length) {
- var data = Buffer.alloc(0);
- return function(emitter, buffer) {
- data = Buffer.concat([data, buffer]);
- while (data.length >= length) {
- var out = data.slice(0, length);
- data = data.slice(length);
- emitter.emit('data', out);
- }
- };
- },
-
- // Emit a data event each time a byte sequence (delimiter is an array of byte) is found
- // Sample usage : byteDelimiter([10, 13])
- byteDelimiter: function(delimiter) {
- if (Object.prototype.toString.call(delimiter) !== '[object Array]') {
- delimiter = [ delimiter ];
- }
- var buf = [];
- var nextDelimIndex = 0;
- return function(emitter, buffer) {
- for (var i = 0; i < buffer.length; i++) {
- buf[buf.length] = buffer[i];
- if (buf[buf.length - 1] === delimiter[nextDelimIndex]) {
- nextDelimIndex++;
- }
- if (nextDelimIndex === delimiter.length) {
- emitter.emit('data', buf);
- buf = [];
- nextDelimIndex = 0;
- }
- }
- };
- }
-};
diff --git a/vendor/node-usb-native/lib/serialport.js b/vendor/node-usb-native/lib/serialport.js
deleted file mode 100644
index 754f21769..000000000
--- a/vendor/node-usb-native/lib/serialport.js
+++ /dev/null
@@ -1,502 +0,0 @@
-'use strict';
-
-// Copyright 2011 Chris Williams
-
-const _debug = false;
-const debug = (message) => {
- if (_debug) console.log(message);
-};
-
-// shims
-// Internal Dependencies
-var SerialPortBinding = require('./bindings');
-var parsers = require('./parsers');
-
-// Built-ins Dependencies
-var fs = require('fs');
-var stream = require('stream');
-var util = require('util');
-
-// VALIDATION ARRAYS
-var DATABITS = [5, 6, 7, 8];
-var STOPBITS = [1, 1.5, 2];
-var PARITY = ['none', 'even', 'mark', 'odd', 'space'];
-var FLOWCONTROLS = ['xon', 'xoff', 'xany', 'rtscts'];
-var SET_OPTIONS = ['brk', 'cts', 'dtr', 'dts', 'rts'];
-
-// Stuff from ReadStream, refactored for our usage:
-var kPoolSize = 40 * 1024;
-var kMinPoolSpace = 128;
-
-var defaultSettings = {
- baudRate: 9600,
- autoOpen: true,
- parity: 'none',
- xon: false,
- xoff: false,
- xany: false,
- rtscts: false,
- hupcl: true,
- dataBits: 8,
- stopBits: 1,
- bufferSize: 64 * 1024,
- lock: true,
- parser: parsers.raw,
- platformOptions: SerialPortBinding.platformOptions
-};
-
-var defaultSetFlags = {
- brk: false,
- cts: false,
- dtr: true,
- dts: false,
- rts: true
-};
-
-// deprecate the lowercase version of these options next major release
-var LOWERCASE_OPTIONS = [
- 'baudRate',
- 'dataBits',
- 'stopBits',
- 'bufferSize',
- 'platformOptions'
-];
-
-function correctOptions(options) {
- LOWERCASE_OPTIONS.forEach((name) => {
- var lowerName = name.toLowerCase();
- if (options.hasOwnProperty(lowerName)) {
- var value = options[lowerName];
- delete options[lowerName];
- options[name] = value;
- }
- });
- return options;
-}
-
-function SerialPort(path, options, callback) {
- if (typeof callback === 'boolean') {
- throw new TypeError('`openImmediately` is now called `autoOpen` and is a property of options');
- }
-
- if (typeof options === 'function') {
- callback = options;
- options = {};
- }
-
- options = options || {};
-
- stream.Stream.call(this);
-
- if (!path) {
- throw new TypeError('No path specified');
- }
-
- this.path = path;
-
- var correctedOptions = correctOptions(options);
- var settings = Object.assign({}, defaultSettings, correctedOptions);
-
- if (typeof settings.baudRate !== 'number') {
- throw new TypeError(`Invalid "baudRate" must be a number got: ${settings.baudRate}`);
- }
-
- if (DATABITS.indexOf(settings.dataBits) === -1) {
- throw new TypeError(`Invalid "databits": ${settings.dataBits}`);
- }
-
- if (STOPBITS.indexOf(settings.stopBits) === -1) {
- throw new TypeError(`Invalid "stopbits": ${settings.stopBits}`);
- }
-
- if (PARITY.indexOf(settings.parity) === -1) {
- throw new TypeError(`Invalid "parity": ${settings.parity}`);
- }
-
- FLOWCONTROLS.forEach((control) => {
- if (typeof settings[control] !== 'boolean') {
- throw new TypeError(`Invalid "${control}" is not boolean`);
- }
- });
-
- settings.disconnectedCallback = this._disconnected.bind(this);
- settings.dataCallback = settings.parser.bind(this, this);
-
- this.fd = null;
- this.paused = true;
- this.opening = false;
- this.closing = false;
-
- if (process.platform !== 'win32') {
- this.bufferSize = settings.bufferSize;
- this.readable = true;
- this.reading = false;
- }
-
- this.options = settings;
-
- if (this.options.autoOpen) {
- // is nextTick necessary?
- process.nextTick(this.open.bind(this, callback));
- }
-}
-
-util.inherits(SerialPort, stream.Stream);
-
-SerialPort.prototype._error = function(error, callback) {
- if (callback) {
- callback.call(this, error);
- } else {
- this.emit('error', error);
- }
-};
-
-SerialPort.prototype.open = function(callback) {
- if (this.isOpen()) {
- return this._error(new Error('Port is already open'), callback);
- }
-
- if (this.opening) {
- return this._error(new Error('Port is opening'), callback);
- }
-
- this.paused = true;
- this.readable = true;
- this.reading = false;
- this.opening = true;
-
- SerialPortBinding.open(this.path, this.options, (err, fd) => {
- this.opening = false;
- if (err) {
- debug('SerialPortBinding.open had an error', err);
- return this._error(err, callback);
- }
- this.fd = fd;
- this.paused = false;
-
- if (process.platform !== 'win32') {
- this.serialPoller = new SerialPortBinding.SerialportPoller(this.fd, (err) => {
- if (!err) {
- this._read();
- } else {
- this._disconnected(err);
- }
- });
- this.serialPoller.start();
- }
-
- this.emit('open');
- if (callback) {
- callback.call(this, null);
- }
- });
-};
-
-SerialPort.prototype.update = function(options, callback) {
- if (!this.isOpen()) {
- debug('update attempted, but port is not open');
- return this._error(new Error('Port is not open'), callback);
- }
-
- var correctedOptions = correctOptions(options);
- var settings = Object.assign({}, defaultSettings, correctedOptions);
- this.options.baudRate = settings.baudRate;
-
- SerialPortBinding.update(this.fd, this.options, (err) => {
- if (err) {
- return this._error(err, callback);
- }
- if (callback) {
- callback.call(this, null);
- }
- });
-};
-
-SerialPort.prototype.isOpen = function() {
- return this.fd !== null && !this.closing;
-};
-
-SerialPort.prototype.write = function(buffer, ending, callback) {
- if (!this.isOpen()) {
- debug('write attempted, but port is not open');
- return this._error(new Error('Port is not open'), callback);
- }
-
- if (!Buffer.isBuffer(buffer)) {
- buffer = Buffer.from(buffer);
- }
-
- switch (ending) {
- case 'Newline':
- buffer = Buffer.concat([buffer, Buffer.from('\n')]);
- break;
- case 'Carriage return':
- buffer = Buffer.concat([buffer, Buffer.from('\r')]);
- break;
- case 'Both NL & CR':
- buffer = Buffer.concat([buffer, Buffer.from('\r\n')]);
- break;
- default:
- break;
- }
-
- debug(`write ${buffer.length} bytes of data`);
- SerialPortBinding.write(this.fd, buffer, (err) => {
- if (err) {
- debug('SerialPortBinding.write had an error', err);
- return this._error(err, callback);
- }
- if (callback) {
- callback.call(this, null);
- }
- });
-};
-
-if (process.platform !== 'win32') {
- SerialPort.prototype._read = function() {
- if (!this.readable || this.paused || this.reading || this.closing) {
- return;
- }
-
- this.reading = true;
-
- if (!this.pool || this.pool.length - this.pool.used < kMinPoolSpace) {
- // discard the old pool. Can't add to the free list because
- // users might have references to slices on it.
- this.pool = Buffer.alloc(kPoolSize);
- this.pool.used = 0;
- }
-
- // Grab another reference to the pool in the case that while we're in the
- // thread pool another read() finishes up the pool, and allocates a new
- // one.
- var toRead = Math.min(this.pool.length - this.pool.used, ~~this.bufferSize);
- var start = this.pool.used;
-
- var _afterRead = (err, bytesRead, readPool, bytesRequested) => {
- this.reading = false;
- if (err) {
- if (err.code && err.code === 'EAGAIN') {
- if (this.isOpen()) {
- this.serialPoller.start();
- }
- // handle edge case were mac/unix doesn't clearly know the error.
- } else if (err.code && (err.code === 'EBADF' || err.code === 'ENXIO' || (err.errno === -1 || err.code === 'UNKNOWN'))) {
- this._disconnected(err);
- } else {
- this.fd = null;
- this.readable = false;
- this.emit('error', err);
- }
- return;
- }
-
- // Since we will often not read the number of bytes requested,
- // let's mark the ones we didn't need as available again.
- this.pool.used -= bytesRequested - bytesRead;
-
- if (bytesRead === 0) {
- if (this.isOpen()) {
- this.serialPoller.start();
- }
- } else {
- var b = this.pool.slice(start, start + bytesRead);
-
- // do not emit events if the stream is paused
- if (this.paused) {
- if (!this.buffer) {
- this.buffer = Buffer.alloc(0);
- }
- this.buffer = Buffer.concat([this.buffer, b]);
- return;
- }
- this._emitData(b);
-
- // do not emit events anymore after we declared the stream unreadable
- if (!this.readable) {
- return;
- }
- this._read();
- }
- };
-
- fs.read(this.fd, this.pool, this.pool.used, toRead, null, (err, bytesRead) => {
- var readPool = this.pool;
- var bytesRequested = toRead;
- _afterRead(err, bytesRead, readPool, bytesRequested);
- });
-
- this.pool.used += toRead;
- };
-
- SerialPort.prototype._emitData = function(data) {
- this.options.dataCallback(data);
- };
-
- SerialPort.prototype.pause = function() {
- this.paused = true;
- };
-
- SerialPort.prototype.resume = function() {
- this.paused = false;
-
- if (this.buffer) {
- var buffer = this.buffer;
- this.buffer = null;
- this._emitData(buffer);
- }
-
- // No longer open?
- if (!this.isOpen()) {
- return;
- }
-
- this._read();
- };
-} // if !'win32'
-
-SerialPort.prototype._disconnected = function(err) {
- this.paused = true;
- this.emit('disconnect', err);
- if (this.closing) {
- return;
- }
-
- if (this.fd === null) {
- return;
- }
-
- this.closing = true;
- if (process.platform !== 'win32') {
- this.readable = false;
- this.serialPoller.close();
- }
-
- SerialPortBinding.close(this.fd, (err) => {
- this.closing = false;
- if (err) {
- debug('Disconnect close completed with error: ', err);
- }
- this.fd = null;
- this.emit('close');
- });
-};
-
-SerialPort.prototype.close = function(callback) {
- this.paused = true;
-
- if (this.closing) {
- debug('close attempted, but port is already closing');
- return this._error(new Error('Port is not open'), callback);
- }
-
- if (!this.isOpen()) {
- debug('close attempted, but port is not open');
- return this._error(new Error('Port is not open'), callback);
- }
-
- this.closing = true;
-
- // Stop polling before closing the port.
- if (process.platform !== 'win32') {
- this.readable = false;
- this.serialPoller.close();
- }
- SerialPortBinding.close(this.fd, (err) => {
- this.closing = false;
- if (err) {
- debug('SerialPortBinding.close had an error', err);
- return this._error(err, callback);
- }
-
- this.fd = null;
- this.emit('close');
- if (callback) {
- callback.call(this, null);
- }
- });
-};
-
-SerialPort.prototype.flush = function(callback) {
- if (!this.isOpen()) {
- debug('flush attempted, but port is not open');
- return this._error(new Error('Port is not open'), callback);
- }
-
- SerialPortBinding.flush(this.fd, (err, result) => {
- if (err) {
- debug('SerialPortBinding.flush had an error', err);
- return this._error(err, callback);
- }
- if (callback) {
- callback.call(this, null, result);
- }
- });
-};
-
-SerialPort.prototype.set = function(options, callback) {
- if (!this.isOpen()) {
- debug('set attempted, but port is not open');
- return this._error(new Error('Port is not open'), callback);
- }
-
- options = options || {};
- if (!callback && typeof options === 'function') {
- callback = options;
- options = {};
- }
-
- var settings = {};
- for (var i = SET_OPTIONS.length - 1; i >= 0; i--) {
- var flag = SET_OPTIONS[i];
- if (options[flag] !== undefined) {
- settings[flag] = options[flag];
- } else {
- settings[flag] = defaultSetFlags[flag];
- }
- }
-
- SerialPortBinding.set(this.fd, settings, (err) => {
- if (err) {
- debug('SerialPortBinding.set had an error', err);
- return this._error(err, callback);
- }
- if (callback) {
- callback.call(this, null);
- }
- });
-};
-
-SerialPort.prototype.drain = function(callback) {
- if (!this.isOpen()) {
- debug('drain attempted, but port is not open');
- return this._error(new Error('Port is not open'), callback);
- }
-
- SerialPortBinding.drain(this.fd, (err) => {
- if (err) {
- debug('SerialPortBinding.drain had an error', err);
- return this._error(err, callback);
- }
- if (callback) {
- callback.call(this, null);
- }
- });
-};
-
-SerialPort.parsers = parsers;
-SerialPort.list = SerialPortBinding.list;
-
-// Write a depreciation warning once
-Object.defineProperty(SerialPort, 'SerialPort', {
- get: function() {
- // console.warn('DEPRECATION: Please use `require(\'serialport\')` instead of `require(\'serialport\').SerialPort`');
- Object.defineProperty(SerialPort, 'SerialPort', {
- value: SerialPort
- });
- return SerialPort;
- },
- configurable: true
-});
-
-module.exports = SerialPort;
diff --git a/vendor/node-usb-native/license b/vendor/node-usb-native/license
deleted file mode 100644
index 4322c5ab6..000000000
--- a/vendor/node-usb-native/license
+++ /dev/null
@@ -1,19 +0,0 @@
-Copyright (c) 2013 Kaba AG
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
diff --git a/vendor/node-usb-native/package.json b/vendor/node-usb-native/package.json
deleted file mode 100644
index 7779f1140..000000000
--- a/vendor/node-usb-native/package.json
+++ /dev/null
@@ -1,34 +0,0 @@
-{
- "name": "usb-native",
- "version": "0.0.1",
- "description": "node-usb && node-serialport combined.",
- "main": "lib/index.js",
- "gypfile": true,
- "keywords": [
- "usb",
- "device",
- "hardware",
- "list",
- "insert",
- "add",
- "remove",
- "change",
- "plug",
- "unplug",
- "notification"
- ],
- "license": "MIT",
- "scripts": {
- "install": "node-gyp rebuild --target=1.6.6 --arch=x64 --dist-url=https://atom.io/download/electron"
- },
- "dependencies": {
- "eventemitter2": "^4.1.0"
- },
- "devDependencies": {
- "chai": "^3.0.0",
- "chai-as-promised": "^5.1.0",
- "chalk": "^1.0.0",
- "mocha": "^2.2.5",
- "nan": "^2.12.1"
- }
-}
\ No newline at end of file
diff --git a/vendor/node-usb-native/src/combined.cpp b/vendor/node-usb-native/src/combined.cpp
deleted file mode 100644
index 28c3ec526..000000000
--- a/vendor/node-usb-native/src/combined.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-extern "C" {
- void init_serialport( v8::Local target);
-#ifndef DISABLE_USB_DETECTOR
- void init_detector( v8::Local target);
-#endif
- void initAll( v8::Local target) {
- init_serialport(target);
- #ifndef DISABLE_USB_DETECTOR
- init_detector(target);
- #endif
- }
-}
-
-NODE_MODULE(detection, initAll);
diff --git a/vendor/node-usb-native/src/detection.cpp b/vendor/node-usb-native/src/detection.cpp
deleted file mode 100644
index 13f7bdc6a..000000000
--- a/vendor/node-usb-native/src/detection.cpp
+++ /dev/null
@@ -1,222 +0,0 @@
-#include "detection.h"
-
-
-#define OBJECT_ITEM_LOCATION_ID "locationId"
-#define OBJECT_ITEM_VENDOR_ID "vendorId"
-#define OBJECT_ITEM_PRODUCT_ID "productId"
-#define OBJECT_ITEM_DEVICE_NAME "deviceName"
-#define OBJECT_ITEM_MANUFACTURER "manufacturer"
-#define OBJECT_ITEM_SERIAL_NUMBER "serialNumber"
-#define OBJECT_ITEM_DEVICE_ADDRESS "deviceAddress"
-
-
-Nan::Callback* addedCallback;
-bool isAddedRegistered = false;
-
-Nan::Callback* removedCallback;
-bool isRemovedRegistered = false;
-
-void RegisterAdded(const Nan::FunctionCallbackInfo& args) {
- Nan::HandleScope scope;
-
- v8::Local callback;
-
- if (args.Length() == 0) {
- return Nan::ThrowTypeError("First argument must be a function");
- }
-
- if (args.Length() == 1) {
- // callback
- if(!args[0]->IsFunction()) {
- return Nan::ThrowTypeError("First argument must be a function");
- }
-
- callback = args[0].As();
- }
-
- addedCallback = new Nan::Callback(callback);
- isAddedRegistered = true;
-}
-
-void NotifyAdded(ListResultItem_t* it) {
- Nan::HandleScope scope;
-
- if (it == NULL) {
- return;
- }
-
- if (isAddedRegistered){
- v8::Local argv[1];
- v8::Local item = Nan::New();
- item->Set(Nan::New(OBJECT_ITEM_LOCATION_ID).ToLocalChecked(), Nan::New(it->locationId));
- item->Set(Nan::New(OBJECT_ITEM_VENDOR_ID).ToLocalChecked(), Nan::New(it->vendorId));
- item->Set(Nan::New(OBJECT_ITEM_PRODUCT_ID).ToLocalChecked(), Nan::New(it->productId));
- item->Set(Nan::New(OBJECT_ITEM_DEVICE_NAME).ToLocalChecked(), Nan::New(it->deviceName.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_MANUFACTURER).ToLocalChecked(), Nan::New(it->manufacturer.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_SERIAL_NUMBER).ToLocalChecked(), Nan::New(it->serialNumber.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_DEVICE_ADDRESS).ToLocalChecked(), Nan::New(it->deviceAddress));
- argv[0] = item;
-
- addedCallback->Call(1, argv);
- }
-}
-
-void RegisterRemoved(const Nan::FunctionCallbackInfo& args) {
- Nan::HandleScope scope;
-
- v8::Local callback;
-
- if (args.Length() == 0) {
- return Nan::ThrowTypeError("First argument must be a function");
- }
-
- if (args.Length() == 1) {
- // callback
- if(!args[0]->IsFunction()) {
- return Nan::ThrowTypeError("First argument must be a function");
- }
-
- callback = args[0].As();
- }
-
- removedCallback = new Nan::Callback(callback);
- isRemovedRegistered = true;
-}
-
-void NotifyRemoved(ListResultItem_t* it) {
- Nan::HandleScope scope;
-
- if (it == NULL) {
- return;
- }
-
- if (isRemovedRegistered) {
- v8::Local argv[1];
- v8::Local item = Nan::New();
- item->Set(Nan::New(OBJECT_ITEM_LOCATION_ID).ToLocalChecked(), Nan::New(it->locationId));
- item->Set(Nan::New(OBJECT_ITEM_VENDOR_ID).ToLocalChecked(), Nan::New(it->vendorId));
- item->Set(Nan::New(OBJECT_ITEM_PRODUCT_ID).ToLocalChecked(), Nan::New(it->productId));
- item->Set(Nan::New(OBJECT_ITEM_DEVICE_NAME).ToLocalChecked(), Nan::New(it->deviceName.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_MANUFACTURER).ToLocalChecked(), Nan::New(it->manufacturer.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_SERIAL_NUMBER).ToLocalChecked(), Nan::New(it->serialNumber.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_DEVICE_ADDRESS).ToLocalChecked(), Nan::New(it->deviceAddress));
- argv[0] = item;
-
- removedCallback->Call(1, argv);
- }
-}
-
-void Find(const Nan::FunctionCallbackInfo& args) {
- Nan::HandleScope scope;
-
- int vid = 0;
- int pid = 0;
- v8::Local callback;
-
- if (args.Length() == 0) {
- return Nan::ThrowTypeError("First argument must be a function");
- }
-
- if (args.Length() == 3) {
- if (args[0]->IsNumber() && args[1]->IsNumber()) {
- vid = (int) args[0]->NumberValue();
- pid = (int) args[1]->NumberValue();
- }
-
- // callback
- if(!args[2]->IsFunction()) {
- return Nan::ThrowTypeError("Third argument must be a function");
- }
-
- callback = args[2].As();
- }
-
- if (args.Length() == 2) {
- if (args[0]->IsNumber()) {
- vid = (int) args[0]->NumberValue();
- }
-
- // callback
- if(!args[1]->IsFunction()) {
- return Nan::ThrowTypeError("Second argument must be a function");
- }
-
- callback = args[1].As();
- }
-
- if (args.Length() == 1) {
- // callback
- if(!args[0]->IsFunction()) {
- return Nan::ThrowTypeError("First argument must be a function");
- }
-
- callback = args[0].As();
- }
-
- ListBaton* baton = new ListBaton();
- strcpy(baton->errorString, "");
- baton->callback = new Nan::Callback(callback);
- baton->vid = vid;
- baton->pid = pid;
-
- uv_work_t* req = new uv_work_t();
- req->data = baton;
- uv_queue_work(uv_default_loop(), req, EIO_Find, (uv_after_work_cb)EIO_AfterFind);
-}
-
-void EIO_AfterFind(uv_work_t* req) {
- Nan::HandleScope scope;
-
- ListBaton* data = static_cast(req->data);
-
- v8::Local argv[2];
- if(data->errorString[0]) {
- argv[0] = v8::Exception::Error(Nan::New(data->errorString).ToLocalChecked());
- argv[1] = Nan::Undefined();
- }
- else {
- v8::Local results = Nan::New();
- int i = 0;
- for(std::list::iterator it = data->results.begin(); it != data->results.end(); it++, i++) {
- v8::Local item = Nan::New();
- item->Set(Nan::New(OBJECT_ITEM_LOCATION_ID).ToLocalChecked(), Nan::New((*it)->locationId));
- item->Set(Nan::New(OBJECT_ITEM_VENDOR_ID).ToLocalChecked(), Nan::New((*it)->vendorId));
- item->Set(Nan::New(OBJECT_ITEM_PRODUCT_ID).ToLocalChecked(), Nan::New((*it)->productId));
- item->Set(Nan::New(OBJECT_ITEM_DEVICE_NAME).ToLocalChecked(), Nan::New((*it)->deviceName.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_MANUFACTURER).ToLocalChecked(), Nan::New((*it)->manufacturer.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_SERIAL_NUMBER).ToLocalChecked(), Nan::New((*it)->serialNumber.c_str()).ToLocalChecked());
- item->Set(Nan::New(OBJECT_ITEM_DEVICE_ADDRESS).ToLocalChecked(), Nan::New((*it)->deviceAddress));
- results->Set(i, item);
- }
- argv[0] = Nan::Undefined();
- argv[1] = results;
- }
-
- data->callback->Call(2, argv);
-
- for(std::list::iterator it = data->results.begin(); it != data->results.end(); it++) {
- delete *it;
- }
- delete data;
- delete req;
-}
-
-void StartMonitoring(const Nan::FunctionCallbackInfo& args) {
- Start();
-}
-
-void StopMonitoring(const Nan::FunctionCallbackInfo& args) {
- Stop();
-}
-
-extern "C" {
- void init_detector ( v8::Local target) {
- Nan::SetMethod(target, "find", Find);
- Nan::SetMethod(target, "registerAdded", RegisterAdded);
- Nan::SetMethod(target, "registerRemoved", RegisterRemoved);
- Nan::SetMethod(target, "startMonitoring", StartMonitoring);
- Nan::SetMethod(target, "stopMonitoring", StopMonitoring);
- InitDetection();
-
- }
-}
\ No newline at end of file
diff --git a/vendor/node-usb-native/src/detection.h b/vendor/node-usb-native/src/detection.h
deleted file mode 100644
index dbcf672cd..000000000
--- a/vendor/node-usb-native/src/detection.h
+++ /dev/null
@@ -1,42 +0,0 @@
-
-#ifndef _USB_DETECTION_H
-#define _USB_DETECTION_H
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include "deviceList.h"
-
-void Find(const Nan::FunctionCallbackInfo& args);
-void EIO_Find(uv_work_t* req);
-void EIO_AfterFind(uv_work_t* req);
-void InitDetection();
-void StartMonitoring(const Nan::FunctionCallbackInfo& args);
-void Start();
-void StopMonitoring(const Nan::FunctionCallbackInfo& args);
-void Stop();
-
-
-struct ListBaton {
- public:
- //v8::Persistent callback;
- Nan::Callback* callback;
- std::list results;
- char errorString[1024];
- int vid;
- int pid;
-};
-
-void RegisterAdded(const Nan::FunctionCallbackInfo& args);
-void NotifyAdded(ListResultItem_t* it);
-void RegisterRemoved(const Nan::FunctionCallbackInfo& args);
-void NotifyRemoved(ListResultItem_t* it);
-
-#endif
diff --git a/vendor/node-usb-native/src/detection_linux.cpp b/vendor/node-usb-native/src/detection_linux.cpp
deleted file mode 100644
index 4c23877ce..000000000
--- a/vendor/node-usb-native/src/detection_linux.cpp
+++ /dev/null
@@ -1,317 +0,0 @@
-#include
-#include
-
-#include "detection.h"
-#include "deviceList.h"
-
-using namespace std;
-
-
-
-/**********************************
- * Local defines
- **********************************/
-#define DEVICE_ACTION_ADDED "add"
-#define DEVICE_ACTION_REMOVED "remove"
-
-#define DEVICE_TYPE_DEVICE "usb_device"
-
-#define DEVICE_PROPERTY_NAME "ID_MODEL"
-#define DEVICE_PROPERTY_SERIAL "ID_SERIAL_SHORT"
-#define DEVICE_PROPERTY_VENDOR "ID_VENDOR"
-
-
-/**********************************
- * Local typedefs
- **********************************/
-
-
-
-/**********************************
- * Local Variables
- **********************************/
-ListResultItem_t* currentItem;
-bool isAdded;
-
-struct udev *udev;
-struct udev_enumerate *enumerate;
-struct udev_list_entry *devices, *dev_list_entry;
-struct udev_device *dev;
-
-struct udev_monitor *mon;
-int fd;
-
-pthread_t thread;
-pthread_mutex_t notify_mutex;
-pthread_cond_t notifyNewDevice;
-pthread_cond_t notifyDeviceHandled;
-
-bool newDeviceAvailable = false;
-bool deviceHandled = true;
-
-bool isRunning = false;
-/**********************************
- * Local Helper Functions protoypes
- **********************************/
-void BuildInitialDeviceList();
-
-void* ThreadFunc(void* ptr);
-void WaitForDeviceHandled();
-void SignalDeviceHandled();
-void WaitForNewDevice();
-void SignalDeviceAvailable();
-
-/**********************************
- * Public Functions
- **********************************/
-void NotifyAsync(uv_work_t* req) {
- WaitForNewDevice();
-}
-
-void NotifyFinished(uv_work_t* req) {
- if (isRunning) {
- if (isAdded) {
- NotifyAdded(currentItem);
- }
- else {
- NotifyRemoved(currentItem);
- }
- }
-
- // Delete Item in case of removal
- if(isAdded == false) {
- delete currentItem;
- }
-
- SignalDeviceHandled();
- uv_queue_work(uv_default_loop(), req, NotifyAsync, (uv_after_work_cb)NotifyFinished);
-}
-
-void Start() {
- isRunning = true;
-}
-
-void Stop() {
- isRunning = false;
- pthread_mutex_lock(¬ify_mutex);
- pthread_cond_signal(¬ifyNewDevice);
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void InitDetection() {
- /* Create the udev object */
- udev = udev_new();
- if (!udev)
- {
- printf("Can't create udev\n");
- return;
- }
-
- /* Set up a monitor to monitor devices */
- mon = udev_monitor_new_from_netlink(udev, "udev");
- udev_monitor_enable_receiving(mon);
-
- /* Get the file descriptor (fd) for the monitor.
- This fd will get passed to select() */
- fd = udev_monitor_get_fd(mon);
-
- BuildInitialDeviceList();
-
- pthread_mutex_init(¬ify_mutex, NULL);
- pthread_cond_init(¬ifyNewDevice, NULL);
- pthread_cond_init(¬ifyDeviceHandled, NULL);
-
- uv_work_t* req = new uv_work_t();
- uv_queue_work(uv_default_loop(), req, NotifyAsync, (uv_after_work_cb)NotifyFinished);
-
- pthread_create(&thread, NULL, ThreadFunc, NULL);
-
- Start();
-}
-
-
-void EIO_Find(uv_work_t* req) {
- ListBaton* data = static_cast(req->data);
-
- CreateFilteredList(&data->results, data->vid, data->pid);
-}
-
-/**********************************
- * Local Functions
- **********************************/
-void WaitForDeviceHandled() {
- pthread_mutex_lock(¬ify_mutex);
- if(deviceHandled == false) {
- pthread_cond_wait(¬ifyDeviceHandled, ¬ify_mutex);
- }
- deviceHandled = false;
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void SignalDeviceHandled() {
- pthread_mutex_lock(¬ify_mutex);
- deviceHandled = true;
- pthread_cond_signal(¬ifyDeviceHandled);
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void WaitForNewDevice() {
- pthread_mutex_lock(¬ify_mutex);
- if(newDeviceAvailable == false){
- pthread_cond_wait(¬ifyNewDevice, ¬ify_mutex);
- }
- newDeviceAvailable = false;
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void SignalDeviceAvailable() {
- pthread_mutex_lock(¬ify_mutex);
- newDeviceAvailable = true;
- pthread_cond_signal(¬ifyNewDevice);
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-
- ListResultItem_t* GetProperties(struct udev_device* dev, ListResultItem_t* item) {
- struct udev_list_entry* sysattrs;
- struct udev_list_entry* entry;
- sysattrs = udev_device_get_properties_list_entry(dev);
- udev_list_entry_foreach(entry, sysattrs) {
- const char *name, *value;
- name = udev_list_entry_get_name(entry);
- value = udev_list_entry_get_value(entry);
-
- if(strcmp(name, DEVICE_PROPERTY_NAME) == 0) {
- item->deviceName = value;
- }
- else if(strcmp(name, DEVICE_PROPERTY_SERIAL) == 0) {
- item->serialNumber = value;
- }
- else if(strcmp(name, DEVICE_PROPERTY_VENDOR) == 0) {
- item->manufacturer = value;
- }
- }
- item->vendorId = strtol(udev_device_get_sysattr_value(dev,"idVendor"), NULL, 16);
- item->productId = strtol(udev_device_get_sysattr_value(dev,"idProduct"), NULL, 16);
- item->deviceAddress = 0;
- item->locationId = 0;
-
- return item;
-}
-
-void DeviceAdded(struct udev_device* dev) {
- DeviceItem_t* item = new DeviceItem_t();
- GetProperties(dev, &item->deviceParams);
-
- AddItemToList((char *)udev_device_get_devnode(dev), item);
-
- currentItem = &item->deviceParams;
- isAdded = true;
-
- SignalDeviceAvailable();
-}
-
-void DeviceRemoved(struct udev_device* dev) {
- ListResultItem_t* item = NULL;
-
- if(IsItemAlreadyStored((char *)udev_device_get_devnode(dev))) {
- DeviceItem_t* deviceItem = GetItemFromList((char *)udev_device_get_devnode(dev));
- if(deviceItem) {
- item = CopyElement(&deviceItem->deviceParams);
- }
- RemoveItemFromList(deviceItem);
- delete deviceItem;
- }
-
- if(item == NULL) {
- item = new ListResultItem_t();
- GetProperties(dev, item);
- }
-
- currentItem = item;
- isAdded = false;
-
- SignalDeviceAvailable();
-}
-
-
-void* ThreadFunc(void* ptr) {
- while (1) {
- /* Make the call to receive the device.
- select() ensured that this will not block. */
- dev = udev_monitor_receive_device(mon);
- if (dev) {
- if(udev_device_get_devtype(dev) && strcmp(udev_device_get_devtype(dev), DEVICE_TYPE_DEVICE) == 0) {
- if(strcmp(udev_device_get_action(dev), DEVICE_ACTION_ADDED) == 0) {
- WaitForDeviceHandled();
- DeviceAdded(dev);
- }
- else if(strcmp(udev_device_get_action(dev), DEVICE_ACTION_REMOVED) == 0) {
- WaitForDeviceHandled();
- DeviceRemoved(dev);
- }
- }
- udev_device_unref(dev);
- }
- }
-
- return NULL;
-}
-
-
-void BuildInitialDeviceList() {
- /* Create a list of the devices */
- enumerate = udev_enumerate_new(udev);
- udev_enumerate_scan_devices(enumerate);
- devices = udev_enumerate_get_list_entry(enumerate);
- /* For each item enumerated, print out its information.
- udev_list_entry_foreach is a macro which expands to
- a loop. The loop will be executed for each member in
- devices, setting dev_list_entry to a list entry
- which contains the device's path in /sys. */
- udev_list_entry_foreach(dev_list_entry, devices) {
- const char *path;
-
- /* Get the filename of the /sys entry for the device
- and create a udev_device object (dev) representing it */
- path = udev_list_entry_get_name(dev_list_entry);
- dev = udev_device_new_from_syspath(udev, path);
-
- /* usb_device_get_devnode() returns the path to the device node
- itself in /dev. */
- if(udev_device_get_devnode(dev) == NULL || udev_device_get_sysattr_value(dev,"idVendor") == NULL) {
- continue;
- }
-
- /* From here, we can call get_sysattr_value() for each file
- in the device's /sys entry. The strings passed into these
- functions (idProduct, idVendor, serial, etc.) correspond
- directly to the files in the /sys directory which
- represents the USB device. Note that USB strings are
- Unicode, UCS2 encoded, but the strings returned from
- udev_device_get_sysattr_value() are UTF-8 encoded. */
-
- DeviceItem_t* item = new DeviceItem_t();
- item->deviceParams.vendorId = strtol (udev_device_get_sysattr_value(dev,"idVendor"), NULL, 16);
- item->deviceParams.productId = strtol (udev_device_get_sysattr_value(dev,"idProduct"), NULL, 16);
- if(udev_device_get_sysattr_value(dev,"product") != NULL) {
- item->deviceParams.deviceName = udev_device_get_sysattr_value(dev,"product");
- }
- if(udev_device_get_sysattr_value(dev,"manufacturer") != NULL) {
- item->deviceParams.manufacturer = udev_device_get_sysattr_value(dev,"manufacturer");
- }
- if(udev_device_get_sysattr_value(dev,"serial") != NULL) {
- item->deviceParams.serialNumber = udev_device_get_sysattr_value(dev, "serial");
- }
- item->deviceParams.deviceAddress = 0;
- item->deviceParams.locationId = 0;
-
- item->deviceState = DeviceState_Connect;
-
- AddItemToList((char *)udev_device_get_devnode(dev), item);
-
- udev_device_unref(dev);
- }
- /* Free the enumerator object */
- udev_enumerate_unref(enumerate);
-}
diff --git a/vendor/node-usb-native/src/detection_mac.cpp b/vendor/node-usb-native/src/detection_mac.cpp
deleted file mode 100644
index bcdfbef31..000000000
--- a/vendor/node-usb-native/src/detection_mac.cpp
+++ /dev/null
@@ -1,461 +0,0 @@
-#include "detection.h"
-#include "deviceList.h"
-
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-
-#include
-
-
-typedef struct DeviceListItem {
- io_object_t notification;
- IOUSBDeviceInterface** deviceInterface;
- DeviceItem_t* deviceItem;
-} stDeviceListItem;
-
-static IONotificationPortRef gNotifyPort;
-static io_iterator_t gAddedIter;
-static CFRunLoopRef gRunLoop;
-
-
-CFMutableDictionaryRef matchingDict;
-CFRunLoopSourceRef runLoopSource;
-
-static pthread_t lookupThread;
-
-pthread_mutex_t notify_mutex;
-pthread_cond_t notifyNewDevice;
-pthread_cond_t notifyDeviceHandled;
-
-bool newDeviceAvailable = false;
-bool deviceHandled = true;
-
-ListResultItem_t* notify_item;
-bool isAdded = false;
-bool isRunning = false;
-bool intialDeviceImport = true;
-
-void WaitForDeviceHandled();
-void SignalDeviceHandled();
-void WaitForNewDevice();
-void SignalDeviceAvailable();
-
-//================================================================================================
-//
-// DeviceRemoved
-//
-// This routine will get called whenever any kIOGeneralInterest notification happens. We are
-// interested in the kIOMessageServiceIsTerminated message so that's what we look for. Other
-// messages are defined in IOMessage.h.
-//
-//================================================================================================
-void DeviceRemoved(void *refCon, io_service_t service, natural_t messageType, void *messageArgument) {
- kern_return_t kr;
- stDeviceListItem* deviceListItem = (stDeviceListItem *) refCon;
- DeviceItem_t* deviceItem = deviceListItem->deviceItem;
-
- if(messageType == kIOMessageServiceIsTerminated) {
- if(deviceListItem->deviceInterface) {
- kr = (*deviceListItem->deviceInterface)->Release(deviceListItem->deviceInterface);
- }
-
- kr = IOObjectRelease(deviceListItem->notification);
-
-
- ListResultItem_t* item = NULL;
- if(deviceItem) {
- item = CopyElement(&deviceItem->deviceParams);
- RemoveItemFromList(deviceItem);
- delete deviceItem;
- }
- else {
- item = new ListResultItem_t();
- }
-
- WaitForDeviceHandled();
- notify_item = item;
- isAdded = false;
- SignalDeviceAvailable();
-
- }
-}
-
-//================================================================================================
-//
-// DeviceAdded
-//
-// This routine is the callback for our IOServiceAddMatchingNotification. When we get called
-// we will look at all the devices that were added and we will:
-//
-// 1. Create some private data to relate to each device (in this case we use the service's name
-// and the location ID of the device
-// 2. Submit an IOServiceAddInterestNotification of type kIOGeneralInterest for this device,
-// using the refCon field to store a pointer to our private data. When we get called with
-// this interest notification, we can grab the refCon and access our private data.
-//
-//================================================================================================
-void DeviceAdded(void *refCon, io_iterator_t iterator) {
- kern_return_t kr;
- io_service_t usbDevice;
- IOCFPlugInInterface **plugInInterface = NULL;
- SInt32 score;
- HRESULT res;
-
- while((usbDevice = IOIteratorNext(iterator))) {
- io_name_t deviceName;
- CFStringRef deviceNameAsCFString;
- UInt32 locationID;
- UInt16 vendorId;
- UInt16 productId;
- UInt16 addr;
-
- DeviceItem_t* deviceItem = new DeviceItem_t();
-
- // Get the USB device's name.
- kr = IORegistryEntryGetName(usbDevice, deviceName);
- if(KERN_SUCCESS != kr) {
- deviceName[0] = '\0';
- }
-
- deviceNameAsCFString = CFStringCreateWithCString(kCFAllocatorDefault, deviceName, kCFStringEncodingASCII);
-
-
- if(deviceNameAsCFString) {
- Boolean result;
- char deviceName[MAXPATHLEN];
-
- // Convert from a CFString to a C (NUL-terminated)
- result = CFStringGetCString(deviceNameAsCFString,
- deviceName,
- sizeof(deviceName),
- kCFStringEncodingUTF8);
-
- if(result) {
- deviceItem->deviceParams.deviceName = deviceName;
- }
-
- CFRelease(deviceNameAsCFString);
- }
-
- CFStringRef manufacturerAsCFString = (CFStringRef)IORegistryEntrySearchCFProperty(
- usbDevice,
- kIOServicePlane,
- CFSTR(kUSBVendorString),
- kCFAllocatorDefault,
- kIORegistryIterateRecursively
- );
-
- if(manufacturerAsCFString) {
- Boolean result;
- char manufacturer[MAXPATHLEN];
-
- // Convert from a CFString to a C (NUL-terminated)
- result = CFStringGetCString(
- manufacturerAsCFString,
- manufacturer,
- sizeof(manufacturer),
- kCFStringEncodingUTF8
- );
-
- if(result) {
- deviceItem->deviceParams.manufacturer = manufacturer;
- }
-
- CFRelease(manufacturerAsCFString);
- }
-
- CFStringRef serialNumberAsCFString = (CFStringRef) IORegistryEntrySearchCFProperty(
- usbDevice,
- kIOServicePlane,
- CFSTR(kUSBSerialNumberString),
- kCFAllocatorDefault,
- kIORegistryIterateRecursively
- );
-
- if(serialNumberAsCFString) {
- Boolean result;
- char serialNumber[MAXPATHLEN];
-
- // Convert from a CFString to a C (NUL-terminated)
- result = CFStringGetCString(
- serialNumberAsCFString,
- serialNumber,
- sizeof(serialNumber),
- kCFStringEncodingUTF8
- );
-
- if(result) {
- deviceItem->deviceParams.serialNumber = serialNumber;
- }
-
- CFRelease(serialNumberAsCFString);
- }
-
-
- // Now, get the locationID of this device. In order to do this, we need to create an IOUSBDeviceInterface
- // for our device. This will create the necessary connections between our userland application and the
- // kernel object for the USB Device.
- kr = IOCreatePlugInInterfaceForService(usbDevice, kIOUSBDeviceUserClientTypeID, kIOCFPlugInInterfaceID, &plugInInterface, &score);
-
- if((kIOReturnSuccess != kr) || !plugInInterface) {
- fprintf(stderr, "IOCreatePlugInInterfaceForService returned 0x%08x.\n", kr);
- continue;
- }
-
- stDeviceListItem *deviceListItem = new stDeviceListItem();
-
- // Use the plugin interface to retrieve the device interface.
- res = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID*) &deviceListItem->deviceInterface);
-
- // Now done with the plugin interface.
- (*plugInInterface)->Release(plugInInterface);
-
- if(res || deviceListItem->deviceInterface == NULL) {
- fprintf(stderr, "QueryInterface returned %d.\n", (int) res);
- continue;
- }
-
- // Now that we have the IOUSBDeviceInterface, we can call the routines in IOUSBLib.h.
- // In this case, fetch the locationID. The locationID uniquely identifies the device
- // and will remain the same, even across reboots, so long as the bus topology doesn't change.
-
- kr = (*deviceListItem->deviceInterface)->GetLocationID(deviceListItem->deviceInterface, &locationID);
- if(KERN_SUCCESS != kr) {
- fprintf(stderr, "GetLocationID returned 0x%08x.\n", kr);
- continue;
- }
- deviceItem->deviceParams.locationId = locationID;
-
-
- kr = (*deviceListItem->deviceInterface)->GetDeviceAddress(deviceListItem->deviceInterface, &addr);
- if(KERN_SUCCESS != kr) {
- fprintf(stderr, "GetDeviceAddress returned 0x%08x.\n", kr);
- continue;
- }
- deviceItem->deviceParams.deviceAddress = addr;
-
-
- kr = (*deviceListItem->deviceInterface)->GetDeviceVendor(deviceListItem->deviceInterface, &vendorId);
- if(KERN_SUCCESS != kr) {
- fprintf(stderr, "GetDeviceVendor returned 0x%08x.\n", kr);
- continue;
- }
- deviceItem->deviceParams.vendorId = vendorId;
-
- kr = (*deviceListItem->deviceInterface)->GetDeviceProduct(deviceListItem->deviceInterface, &productId);
- if(KERN_SUCCESS != kr) {
- fprintf(stderr, "GetDeviceProduct returned 0x%08x.\n", kr);
- continue;
- }
- deviceItem->deviceParams.productId = productId;
-
-
- // Extract path name as unique key
- io_string_t pathName;
- IORegistryEntryGetPath(usbDevice, kIOServicePlane, pathName);
- deviceNameAsCFString = CFStringCreateWithCString(kCFAllocatorDefault, pathName, kCFStringEncodingASCII);
- char cPathName[MAXPATHLEN];
-
- if(deviceNameAsCFString) {
- Boolean result;
-
- // Convert from a CFString to a C (NUL-terminated)
- result = CFStringGetCString(
- deviceNameAsCFString,
- cPathName,
- sizeof(cPathName),
- kCFStringEncodingUTF8
- );
-
-
- CFRelease(deviceNameAsCFString);
- }
-
- AddItemToList(cPathName, deviceItem);
- deviceListItem->deviceItem = deviceItem;
-
- if(intialDeviceImport == false) {
- WaitForDeviceHandled();
- notify_item = &deviceItem->deviceParams;
- isAdded = true;
- SignalDeviceAvailable();
- }
-
- // Register for an interest notification of this device being removed. Use a reference to our
- // private data as the refCon which will be passed to the notification callback.
- kr = IOServiceAddInterestNotification(
- gNotifyPort, // notifyPort
- usbDevice, // service
- kIOGeneralInterest, // interestType
- DeviceRemoved, // callback
- deviceListItem, // refCon
- &(deviceListItem->notification) // notification
- );
-
- if(KERN_SUCCESS != kr) {
- printf("IOServiceAddInterestNotification returned 0x%08x.\n", kr);
- }
-
- // Done with this USB device; release the reference added by IOIteratorNext
- kr = IOObjectRelease(usbDevice);
- }
-}
-
-
-void WaitForDeviceHandled() {
- pthread_mutex_lock(¬ify_mutex);
- if(deviceHandled == false) {
- pthread_cond_wait(¬ifyDeviceHandled, ¬ify_mutex);
- }
- deviceHandled = false;
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void SignalDeviceHandled() {
- pthread_mutex_lock(¬ify_mutex);
- deviceHandled = true;
- pthread_cond_signal(¬ifyDeviceHandled);
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void WaitForNewDevice() {
- pthread_mutex_lock(¬ify_mutex);
- if(newDeviceAvailable == false) {
- pthread_cond_wait(¬ifyNewDevice, ¬ify_mutex);
- }
- newDeviceAvailable = false;
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void SignalDeviceAvailable() {
- pthread_mutex_lock(¬ify_mutex);
- newDeviceAvailable = true;
- pthread_cond_signal(¬ifyNewDevice);
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-
-void *RunLoop(void * arg) {
-
- runLoopSource = IONotificationPortGetRunLoopSource(gNotifyPort);
-
- gRunLoop = CFRunLoopGetCurrent();
- CFRunLoopAddSource(gRunLoop, runLoopSource, kCFRunLoopDefaultMode);
-
- // Start the run loop. Now we'll receive notifications.
- CFRunLoopRun();
-
- // We should never get here
- fprintf(stderr, "Unexpectedly back from CFRunLoopRun()!\n");
-
- return NULL;
-}
-
-void NotifyAsync(uv_work_t* req) {
- WaitForNewDevice();
-}
-
-void NotifyFinished(uv_work_t* req) {
- if(isRunning) {
- if(isAdded) {
- NotifyAdded(notify_item);
- }
- else {
- NotifyRemoved(notify_item);
- }
- }
-
- // Delete Item in case of removal
- if(isAdded == false) {
- delete notify_item;
- }
-
- if(isRunning) {
- uv_queue_work(uv_default_loop(), req, NotifyAsync, (uv_after_work_cb)NotifyFinished);
- }
- SignalDeviceHandled();
-}
-
-void Start() {
- isRunning = true;
-}
-
-void Stop() {
- isRunning = false;
- pthread_mutex_lock(¬ify_mutex);
- pthread_cond_signal(¬ifyNewDevice);
- pthread_mutex_unlock(¬ify_mutex);
-}
-
-void InitDetection() {
-
- kern_return_t kr;
-
- // Set up the matching criteria for the devices we're interested in. The matching criteria needs to follow
- // the same rules as kernel drivers: mainly it needs to follow the USB Common Class Specification, pp. 6-7.
- // See also Technical Q&A QA1076 "Tips on USB driver matching on Mac OS X"
- // .
- // One exception is that you can use the matching dictionary "as is", i.e. without adding any matching
- // criteria to it and it will match every IOUSBDevice in the system. IOServiceAddMatchingNotification will
- // consume this dictionary reference, so there is no need to release it later on.
-
- // Interested in instances of class
- // IOUSBDevice and its subclasses
- matchingDict = IOServiceMatching(kIOUSBDeviceClassName);
-
- if (matchingDict == NULL) {
- fprintf(stderr, "IOServiceMatching returned NULL.\n");
- }
-
- // Create a notification port and add its run loop event source to our run loop
- // This is how async notifications get set up.
-
- gNotifyPort = IONotificationPortCreate(kIOMasterPortDefault);
-
- // Now set up a notification to be called when a device is first matched by I/O Kit.
- kr = IOServiceAddMatchingNotification(
- gNotifyPort, // notifyPort
- kIOFirstMatchNotification, // notificationType
- matchingDict, // matching
- DeviceAdded, // callback
- NULL, // refCon
- &gAddedIter // notification
- );
-
- if (KERN_SUCCESS != kr) {
- printf("IOServiceAddMatchingNotification returned 0x%08x.\n", kr);
- }
-
- // Iterate once to get already-present devices and arm the notification
- DeviceAdded(NULL, gAddedIter);
- intialDeviceImport = false;
-
-
- pthread_mutex_init(¬ify_mutex, NULL);
- pthread_cond_init(¬ifyNewDevice, NULL);
- pthread_cond_init(¬ifyDeviceHandled, NULL);
-
- int rc = pthread_create(&lookupThread, NULL, RunLoop, NULL);
- if (rc) {
- printf("ERROR; return code from pthread_create() is %d\n", rc);
- exit(-1);
- }
-
- uv_work_t* req = new uv_work_t();
- uv_queue_work(uv_default_loop(), req, NotifyAsync, (uv_after_work_cb)NotifyFinished);
-
- Start();
-}
-
-void EIO_Find(uv_work_t* req) {
- ListBaton* data = static_cast(req->data);
-
- CreateFilteredList(&data->results, data->vid, data->pid);
-}
diff --git a/vendor/node-usb-native/src/detection_win.cpp b/vendor/node-usb-native/src/detection_win.cpp
deleted file mode 100644
index 4d6645960..000000000
--- a/vendor/node-usb-native/src/detection_win.cpp
+++ /dev/null
@@ -1,471 +0,0 @@
-#include
-#include
-#include
-#include
-#include
-
-
-// Include Windows headers
-#include
-#include
-#include
-#include
-#include
-
-#include "detection.h"
-#include "deviceList.h"
-
-using namespace std;
-
-/**********************************
- * Local defines
- **********************************/
-#define VID_TAG "VID_"
-#define PID_TAG "PID_"
-
-#define LIBRARY_NAME ("setupapi.dll")
-
-
-#define DllImport __declspec(dllimport)
-
-#define MAX_THREAD_WINDOW_NAME 64
-
-/**********************************
- * Local typedefs
- **********************************/
-
-
-
-/**********************************
- * Local Variables
- **********************************/
-GUID GUID_DEVINTERFACE_USB_DEVICE = {
- 0xA5DCBF10L,
- 0x6530,
- 0x11D2,
- 0x90,
- 0x1F,
- 0x00,
- 0xC0,
- 0x4F,
- 0xB9,
- 0x51,
- 0xED
-};
-
-HWND handle;
-DWORD threadId;
-HANDLE threadHandle;
-
-HANDLE deviceChangedRegisteredEvent;
-HANDLE deviceChangedSentEvent;
-
-ListResultItem_t* currentDevice;
-bool isAdded;
-bool isRunning = false;
-
-HINSTANCE hinstLib;
-
-
-typedef BOOL (WINAPI *_SetupDiEnumDeviceInfo) (HDEVINFO DeviceInfoSet, DWORD MemberIndex, PSP_DEVINFO_DATA DeviceInfoData);
-typedef HDEVINFO (WINAPI *_SetupDiGetClassDevs) (const GUID *ClassGuid, PCTSTR Enumerator, HWND hwndParent, DWORD Flags);
-typedef BOOL (WINAPI *_SetupDiDestroyDeviceInfoList) (HDEVINFO DeviceInfoSet);
-typedef BOOL (WINAPI *_SetupDiGetDeviceInstanceId) (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, PTSTR DeviceInstanceId, DWORD DeviceInstanceIdSize, PDWORD RequiredSize);
-typedef BOOL (WINAPI *_SetupDiGetDeviceRegistryProperty) (HDEVINFO DeviceInfoSet, PSP_DEVINFO_DATA DeviceInfoData, DWORD Property, PDWORD PropertyRegDataType, PBYTE PropertyBuffer, DWORD PropertyBufferSize, PDWORD RequiredSize);
-
-
-_SetupDiEnumDeviceInfo DllSetupDiEnumDeviceInfo;
-_SetupDiGetClassDevs DllSetupDiGetClassDevs;
-_SetupDiDestroyDeviceInfoList DllSetupDiDestroyDeviceInfoList;
-_SetupDiGetDeviceInstanceId DllSetupDiGetDeviceInstanceId;
-_SetupDiGetDeviceRegistryProperty DllSetupDiGetDeviceRegistryProperty;
-
-
-/**********************************
- * Local Helper Functions protoypes
- **********************************/
-void UpdateDevice(PDEV_BROADCAST_DEVICEINTERFACE pDevInf, WPARAM wParam, DeviceState_t state);
-DWORD WINAPI ListenerThread(LPVOID lpParam);
-
-void BuildInitialDeviceList();
-
-void NotifyAsync(uv_work_t* req);
-void NotifyFinished(uv_work_t* req);
-
-void ExtractDeviceInfo(HDEVINFO hDevInfo, SP_DEVINFO_DATA* pspDevInfoData, TCHAR* buf, DWORD buffSize, ListResultItem_t* resultItem);
-bool CheckValidity(ListResultItem_t* item);
-
-
-/**********************************
- * Public Functions
- **********************************/
-void NotifyAsync(uv_work_t* req) {
- WaitForSingleObject(deviceChangedRegisteredEvent, INFINITE);
-}
-
-
-void NotifyFinished(uv_work_t* req) {
- if (isRunning) {
- if(isAdded) {
- NotifyAdded(currentDevice);
- }
- else {
- NotifyRemoved(currentDevice);
- }
- }
-
- // Delete Item in case of removal
- if(isAdded == false) {
- delete currentDevice;
- }
-
- SetEvent(deviceChangedSentEvent);
-
- currentDevice = NULL;
- uv_queue_work(uv_default_loop(), req, NotifyAsync, (uv_after_work_cb)NotifyFinished);
-}
-
-void LoadFunctions() {
-
- bool success;
-
- hinstLib = LoadLibrary(LIBRARY_NAME);
-
- if (hinstLib != NULL) {
- DllSetupDiEnumDeviceInfo = (_SetupDiEnumDeviceInfo) GetProcAddress(hinstLib, "SetupDiEnumDeviceInfo");
-
- DllSetupDiGetClassDevs = (_SetupDiGetClassDevs) GetProcAddress(hinstLib, "SetupDiGetClassDevsA");
-
- DllSetupDiDestroyDeviceInfoList = (_SetupDiDestroyDeviceInfoList) GetProcAddress(hinstLib, "SetupDiDestroyDeviceInfoList");
-
- DllSetupDiGetDeviceInstanceId = (_SetupDiGetDeviceInstanceId) GetProcAddress(hinstLib, "SetupDiGetDeviceInstanceIdA");
-
- DllSetupDiGetDeviceRegistryProperty = (_SetupDiGetDeviceRegistryProperty) GetProcAddress(hinstLib, "SetupDiGetDeviceRegistryPropertyA");
-
- success = (
- DllSetupDiEnumDeviceInfo != NULL &&
- DllSetupDiGetClassDevs != NULL &&
- DllSetupDiDestroyDeviceInfoList != NULL &&
- DllSetupDiGetDeviceInstanceId != NULL &&
- DllSetupDiGetDeviceRegistryProperty != NULL
- );
- }
- else {
- success = false;
- }
-
- if(!success) {
- printf("Could not load library functions from dll -> abort (Check if %s is available)\r\n", LIBRARY_NAME);
- exit(1);
- }
-}
-
-void Start() {
- isRunning = true;
-}
-
-void Stop() {
- isRunning = false;
- SetEvent(deviceChangedRegisteredEvent);
-}
-
-void InitDetection() {
-
- LoadFunctions();
-
- deviceChangedRegisteredEvent = CreateEvent(NULL, false /* auto-reset event */, false /* non-signalled state */, "");
- deviceChangedSentEvent = CreateEvent(NULL, false /* auto-reset event */, true /* non-signalled state */, "");
-
- BuildInitialDeviceList();
-
- threadHandle = CreateThread(
- NULL, // default security attributes
- 0, // use default stack size
- ListenerThread, // thread function name
- NULL, // argument to thread function
- 0, // use default creation flags
- &threadId
- );
-
- uv_work_t* req = new uv_work_t();
- uv_queue_work(uv_default_loop(), req, NotifyAsync, (uv_after_work_cb)NotifyFinished);
-
- Start();
-}
-
-
-void EIO_Find(uv_work_t* req) {
-
- ListBaton* data = static_cast(req->data);
-
- CreateFilteredList(&data->results, data->vid, data->pid);
-}
-
-
-/**********************************
- * Local Functions
- **********************************/
-void ToUpper(char * buf) {
- char* c = buf;
- while (*c != '\0') {
- *c = toupper((unsigned char)*c);
- c++;
- }
-}
-
-
-void extractVidPid(char * buf, ListResultItem_t * item) {
- if(buf == NULL) {
- return;
- }
-
- ToUpper(buf);
-
- char* string;
- char* temp;
- char* pidStr, *vidStr;
- int vid = 0;
- int pid = 0;
-
- string = new char[strlen(buf) + 1];
- memcpy(string, buf, strlen(buf) + 1);
-
- vidStr = strstr(string, VID_TAG);
- pidStr = strstr(string, PID_TAG);
-
- if(vidStr != NULL) {
- temp = (char*) (vidStr + strlen(VID_TAG));
- temp[4] = '\0';
- vid = strtol (temp, NULL, 16);
- }
-
- if(pidStr != NULL) {
- temp = (char*) (pidStr + strlen(PID_TAG));
- temp[4] = '\0';
- pid = strtol (temp, NULL, 16);
- }
- item->vendorId = vid;
- item->productId = pid;
-
- delete string;
-}
-
-
-LRESULT CALLBACK DetectCallback(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {
- if (msg == WM_DEVICECHANGE) {
- if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam ) {
- PDEV_BROADCAST_HDR pHdr = (PDEV_BROADCAST_HDR)lParam;
- PDEV_BROADCAST_DEVICEINTERFACE pDevInf;
-
- if(pHdr->dbch_devicetype == DBT_DEVTYP_DEVICEINTERFACE) {
- pDevInf = (PDEV_BROADCAST_DEVICEINTERFACE)pHdr;
- UpdateDevice(pDevInf, wParam, (DBT_DEVICEARRIVAL == wParam) ? DeviceState_Connect : DeviceState_Disconnect);
- }
- }
- }
-
- return 1;
-}
-
-
-DWORD WINAPI ListenerThread( LPVOID lpParam ) {
- char className[MAX_THREAD_WINDOW_NAME];
- _snprintf_s(className, MAX_THREAD_WINDOW_NAME, "ListnerThreadUsbDetection_%d", GetCurrentThreadId());
-
- WNDCLASSA wincl = {0};
- wincl.hInstance = GetModuleHandle(0);
- wincl.lpszClassName = className;
- wincl.lpfnWndProc = DetectCallback;
-
- if (!RegisterClassA(&wincl)) {
- DWORD le = GetLastError();
- printf("RegisterClassA() failed [Error: %x]\r\n", le);
- return 1;
- }
-
-
- HWND hwnd = CreateWindowExA(WS_EX_TOPMOST, className, className, 0, 0, 0, 0, 0, NULL, 0, 0, 0);
- if (!hwnd) {
- DWORD le = GetLastError();
- printf("CreateWindowExA() failed [Error: %x]\r\n", le);
- return 1;
- }
-
- DEV_BROADCAST_DEVICEINTERFACE_A notifyFilter = {0};
- notifyFilter.dbcc_size = sizeof(notifyFilter);
- notifyFilter.dbcc_devicetype = DBT_DEVTYP_DEVICEINTERFACE;
- notifyFilter.dbcc_classguid = GUID_DEVINTERFACE_USB_DEVICE;
-
- HDEVNOTIFY hDevNotify = RegisterDeviceNotificationA(hwnd, ¬ifyFilter, DEVICE_NOTIFY_WINDOW_HANDLE);
- if (!hDevNotify) {
- DWORD le = GetLastError();
- printf("RegisterDeviceNotificationA() failed [Error: %x]\r\n", le);
- return 1;
- }
-
- MSG msg;
- while(TRUE) {
- BOOL bRet = GetMessage(&msg, hwnd, 0, 0);
- if ((bRet == 0) || (bRet == -1)) {
- break;
- }
-
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
-
- return 0;
-}
-
-
-void BuildInitialDeviceList() {
- TCHAR buf[MAX_PATH];
- DWORD dwFlag = (DIGCF_ALLCLASSES | DIGCF_PRESENT);
- HDEVINFO hDevInfo = DllSetupDiGetClassDevs(NULL, "USB", NULL, dwFlag);
-
- if(INVALID_HANDLE_VALUE == hDevInfo) {
- return;
- }
-
- SP_DEVINFO_DATA* pspDevInfoData = (SP_DEVINFO_DATA*) HeapAlloc(GetProcessHeap(), 0, sizeof(SP_DEVINFO_DATA));
- pspDevInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
- for(int i=0; DllSetupDiEnumDeviceInfo(hDevInfo, i, pspDevInfoData); i++) {
- DWORD nSize=0 ;
-
- if (!DllSetupDiGetDeviceInstanceId(hDevInfo, pspDevInfoData, buf, sizeof(buf), &nSize)) {
- break;
- }
-
- DeviceItem_t* item = new DeviceItem_t();
- item->deviceState = DeviceState_Connect;
-
- DWORD DataT;
- DllSetupDiGetDeviceRegistryProperty(hDevInfo, pspDevInfoData, SPDRP_HARDWAREID, &DataT, (PBYTE)buf, MAX_PATH, &nSize);
-
- AddItemToList(buf, item);
- ExtractDeviceInfo(hDevInfo, pspDevInfoData, buf, MAX_PATH, &item->deviceParams);
- }
-
- if(pspDevInfoData) {
- HeapFree(GetProcessHeap(), 0, pspDevInfoData);
- }
-
- if(hDevInfo) {
- DllSetupDiDestroyDeviceInfoList(hDevInfo);
- }
-}
-
-
-void ExtractDeviceInfo(HDEVINFO hDevInfo, SP_DEVINFO_DATA* pspDevInfoData, TCHAR* buf, DWORD buffSize, ListResultItem_t* resultItem) {
-
- DWORD DataT;
- DWORD nSize;
- static int dummy = 1;
-
- resultItem->locationId = 0;
- resultItem->deviceAddress = dummy++;
-
- // device found
- if (DllSetupDiGetDeviceRegistryProperty(hDevInfo, pspDevInfoData, SPDRP_FRIENDLYNAME, &DataT, (PBYTE)buf, buffSize, &nSize)) {
- resultItem->deviceName = buf;
- }
- else if ( DllSetupDiGetDeviceRegistryProperty(hDevInfo, pspDevInfoData, SPDRP_DEVICEDESC, &DataT, (PBYTE)buf, buffSize, &nSize))
- {
- resultItem->deviceName = buf;
- }
- if (DllSetupDiGetDeviceRegistryProperty(hDevInfo, pspDevInfoData, SPDRP_MFG, &DataT, (PBYTE)buf, buffSize, &nSize)) {
- resultItem->manufacturer = buf;
- }
- if (DllSetupDiGetDeviceRegistryProperty(hDevInfo, pspDevInfoData, SPDRP_HARDWAREID, &DataT, (PBYTE)buf, buffSize, &nSize)) {
- // Use this to extract VID / PID
- extractVidPid(buf, resultItem);
- }
-}
-
-
-void UpdateDevice(PDEV_BROADCAST_DEVICEINTERFACE pDevInf, WPARAM wParam, DeviceState_t state) {
- // dbcc_name:
- // \\?\USB#Vid_04e8&Pid_503b#0002F9A9828E0F06#{a5dcbf10-6530-11d2-901f-00c04fb951ed}
- // convert to
- // USB\Vid_04e8&Pid_503b\0002F9A9828E0F06
- CString szDevId = pDevInf->dbcc_name+4;
- int idx = szDevId.ReverseFind(_T('#'));
-
- szDevId.Truncate(idx);
- szDevId.Replace(_T('#'), _T('\\'));
- szDevId.MakeUpper();
-
- CString szClass;
- idx = szDevId.Find(_T('\\'));
- szClass = szDevId.Left(idx);
-
- // if we are adding device, we only need present devices
- // otherwise, we need all devices
- DWORD dwFlag = DBT_DEVICEARRIVAL != wParam ? DIGCF_ALLCLASSES : (DIGCF_ALLCLASSES | DIGCF_PRESENT);
- HDEVINFO hDevInfo = DllSetupDiGetClassDevs(NULL, szClass, NULL, dwFlag);
- if(INVALID_HANDLE_VALUE == hDevInfo) {
- return;
- }
-
- SP_DEVINFO_DATA* pspDevInfoData = (SP_DEVINFO_DATA*) HeapAlloc(GetProcessHeap(), 0, sizeof(SP_DEVINFO_DATA));
- pspDevInfoData->cbSize = sizeof(SP_DEVINFO_DATA);
- for(int i=0; DllSetupDiEnumDeviceInfo(hDevInfo, i, pspDevInfoData); i++) {
- DWORD nSize=0 ;
- TCHAR buf[MAX_PATH];
-
- if (!DllSetupDiGetDeviceInstanceId(hDevInfo, pspDevInfoData, buf, sizeof(buf), &nSize)) {
- break;
- }
-
- if(szDevId == buf) {
-
- WaitForSingleObject(deviceChangedSentEvent, INFINITE);
-
- DWORD DataT;
- DWORD nSize;
- DllSetupDiGetDeviceRegistryProperty(hDevInfo, pspDevInfoData, SPDRP_HARDWAREID, &DataT, (PBYTE)buf, MAX_PATH, &nSize);
-
- if(state == DeviceState_Connect) {
- DeviceItem_t* device = new DeviceItem_t();
-
- AddItemToList(buf, device);
- ExtractDeviceInfo(hDevInfo, pspDevInfoData, buf, MAX_PATH, &device->deviceParams);
-
- currentDevice = &device->deviceParams;
- isAdded = true;
- }
- else {
-
- ListResultItem_t* item = NULL;
- if(IsItemAlreadyStored(buf)) {
- DeviceItem_t* deviceItem = GetItemFromList(buf);
- if(deviceItem)
- {
- item = CopyElement(&deviceItem->deviceParams);
- }
- RemoveItemFromList(deviceItem);
- delete deviceItem;
- }
-
- if(item == NULL) {
- item = new ListResultItem_t();
- ExtractDeviceInfo(hDevInfo, pspDevInfoData, buf, MAX_PATH, item);
- }
- currentDevice = item;
- isAdded = false;
- }
-
- break;
- }
- }
-
- if (pspDevInfoData) {
- HeapFree(GetProcessHeap(), 0, pspDevInfoData);
- }
-
- if(hDevInfo) {
- DllSetupDiDestroyDeviceInfoList(hDevInfo);
- }
-
- SetEvent(deviceChangedRegisteredEvent);
-}
diff --git a/vendor/node-usb-native/src/deviceList.cpp b/vendor/node-usb-native/src/deviceList.cpp
deleted file mode 100644
index af9a96a0f..000000000
--- a/vendor/node-usb-native/src/deviceList.cpp
+++ /dev/null
@@ -1,75 +0,0 @@
-#include