Permalink
Browse files

Change the way to write on USB. As the old one was not working with m…

…y new traffic light
  • Loading branch information...
gaelL committed Jul 25, 2018
1 parent 48cdec2 commit 53f2334fababde3fc0e7c08e7cbfea25705918f1
Showing with 20 additions and 1 deletion.
  1. +20 −1 clewareampel.py
@@ -1,3 +1,7 @@
# Enable debug
#import os
#os.environ['PYUSB_DEBUG'] = 'debug'

import sys
import argparse

@@ -36,7 +40,22 @@ def __exit__(self, type, value, traceback):
self.device.attach_kernel_driver(self.interface)

def _set_led(self, color, value):
self.device.ctrl_transfer(0x21, 0x09, 0x200, 0x00, [0x00, color, value])
cfg = self.device.get_active_configuration()
intf = cfg[(0,0)]
ep = usb.util.find_descriptor(
intf,
# match the first OUT endpoint
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_OUT)

assert ep is not None

# write the data
ep.write([0x00, color, value])
#self.device.ctrl_transfer(0x21, 0x09, 0x200, 0x00, [0x00, color, value])


def all_on(self):
self.red_on()

0 comments on commit 53f2334

Please sign in to comment.