-
Notifications
You must be signed in to change notification settings - Fork 1k
Fix single-pin half-duplex in SoftwareSerial::send #749
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
Conversation
Tagging @ABOSTM. Perhaps they have insight into why these changes were originally made when porting SoftwareSerial to STM32. |
I will modify my board this morning so that I can test when using two serial pins, to make sure I didn't break that. |
I just verified that I can also communicate with my TMC2208 stepper driver using two pins from Marlin. |
I ran into another issue during testing involving half-duplex. The listen() called at the end of begin() causes SoftwareSerial to switch to RX as soon as a write finishes. This is true even if there is no read intended. This problem can be sporadic, and also only impacts the SoftwareSerial instance which most recently ran begin(). This can cause communications issues for some hardware which is counting on the TX pin keeping the wire at the proper high state between transfers. An example hardware combination is a BigTreeTech SKR Pro with their BTT 2208 modules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me
Thanks @ABOSTM |
Summary
When SoftwareSerial was adapted from the LPC1768 version, SoftwareSerial::send was altered in a way that prevents single-pin half-duplex communication from working properly.
This change reverts to the behavior seen in other repositories using variations of this code.
This PR fixes/implements the following bugs/features
This issue was discovered while testing a Marlin pull request which is adapting Marlin to work with STM32 5.7. During testing I found that one-pin communication with TMC stepper drivers did not work properly, although it did when using similar SoftwareSerial code from other sources.
The image below shows the same read command being sent to a TMC2208 stepper driver, both before and after the change in this PR. (Doesn't scale well, click to zoom)

Validation
I have validated that I can now communicate properly with TMC stepper drivers using one-wire connections inside Marlin.