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

fix(SoftwareSerial): correct TX to RX switch when using half-duplex #1771

Merged
merged 1 commit into from
Jul 29, 2022

Conversation

dominikberse
Copy link
Contributor

Summary

When working with single-pin half-duplex SoftwareSerial, I noticed that after the call to listen() receiving data is not possible until data is written. In fact setRXTX(true) is only called within send(), which in turn is only called as long as active_out is set (i.e. ongoing transmission). Since at the beginning of listen() completion of any ongoing transmissions is awaited, the SoftwareSerial will not actively listen before another transmission is completed.

This PR fixes/implements the following bugs/features

  • Fixes the above behavior
  • No intentional breaking changes

This occurs if the communication is not initiated by the STM32. Otherwise, one would simply call listen() and then send whatever will trigger the other side to respond.

In my case, I wanted to use a second line to indicate the direction of communication (which however can not be used as a second line for full-duplex). I must admit that this is probably a very rare case, and the fix I suggest will in fact change the current behavior of calling listen() before sending data. However it took me a few hours to debug this and I thought I should at least mention this finding in case someone else stumbles upon it.

@fpistm fpistm requested review from ABOSTM and fpistm July 26, 2022 08:09
@fpistm fpistm added the enhancement New feature or request label Jul 26, 2022
@fpistm fpistm added this to the 2.3.1/2.4.0 milestone Jul 26, 2022
Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@ABOSTM ABOSTM left a comment

Choose a reason for hiding this comment

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

@dominikberse
thanks for sharing your findings.
Patch LGTM

@fpistm fpistm merged commit e773fec into stm32duino:main Jul 29, 2022
julien33510 added a commit to julien33510/arduino_essai1 that referenced this pull request Oct 2, 2023
mise en place de la librairie semi-duplex trouvé sur github (stm32duino/Arduino_Core_STM32#1771) et ajout de la spécificité pour les bits de parité et les 2 bits stop

=> succès
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants