Skip to content

Commit

Permalink
Change the way to write on USB. As the old one was not working with m…
Browse files Browse the repository at this point in the history
…y new traffic light
  • Loading branch information
gaelL committed Jul 25, 2018
1 parent 48cdec2 commit 53f2334
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion clewareampel.py
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,7 @@
# Enable debug
#import os
#os.environ['PYUSB_DEBUG'] = 'debug'

import sys import sys
import argparse import argparse


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


def _set_led(self, color, value): 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): def all_on(self):
self.red_on() self.red_on()
Expand Down

0 comments on commit 53f2334

Please sign in to comment.