MattIPv4 / MattIPv4/PyDMXControl

val in self.channels.items() can be float

Abierto
#55 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
Python
Estrellas
143
Forks
23
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

Hi fellow,

thanks a looot for your library. Real nice work.

I ran into an issue (can't tell you the origin), but by using a constant stream following line in _Controller.py might create a float, which later on will crash the program:

# Get all channels values
               for key, val in self.channels.items():
                    # If channel in frame
                    if key - first < len(self.__frame):
                       self.__frame[key - first] = int(val[0])`

i placed an int() around the val[0]. Not sure if that's in general a good idea.

but it fixed the issue, that otherwise at this call would break the runtime.

def _transmit(self, frame: List[int], first: int):
        # Convert to a bytearray and pad the start of the frame
        # We're transmitting direct DMX data here, so a frame must start at channel 1, but can end early
        try:
            data = bytearray(([0] * (first - 1)) + frame)
            # The first byte in the type, and is `0` for normal DMX data
            data.insert(0, 0)

            # Write
            self.__device.send_break(100e-6)
            sleep(10e-6)
            self.__device.write(data)
        except:
            print("bad request")`
```

as you see I made a try / except for myself.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza en _Controller.py, en el bucle de valores de canal, e inspecciona cómo llegan a _transmit los valores de self.channels.items(). Reproduce el caso de un flujo constante que produce un float y verifica que el tratamiento elegido conserva datos de trama DMX válidos y evita que falle la conversión a bytearray.

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

Evaluación

Stack tecnológico
python
Área
embedded-iot
Tipo de issue
Error
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.