Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Adding in port selection to serialport-term. #1448

Merged

Conversation

robertmassaioli
Copy link
Contributor

@robertmassaioli robertmassaioli commented Jan 21, 2018

This makes the terminal command much more usable when you need to open
it multiple times in a row; especially when the names of the serial ports
are rapidly changing.

screen shot 2018-01-21 at 1 30 35 pm

At the moment, I'm doing a bunch of development on the nRF5 series of SOC's from Nordic Semiconductor and, because this is Bluetooth, I often have more than one SOC connected to my computer. Also, every time that I plug a new device in the Silicon Labs driver gives me a new virtual port for the device; making it a more lengthy than required process to reconnect to my logs. It would be better if it would just be:

  1. Ctrl-C
  2. Rerun terminal
  3. Select the newly named port.
  4. Profit

At any rate, hopefully, you like these changes.

This makes the terminal command much more useable when you need to open
it multiple times in a row; especially when the names of the serialports
are rapidly changing.
@@ -62,6 +62,7 @@
"nan": "^2.6.2",
"prebuild-install": "^2.4.1",
"promirepl": "^1.0.1",
"prompt-list": "^3.1.2",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change does require a new dependency. I don't know if this will be contentious or not. Please let me know.

@@ -99,6 +100,7 @@
"lint": "eslint lib test bin examples",
"rebuild-all": "npm rebuild && node-gyp rebuild",
"repl": "node bin/repl.js",
"terminal": "node bin/terminal.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is useful for development because of: npm/npm#7137


function makeNumber(input) {
return Number(input);
}

args
.version(version)
.usage('-p <port> [options]')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since port is no longer a required argument we can remove references to it.

bin/terminal.js Outdated

portSelection.run()
.then(answer => {
const choice = answer.split('\t')[1];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably the hackiest part of the whole PR. Relying on the choices to be tab separated in order to extract the comName.

I would prefer it if the prompt-list library had a name and value fields so that what you display could be different to what gets returned as an 'answer' but, alas, it does not look like that is the case.

bin/terminal.js Outdated
})
.catch(error => {
console.log(`Could not select a port: ${error}`);
process.exit(-2);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what your policy is on the error code numbering that should be returned. Could use feedback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets make it a positive int for fewer surprises cross platform

@reconbot
Copy link
Member

reconbot commented Jan 21, 2018 via email

@reconbot
Copy link
Member

reconbot commented Jan 21, 2018 via email

@robertmassaioli
Copy link
Contributor Author

I looked at listr on your recommendation and I think that prompt-list is a better fit for this use case. But maybe my cursory glance did not reveal something in listr that makes it a better fit.

I think the error codes look good based on what you have said. What would you like me to do in order for this PR to be merged in? It looks good to me. Cheers!

@reconbot
Copy link
Member

Just a bit about the error codes. I'm on vacation so I'll be mostly out of touch until next week. Looks good, I do approve 👍

@robertmassaioli
Copy link
Contributor Author

Awesome, I've modified all of the error codes so that they are positive. Even the one that was -1 before.

I'll wait till you get back next week. Cheers, have a great break, and thank you for your time! 😄

@codecov-io
Copy link

codecov-io commented Jan 26, 2018

Codecov Report

Merging #1448 into master will increase coverage by 0.02%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1448      +/-   ##
==========================================
+ Coverage   79.71%   79.73%   +0.02%     
==========================================
  Files          21       21              
  Lines         922      923       +1     
  Branches      167      169       +2     
==========================================
+ Hits          735      736       +1     
  Misses        187      187
Impacted Files Coverage Δ
lib/parsers/delimiter.js 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a819bca...125bb3b. Read the comment docs.

@robertmassaioli
Copy link
Contributor Author

Hi @reconbot , I understand that you are on vacation so I don't want to ping too much, but by which date would you be available for us to pick this PR up and see if we can get it over the line?

@reconbot reconbot merged commit 9f543b6 into serialport:master Feb 3, 2018
@robertmassaioli
Copy link
Contributor Author

Thank you! Excited to see these changes go out in the next release! Your rock, keep up the great work!

IvanSanchez pushed a commit to NordicPlayground/node-serialport that referenced this pull request Feb 27, 2018
* Adding in port selection to serialport-term.

This makes the terminal command much more useable when you need to open
it multiple times in a row; especially when the names of the serialports
are rapidly changing.

* Fix the command line arguments.

* Fixing eslint mistakes.

* Make all of the negative errors positive in serialport-terminal.
oteku pushed a commit to Cutii/node-serialport that referenced this pull request Apr 9, 2018
* Adding in port selection to serialport-term.

This makes the terminal command much more useable when you need to open
it multiple times in a row; especially when the names of the serialports
are rapidly changing.

* Fix the command line arguments.

* Fixing eslint mistakes.

* Make all of the negative errors positive in serialport-terminal.
reconbot pushed a commit that referenced this pull request Jul 24, 2018
* Adding in port selection to serialport-term.

This makes the terminal command much more useable when you need to open
it multiple times in a row; especially when the names of the serialports
are rapidly changing.

* Fix the command line arguments.

* Fixing eslint mistakes.

* Make all of the negative errors positive in serialport-terminal.
@lock lock bot locked as resolved and limited conversation to collaborators Aug 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants