fossasia / fossasia/pslab-python

Clarify CLI runtime behavior when migrating away from deprecated pslab.serial_handler

Abierto
#271 0 comentarios 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
Python
Estrellas
1.6k
Forks
242
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

### Background
The `pslab.serial_handler` module is deprecated and emits warnings during build and runtime.
A newer API is available via `pslab.connection.SerialHandler`.

Migrating to the new API is necessary, but the two implementations differ in runtime behavior, particularly regarding connection states.

### Current CLI behavior
In `pslab/cli.py`, the CLI currently:
- Instantiates `SerialHandler(port=args.port)`
- Uses the handler immediately without explicitly calling `connect()`
- Relies on the deprecated module's **implicit** connection behavior to function.

### Behavior difference with `pslab.connection`
The newer `pslab.connection.SerialHandler`:
- Does **not** auto-connect on initialization.
- Requires an explicit `.connect()` call to open the port.
- Will fail at runtime if used immediately after instantiation without connection.

### Proposed Resolution
To safely migrate to the new API, the CLI logic in `pslab/cli.py` will be updated to:
1. **Explicit Connection:** Call `handler.connect()` immediately after instantiation.
2. **Lifecycle Management:** Wrap the execution in a `try...finally` block to ensure `handler.disconnect()` is called on exit.
3. **Port Handling:** Ensure `args.port` is passed correctly to support both specific port selection and auto-discovery.

### Related work
- PR: #267 (Implementation in progress)

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

Comienza en pslab/cli.py y compara su ciclo de vida del handler con pslab.connection.SerialHandler. Verifica que la CLI se conecte explícitamente, pase args.port en los casos de puerto seleccionado y descubrimiento automático, y se desconecte al salir; el PR relacionado #267 indica que la implementación ya está en curso.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
python
Área
cli
Tipo de issue
Error
Dificultad
2/5
Tiempo estimado
1-3 horas
Estado de actividad
Estancado
Claridad
Bien especificado
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.