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

Make Pololu Maestro driver be possible to use in UART mode as well. #135

Open
heevasti opened this issue Feb 27, 2025 · 0 comments
Open
Labels
enhancement New feature or request

Comments

@heevasti
Copy link
Collaborator

heevasti commented Feb 27, 2025

Is your feature request related to a problem? Please describe.
The QMI Pololu Maestro device driver is now supporting the use of the device in Dual USB or Daisy Chain modes. These are not the default modes, but an UART mode is the default of the device. So, to use the driver, the manufacturer-provided GUI needs to be used first to change the mode.

First of all, this should be mentioned in our driver. The documentation should be edited to instruct the mode change for new devices. Secondly, we could enable the UART mode as well by selectively importing a separate class for UART control, or to make the driver smart enough to recognize or figure out which mode the device is on.

The original driver that was developed for Diamondos was based largely on the example of Maestro package's maestro.py. The umaestro.py is the UART version and looks very similar in function to the maestro.py.

Describe the solution you'd like
The UART control is rather similar to the serial-to-USB control through COM ports. We could create a special transport string that recognizes if we want to use the UART mode or not. Something like

if transport.upper().startswith("UART"):
    self._transport = busio.UART(board.TX, board.RX, baudrate)  # Possibly extract 'baudrate' from the transport string
else: ... # The current self._transport line

From the first look the existing _write and _ask functions could be used for both control ways without any or little modification. Probably the stumbling point here is the self._transport.discard_read() which does not exist in the busio.UART API. But we could extend the UART class in the driver to have this call OR use the reset_input_buffer with a little detour.

The board and busio modules, needed for this driver, should be "lazy imports" as we don't want more dependencies. They are part of a larger package, https://pypi.org/project/Adafruit-Blinka/.

Describe alternatives you've considered
Without digging deeper into the code, the assumption is that the rest of the driver API can stay the same. But if not, we can then make a base class Pololu_Maestro(QMI_Instrument) and derive the mode-specific classes from it Pololu_MaestroUsb(Pololu_Maestro) and Pololu_MaestroUart(Pololu_Maestro) and create in base class a selection method to which class to use when initialized. Specific selection of the child class should in that case also be allowed.

Acceptance criteria
The driver works also for the default UART mode, and only thing needed for that would be a modification of the transport string to start with "uart:" instead of "serial:".

Additional context
N/A

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

No branches or pull requests

1 participant