MattIPv4 / MattIPv4/PyDMXControl
macOS extremely slow refresh rate when using a serial-based controller due to break time
Personne n'a encore pris cette issue.
- Langage dominant
- Python
- Étoiles
- 143
- Forks
- 23
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
This is more of an FYI for anyone else that tries to use this on macOS than an issue I expect fixed, but I'll document it here in case anyone wants to implement a more elegant solution.
When running PyDMXControl on macOS, the refresh rate for packets sent out is capped around ~2Hz due to the underlying implementation of sending a break in PySerial. A user in this thread helpful did some digging into the tcsendbreak function and found that it's hardcoded to 400ms on macOS, no matter what duration is passed in: link.
That means that the Ticker loop in this module blocks on the the call to PySerial's send_break function for 400ms and cannot spin any faster than that. My current workaround is to comment out the send_break and sleep calls here and instead replace it with:
self.__device.break_condition = True
sleep(5e-6)
self.__device.break_condition = False
sleep(1e-6)
Those sleep times are actually way shorter than what is supported by the DMX standard (min 88uS and 10uS respectively I think), but since the python sleep module isn't really accurate below 1ms, the actual break and MAB measured with a logic analyser ended up around 200uS and 300uS respectively. That will probably vary greatly depending on the system, but thankfully the DMX spec only mandates minimum lengths for both, and most DMX devices will do just find with longer breaks/MABs.
I don't know enough python to know if there are more reliable ways to do timing on a microsecond level, but this hack works well enough for the basic bringup I need to do with this module.
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez dans PyDMXControl/controllers/_SerialController.py, au niveau de la boucle Ticker et de l'appel send_break de PySerial. Étudiez le comportement du break-time sous macOS ainsi que le workaround documenté de break_condition ; le travail est considéré comme terminé lorsqu'une refresh rate plus élevée est obtenue sans enfreindre les exigences de timing de DMX.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- python
- Domaine
- embedded-iot, operating-systems
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 30/100