Skip to content

setTimeout needs a non-constant reference? #14

Closed

Description

@Carlos4621

I'm trying to change the timeout of my serial object at runtime with setTimeout, but I notice that it requires a non-constant reference to a Timeout object, so lines like

serialPort_m.setTimeout(serial::Timeout::simpleTimeout(100));

don't work. Reviewing the implementation, I find that

void
Serial::SerialImpl::setTimeout (serial::Timeout &timeout)
{
timeout_ = timeout;
}

where timeout_ is a Timeout (not a reference).

My point here is: Does it really need a non-constant reference, or could the implementation be changed to accept a constant reference?

Activity

  1. traversaro commented on Oct 3, 2025

    @traversaro
    Contributor

    I think probably that can be made a const reference, and it was not like that just because no one ever noticed? Are you interested in opening a PR to fix that? Thanks!

  2. traversaro commented on Oct 3, 2025

    @traversaro
    Contributor

    Probably we just need to cherry-pick wjwwood/serial#102 here, see also wjwwood/serial#101 . This touches the public API, but I think there is no problem, we can just document that headers can change in minor releases, and just release 1.4.0 after this change.

  3. traversaro commented on Nov 14, 2025

    @traversaro
    Contributor

    Fixed in #16 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions