Changeset - baae0bdfde74
[Not reviewed]
default
0 3 0
Drew Perttula - 6 years ago 2019-05-27 12:44:18
drewp@bigasterisk.com
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
3 files changed with 23 insertions and 7 deletions:
0 comments (0 inline, 0 general)
bin/collector
Show inline comments
 
@@ -60,7 +60,7 @@ def launch(graph, doLoadTest=False):
 
    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:
light9/collector/output.py
Show inline comments
 
@@ -130,19 +130,28 @@ class EnttecDmx(DmxOutput):
 
    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 @@ class Udmx(DmxOutput):
 
            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 @@ class Udmx(DmxOutput):
 
                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
requirements.txt
Show inline comments
 
@@ -24,6 +24,7 @@ txzmq==0.8.0
 
typing==3.6.1
 
watchdog==0.8.3
 
webcolors==1.7
 
udmx-pyusb==2.0.0
 
yapf==0.27.0
 

	
 
coverage==4.3.4
0 comments (0 inline, 0 general)