Mercurial > code > home > repos > light9
changeset 1881:baae0bdfde74
add pyudmx support. The usb code looks the same as what i had, but mine quickly gave lots of 'Pipe error' and pyudmx is quiet so far
Ignore-this: 43495af6a9004c16f3a12c7e85d715b4
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Mon, 27 May 2019 12:44:18 +0000 |
parents | 0b2fdbc10fd3 |
children | 5c1b662c0263 |
files | bin/collector light9/collector/output.py requirements.txt |
diffstat | 3 files changed, 23 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/bin/collector Mon May 27 12:01:56 2019 +0000 +++ b/bin/collector Mon May 27 12:44:18 2019 +0000 @@ -60,7 +60,7 @@ try: # todo: drive outputs with config files outputs = [ - DummyOutput(L9['output/dmxA/'], 80), + Udmx(L9['output/dmxA/'], bus=None, address=None, numChannels=510), DummyOutput(L9['output/dmxB/'], 510), ] except Exception:
--- a/light9/collector/output.py Mon May 27 12:01:56 2019 +0000 +++ b/light9/collector/output.py Mon May 27 12:44:18 2019 +0000 @@ -130,19 +130,28 @@ def shortId(self): return 'enttec' +USE_PYUDMX = True class Udmx(DmxOutput): stats = scales.collection('/output/udmx', scales.PmfStat('update'), scales.PmfStat('write'), scales.IntStat('usbErrors')) - def __init__(self, uri, bus, numChannels): + def __init__(self, uri, bus, address, numChannels): DmxOutput.__init__(self, uri, numChannels) self._shortId = self.uri.rstrip('/')[-1] - from light9.io.udmx import Udmx - self.dev = Udmx(bus) - self.currentBuffer = '' + if USE_PYUDMX: + from pyudmx import pyudmx + self.dev = pyudmx.uDMXDevice() + if not self.dev.open(bus=bus, address=address): + raise ValueError("dmx open failed") + else: + from light9.io.udmx import Udmx + self.dev = Udmx(bus) + self.currentBuffer = '' + + self.currentBuffer = [] self.lastSentBuffer = None self.lastLog = 0 @@ -162,7 +171,7 @@ log.debug('%s %s', self.shortId(), ' '.join(map(str, values))) self.lastLog = now - self.currentBuffer = ''.join(map(chr, values)) + self.currentBuffer = values def sendDmx(self, buf): with Udmx.stats.write.time(): @@ -170,7 +179,13 @@ if not buf: print("skip empty msg") return True - self.dev.SendDMX(buf) + if USE_PYUDMX: + sent = self.dev.send_multi_value(1, self.currentBuffer) + if sent != len(self.currentBuffer): + raise ValueError("incomplete send") + else: + self.dev.SendDMX(''.join(map(chr, self.currentBuffer))) + return True except usb.core.USBError as e: # not in main thread