Skip to content

Add Multiple Hand Control Via RS485 Bus #45

@TomaszTB

Description

@TomaszTB

We connected two hands to a single USB to RS485 adapter with the hope to control both hands by read/writing to one, then the other sequentially.

We tried something like the following using the C++ API, but it did not work.

AHWrapper wrapperLeft = AHWrapper(0x50, 460800);
wrapperLeft.connect();

AHWrapper wrapperRight = AHWrapper(0x51, 460800);
wrapperRight.connect();

while (running) {
    wrapperLeft.read_write_once(/* params */);
    wrapperLeft.read_write_once(/* params */);
}

We looked into the code and found that connect() should only be called once, regardless of how many AHWrappers are instantiated. E.g.:

AHWrapper wrapperLeft = AHWrapper(0x50, 460800);
AHWrapper wrapperRight = AHWrapper(0x51, 460800);
wrapperRight.connect();

while (running) {
    wrapperLeft.read_write_once(/* params */);
    wrapperLeft.read_write_once(/* params */);
}

While this works, the API is not intuitive for controlling multiple hands, and we're not sure of the behavior when the AHWrapper destructor is called multiple times. It seems fairly simple to fix by making the connect function static and adding a disconnect function.

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