-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move cli tools to their own packages (#1664)
- update cli docs - fix #1659 close / disconnect error for serialport-terminal - rename serialport-term to serialport-terminal - stop `test:require` because it's not necessary and breaks on the cli packages
- Loading branch information
Showing
23 changed files
with
461 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,7 +73,6 @@ install: | |
|
||
script: | ||
- npm run lint | ||
- npm run test:require | ||
- npm test | ||
|
||
# if publishing, do it | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.test.js | ||
CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2018 Francis Gulotta. All rights reserved. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## SerialPort List | ||
|
||
```bash | ||
$ npx @serialport/list [options] | ||
# or | ||
$ npm install -g @serialport/list | ||
$ serialport-list [options] | ||
``` | ||
|
||
The package `@serialport/list` will install the `serialport-list` cli tool which lists all available serial ports in different formats. | ||
|
||
```bash | ||
$ serialport-list -h | ||
|
||
Usage: serialport-list [options] | ||
|
||
List available serial ports | ||
|
||
Options: | ||
|
||
-h, --help output usage information | ||
-V, --version output the version number | ||
-f, --format <type> Format the output as text, json, or jsonline. default: text | ||
|
||
|
||
$ serialport-list | ||
/dev/tty.Bluetooth-Incoming-Port | ||
/dev/tty.usbmodem1421 Arduino (www.arduino.cc) | ||
|
||
$ serialport-list -f json | ||
[{"comName":"/dev/tty.Bluetooth-Incoming-Port"},{"comName":"/dev/tty.usbmodem1421","manufacturer":"Arduino (www.arduino.cc)","serialNumber":"752303138333518011C1","locationId":"14200000","vendorId":"2341","productId":"0043"}] | ||
|
||
$ serialport-list -f jsonline | ||
{"comName":"/dev/tty.Bluetooth-Incoming-Port"} | ||
{"comName":"/dev/tty.usbmodem1421","manufacturer":"Arduino (www.arduino.cc)","serialNumber":"752303138333518011C1","locationId":"14200000","vendorId":"2341","productId":"0043"} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#!/usr/bin/env node | ||
|
||
const bindings = require('@serialport/bindings') | ||
const { version } = require('../package.json') | ||
const args = require('commander') | ||
|
||
args | ||
.version(version) | ||
.description('List available serial ports') | ||
.option( | ||
'-f, --format <type>', | ||
'Format the output as text, json, or jsonl. default: text', | ||
/^(text|json|jsonline|jsonl)$/i, | ||
'text' | ||
) | ||
.parse(process.argv) | ||
|
||
function jsonl(ports) { | ||
ports.forEach(port => { | ||
console.log(JSON.stringify(port)) | ||
}) | ||
} | ||
|
||
const formatters = { | ||
text(ports) { | ||
ports.forEach(port => { | ||
console.log( | ||
`${port.comName}\t${port.pnpId || ''}\t${port.manufacturer || ''}` | ||
) | ||
}) | ||
}, | ||
json(ports) { | ||
console.log(JSON.stringify(ports)) | ||
}, | ||
jsonl, | ||
jsonline: jsonl, | ||
} | ||
|
||
bindings.list().then(formatters[args.format], err => { | ||
console.error(JSON.stringify(err)) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@serialport/list", | ||
"version": "1.0.0", | ||
"main": "lib/list.js", | ||
"bin": { | ||
"serialport-list": "./lib/list.js" | ||
}, | ||
"dependencies": { | ||
"commander": "^2.13.0", | ||
"@serialport/bindings": "^2.0.2" | ||
}, | ||
"engines": { | ||
"node": ">=6.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/node-serialport/node-serialport.git" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
*.test.js | ||
CHANGELOG.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2018 Francis Gulotta. All rights reserved. | ||
|
||
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## SerialPort Repl | ||
```bash | ||
$ npx @serialport/repl <port> | ||
# or | ||
$ npm install -g @serialport/repl | ||
$ serialport-repl <port> | ||
``` | ||
|
||
The package `@serialport/repl` will install the `serialport-repl` cli tool which provides a nodejs repl for working with serialport. This is valuable when debugging. | ||
|
||
You can make use of the `serialport-repl` command with; | ||
```bash | ||
$ serialport-repl # to auto detect an arduino | ||
$ serialport-repl /dev/tty.usbmodem1421 # to connect to a specific port | ||
``` | ||
|
||
It will load a serialport object with debugging turned on. | ||
```bash | ||
$ serialport-repl | ||
serialport:binding:auto-detect loading DarwinBinding +0ms | ||
port = SerialPort("/dev/tty.usbmodem1421", { autoOpen: false }) | ||
globals { SerialPort, portName, port } | ||
> SerialPort.list() | ||
serialport:main .list +6s | ||
[ { comName: '/dev/tty.usbmodem1421', | ||
manufacturer: 'Arduino (www.arduino.cc)', | ||
serialNumber: '752303138333518011C1', | ||
pnpId: undefined, | ||
locationId: '14200000', | ||
vendorId: '2341', | ||
productId: '0043' } ] | ||
> port.write('Calling all Autobots!') | ||
true | ||
> port.read() | ||
serialport:main _read queueing _read for after open +1m | ||
null | ||
> port.open() | ||
serialport:main opening path: /dev/tty.usbmodem1421 +30s | ||
serialport:bindings open +1ms | ||
``` |
4 changes: 2 additions & 2 deletions
4
packages/serialport/bin/repl.js → packages/repl/lib/repl.js
100755 → 100644
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"name": "@serialport/repl", | ||
"version": "1.0.0", | ||
"main": "lib/repl.js", | ||
"bin": { | ||
"serialport-repl": "./lib/repl.js" | ||
}, | ||
"dependencies": { | ||
"promirepl": "^1.0.1", | ||
"serialport": "^7.0.2" | ||
}, | ||
"engines": { | ||
"node": ">=6.0.0" | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/node-serialport/node-serialport.git" | ||
} | ||
} |
Oops, something went wrong.