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

node-red-node-serialport port selection node addition #1035

Merged
merged 21 commits into from
Nov 23, 2023
Merged

node-red-node-serialport port selection node addition #1035

merged 21 commits into from
Nov 23, 2023

Conversation

yhur
Copy link
Contributor

@yhur yhur commented Nov 14, 2023

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

When the node-red starts, the flow(program) picks up the hard-coded serial ports and open them. But when a device re-connects after disconnecting for any reason, it may be possible the port number change, but the end user of the flow can't change the port unless he/she has the access to the node-red editor.

Recently I had to develop a feature on top of node-red-node-serialport that enables the end user of node-red to change the port number/name without the access to the node-red editor.

This PR adds the said functionality to the existing node-red-node-capability

********** This version: IMAP ONLY **********

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run grunt to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

Copy link

linux-foundation-easycla bot commented Nov 14, 2023

CLA Signed

The committers listed above are authorized under a signed CLA.

@yhur
Copy link
Contributor Author

yhur commented Nov 14, 2023

@dceejay,
As discussed, here is the PR for the modification. Thanks.
https://discourse.nodered.org/t/node-red-node-serialport-port-selection/82651

@dceejay
Copy link
Member

dceejay commented Nov 18, 2023

Hi - finally had a chance to check this out... looks like a good idea - but... if we are going to do this then I think it should offer more control over the port. As we have another PR outstanding about stop start control and this would be an opportunity to do both in a not-intrusive manner.
I think we could use baud = 0 to flush/close ?
then resending with correct baud would restart it.
(or maybe we want to add an explicit stop/start command ?)

When you inject a blank message you only get the current port back - you don't get any of it settings etc - should it not return the complete config ?

Also need some help docs for the info tab - iE copy the text from README to locales/en-US/25-serial.json

If we add stop start then I think the name should also change to "serial control" - so it then also more closely matches the other serial node names.

io/serialport/README.md Outdated Show resolved Hide resolved
io/serialport/README.md Outdated Show resolved Hide resolved
io/serialport/25-serial.js Outdated Show resolved Hide resolved
io/serialport/25-serial.js Outdated Show resolved Hide resolved
@yhur
Copy link
Contributor Author

yhur commented Nov 19, 2023

@dceejay,
Thank you for your feedback.

I modified according to your feedback and implemented the stop/start as well and it is now renamed to 'serial control'.
And in order to take the stop/start into the modification, a minor refactoring was done. Just FYI.

io/serialport/25-serial.js Outdated Show resolved Hide resolved
io/serialport/25-serial.js Outdated Show resolved Hide resolved
@dceejay
Copy link
Member

dceejay commented Nov 20, 2023

Hmm - not sure I like a separate config property - I prefer the way you had that before.. just add the properties to the msg.payload level.
And just to add a single "enable" or "control" property that can be true/false etc ?
But much closer.

@yhur
Copy link
Contributor Author

yhur commented Nov 21, 2023

I originally started with a very simple requirement of changing the serial port, and taking your stop/start feedback into the code(btw, I like your requirement), it is now more full blown feature, I guess.

When adding the stop/start, I changed my view on the message from the configuration property to the command, because stop/start sounds like a command, so the initially thought property had to be a command, so it turned into the 'config' command. Though the stop and start command looked somewhat awkward with no values.

But since it is suggested to see the message as the properties, it now looks to have the better shape and consistency.

io/serialport/25-serial.js Outdated Show resolved Hide resolved
@yhur
Copy link
Contributor Author

yhur commented Nov 22, 2023

Learning a lot 😉

@dceejay
Copy link
Member

dceejay commented Nov 23, 2023

Hi, There are a few small changes I want to make but rather than keep hassling you I will merge this as-is and then tweak before releasing. (Mainly I think the property should be named 'enabled' rather than 'enable', and no need to expose binary and char yet... If there is user demand they can be added - but right now they just add clutter.)

Thanks very much for your work on this

@dceejay dceejay merged commit 2ddb603 into node-red:master Nov 23, 2023
@dceejay
Copy link
Member

dceejay commented Nov 23, 2023

HI - I have pushed to master branch... I also added some status under the node
image
Will release later today (probably) after some more testing.

@yhur
Copy link
Contributor Author

yhur commented Nov 23, 2023

@dceejay ,
Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants