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

Feature rs485 #79

Closed
wants to merge 2 commits into from
Closed

Feature rs485 #79

wants to merge 2 commits into from

Conversation

cbrake
Copy link
Contributor

@cbrake cbrake commented May 7, 2020

First pass at implementing #78

Tested on a i.MX6UL embedded Linux system.

shaunco and others added 2 commits May 7, 2020 12:36
@cmaglie
Copy link
Member

cmaglie commented May 8, 2020

This implementation is for linux only, one of the goal of this library is to provide a serial implementation that is independent and (ideally) works 100% the same across all OS.

Is there any native support for rs485 on Windows and Mac too?

Also, I'm wondering: is the added API really needed? can't you control RTS/DTS yourself with the already exising API?

@cbrake
Copy link
Contributor Author

cbrake commented May 8, 2020

The problem with controlling the RS485 direction control from the application layer is you don't know exactly when the serial driver buffer/fifo is empty. The idea behind the driver/hardware control is the direction of the bus is changed from tx to rx exactly when it is done sending so you are ready to receive the response. Otherwise, the receiver could start responding before you turn the bus around, and you might miss something. If the application is controlling the direction of the RS485 transceiver with RTS, you would have to put some type of worse case delay after sending to allow the TX to complete which is not optimal.

This is probably only applicable to processors for embedded Linux systems. Most USB RS485 adapters (what you would use with windows or MAC) have automatic direction control built into the device itself -- nothing is required at the driver/app level. However, embedded processors (like the i.MX6UL) are designed to do many different things with the UART, so if you want hardware flow control of a RS485 bus transceiver, that needs to be configured, as the RTS signal is also designed to do other things.

We could create another package that could just be used to configure hardware flow control for the port and perhaps other esoteric things. Perhaps we could open the port with this package, and then open it again with another package and configure the hardware flow control -- not sure offhand if that would work -- seems like a hack.

The current implementation does not affect the API much. Most users simply don't fill out the RS485 field when they create the Mode struct. It does bloat the struct some, but seems cleaner than adding more functions to the interface, which every implementation would have to implement.

@AndreRenaud
Copy link
Contributor

This is a feature that I would also be quite keen on having available, for similar reasons (embedded systems with RTS-controlled RS485 ports). This functionality is also available on Windows if we wanted to try to make it more cross platform. This would be done using the dcbRTSControlToggle settings when we open the port. That would only cover the trivial case (ie: without the various delays etc... being usable). However I think this is the normal & most common behaviour.

@AndreRenaud AndreRenaud mentioned this pull request Dec 8, 2023
@cbrake
Copy link
Contributor Author

cbrake commented Dec 26, 2023

This PR was refreshed in #170, so closing. Thanks @AndreRenaud

@cbrake cbrake closed this Dec 26, 2023
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.

4 participants