-
Notifications
You must be signed in to change notification settings - Fork 205
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
Feature RS485 #170
base: master
Are you sure you want to change the base?
Feature RS485 #170
Conversation
If anyone has a windows machine that can try this on, I believe this is the Windows change required for support. Unfortunately I cannot test it, so I don't know if it's a good idea for me to add it to this patch: diff --git a/serial_windows.go b/serial_windows.go
index 2e8a4cc..ff4e272 100644
--- a/serial_windows.go
+++ b/serial_windows.go
@@ -468,6 +468,10 @@ func nativeOpen(portName string, mode *Mode) (*windowsPort, error) {
params.XoffLim = 512
params.XonChar = 17 // DC1
params.XoffChar = 19 // C3
+
+ if mode.RS485.Enabled {
+ params.Flags |= dcbRTSControlToggle
+ }
if setCommState(port.handle, params) != nil {
port.Close()
return nil, &PortError{code: InvalidSerialPort}
@@ -479,12 +483,3 @@ func nativeOpen(portName string, mode *Mode) (*windowsPort, error) {
}
return port, nil
}
-
-// enableRS485 enables RS485 functionality of driver via an ioctl if the config says so
-func (port *windowsPort) enableRS485(config *RS485Config) error {
- if !config.Enabled {
- return &PortError{code: NoPlatformSupportForRS485, causedBy: nil}
- }
-
- return nil
-} |
@cmaglie is there any chance you will consider merging this? I hear the argument that it is not cross-platform, but realistically, the only platforms that need this are embedded Linux platforms with SOCs that have hardware support for RS485 direction control in the UART. Is there a better way this can be implemented so it would be accepted? |
Here are a few snippets from a i.MX6UL datasheet that illustrates what we are talking about: Embedded processors from TI and others have similar features. This is the relevant kernel API: https://docs.kernel.org/driver-api/serial/serial-rs485.html?highlight=rs485 |
@AndreRenaud Maybe you could fix one CI/CD bug and it will be possible to merge your PR to |
It's not obvious to me why that CI/CD issue is related to this PR to be honest. It is complaining about Also this PR has been sitting idle for a while - I don't think it's the CI/CD issue that is preventing it getting traction. |
The workflow failure does appear to be unrelated to this PR. On MacOS/Darwin, the build requires CGO, and thus will fail unless it is built with See arduino/yun-go-updater#1 for some more discussion on it. |
I've investigated the workflow issue, and have submitted a separate PR to resolve it. #186 |
This is a simple rebasing of #79 (from the https://github.com/cbrake/go-serial-1/tree/feature-rs485) branch. Sorry, I wasn't sure what the best approach was - this isn't my code, but it does compile against the latest version of go-serial.