Skip to content

Can't shut down the EtherCAT bus after a state transition failure #268

@fpdotmonkey

Description

@fpdotmonkey

Hi! Thanks for opening an issue. Please provide some specific details to make it easier to debug any
problems.

Environment

Description of the problem/feature request/other

In the program I'm writing, I expect occasional failures to enter OP, generally because of unconfigured SDOs, which is fine for my application. In that event, I'd like to gracefully shutdown the EtherCAT bus. However, that's not possible. Observe,

let group = match group.into_op(&maindevice).await {
    Ok(group) => group,
    Err(err) => {
        group.into_init(&maindevice).await?;  // ERROR: group was moved above and can't be used anymore
        time_to_exit();
    }
}

The state transition failure, along with the borrow checker, make it so group cannot be interacted with after a state transition failure. So the question is how to solve this.

I have a couple thoughts, and I wonder what's the most right?

  • Create a new group with MainDevice; I think it should work as-is, but it feels hacky
  • Add a reference to a valid SubDeviceGroup in the Err type; this allows the cleanup, but makes handling Err possibly more complicated
  • Have MainDevice shut down the bus on Drop

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