Changeset - f226f40a731d
[Not reviewed]
default
0 1 0
drewp@bigasterisk.com - 20 months ago 2023-05-29 18:46:25
drewp@bigasterisk.com
report usb stalls
1 file changed with 4 insertions and 1 deletions:
0 comments (0 inline, 0 general)
light9/collector/output.py
Show inline comments
 
@@ -214,25 +214,25 @@ class Udmx(BackgroundLoopOutput):
 
                if not buf:
 
                    logAllDmx.debug('%s: empty buf- no output', self.shortId())
 
                    return
 

	
 
                # ok to truncate the last channels if they just went
 
                # to 0? No it is not. DMX receivers don't add implicit
 
                # zeros there.
 
                buf = buf[:self.lastDmxChannel]
 

	
 
                if logAllDmx.isEnabledFor(logging.DEBUG):
 
                    # for testing fps, smooth fades, etc
 
                    logAllDmx.debug('%s: %s...' % (self.shortId(), ' '.join(map(str, buf[:32]))))
 

	
 
                t1 = time.time()
 
                sent = self.dev.send_multi_value(1, bytearray(buf))
 
                if sent != len(buf):
 
                    raise ValueError("incomplete send")
 
            except ValueError:
 
                self.reconnect()
 
                raise
 
            except usb.core.USBError as e:
 
                # not in main thread
 
                if e.errno == 75:
 
                    metrics('write_overflow', output=self.shortId()).inc()
 
                    return
 

	
 
@@ -246,24 +246,27 @@ class Udmx(BackgroundLoopOutput):
 

	
 
                msg = 'usb: sending %s bytes to %r; error %r' % (len(buf), self.uri, e)
 
                log.warn(msg)
 

	
 
                if e.errno == 13:  # permissions
 
                    return self.crash()
 

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

	
 
                raise
 
            dt = time.time() - t1
 
            if dt > 1/self.rate*1.5:
 
                log.warning(f'usb stall- took {(dt*1000):.2f}ms')
 

	
 

	
 
'''
 
# 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)
 

	
0 comments (0 inline, 0 general)