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

add dtr control to Serial constructor #266

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MaxTheMooshroom
Copy link

@MaxTheMooshroom MaxTheMooshroom commented May 23, 2022

What:
Add Data-Terminal-Ready (DTR) control parameter to the Serial constructor.

Why:
To set the default in the constructor. The arduino IDE and pyserial lib both provide constructor arguments for setting the default DTR behaviour of a serial object without needing to make external calls to update the properties of a file handle after construction. This is desirable behaviour.

Solves #265

How:

  • Create a dtrcontrol_t enum with values dtr_disable, dtr_enable, and dtr_handshake.
    • dtr_handshake is non-functional.
  • Add dtrcontrol_t dtrcontrol_ field to SerialImpl.
  • Replace Serial::setDTR() and SerialImpl::setDTR() bool parameters with dtrcontrol_t parameters.
  • Set SerialImpl::dtrcontrol_ to parameter value of SerialImpl::setDTR() in SerialImpl::setDTR().
  • Configure DTR within SerialImpl::reconfigurePort() depending on the value of SerialImpl::dtrcontrol_.
  • Add dtrcontrol_t constructor arguments for both Serial and SerialImpl constructors.
    • The default Serial constructor parameter value of dtrcontrol_t is dtr_disable.

These changes are made to both windows and unix implementations.

If something is not satisfactory, please let me know and I will make adjustments.
- Maxine

typedef enum `dtrcontrol_t`  for specification in the constructor of `serial::Serial` and `serial::Serial::SerialImpl`.

add `dtrcontrol_t` parameter to `serial::Serial` and `serial::Serial::SerialImpl` constructors for both windows and unix. `serial::Serial` constructor parameter defaults to `dtr_disable`.

set dtr control in `serial::Serial::SerialImpl::reconfigurePort` with `ioctl`.

change parameter for `setDTR` to `dtrcontrol_t` in both `serial::Serial` and `serial::Serial::SerialImpl` for both windows and unix. Changed default in `serial::Serial::setDTR` to `dtr_enable`.
fix bug where parameter `dtrcontrol` isn't stored to `dtrcontrol_`.
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.

1 participant