Changeset - f45814654fdb
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-05-24 06:56:28
drewp@bigasterisk.com
comment
1 file changed with 11 insertions and 4 deletions:
0 comments (0 inline, 0 general)
light9/collector/output.py
Show inline comments
 
@@ -160,24 +160,31 @@ class ArtnetDmx(BackgroundLoopOutput):
 
            packet.append(0x00)  # Physical
 
            universe_nr = 0
 
            packet.append(universe_nr & 0xFF)  # Universe LowByte
 
            packet.append(universe_nr >> 8 & 0xFF)  # Universe HighByte
 

	
 
            packet.extend(struct.pack('>h', len(buf)))  # Pack the number of channels Big endian
 
            packet.extend(buf)
 

	
 
            self._socket.sendto(packet, ('127.0.0.1', 6454))
 

	
 

	
 
class Udmx(BackgroundLoopOutput):
 
    """alternate lib:
 

	
 
    from PyDMXControl.controllers import uDMXController
 
    u = uDMXController(autostart=False)
 
    u._connect()
 
    u._transmit([255, 0, 0, ...
 
    """
 

	
 
    def __init__(self, uri: URIRef, bus: int, address: int, lastDmxChannel: int, rate=22):
 
        self.bus = bus
 
        self.address = address
 
        self.lastDmxChannel = lastDmxChannel
 
        self.dev = None
 
        super().__init__(uri, rate=rate)
 

	
 
        self.reconnect()
 

	
 
    def shortId(self) -> str:
 
        return super().shortId() + f'_bus={self.bus}'
 
@@ -244,46 +251,46 @@ class Udmx(BackgroundLoopOutput):
 
                    return self.crash()
 

	
 
                if e.errno == 19:  # no such dev; usb hw restarted
 
                    self.reconnect()
 
                    return
 

	
 
                raise
 

	
 

	
 
'''
 
# the code used in 2018 and before
 
class UdmxOld(BackgroundLoopOutput):
 
    
 

	
 
    def __init__(self, uri, bus):
 
        from light9.io.udmx import Udmx
 
        self._dev = Udmx(bus)
 
        
 

	
 
        super().__init__(uri)
 

	
 
    def _write(self, buf: bytes):
 
        try:
 
            if not buf:
 
                return
 
            self.dev.SendDMX(buf)
 

	
 
        except usb.core.USBError as e:
 
            # not in main thread
 
            if e.errno != 75:
 
                msg = 'usb: sending %s bytes to %r; error %r' % (
 
                    len(buf), self.uri, e)
 
                log.warn(msg)
 
            raise
 
          
 
                                
 

	
 

	
 
# out of date
 
class EnttecDmx(BackgroundLoopOutput):
 
    stats = scales.collection('/output/enttecDmx', scales.PmfStat('write', recalcPeriod=1),
 
                              scales.PmfStat('update', recalcPeriod=1))
 

	
 
    def __init__(self, uri, devicePath='/dev/dmx0', numChannels=80):
 
        sys.path.append("dmx_usb_module")
 
        from dmx import Dmx
 
        self.dev = Dmx(devicePath)
 
        super().__init__(uri)
 

	
 

	
0 comments (0 inline, 0 general)