Skip to content

Commit 75c8229

Browse files
authored
Merge pull request #18 from orionrobots/logging
Add debug logging.
2 parents ffd90fb + 4f0af97 commit 75c8229

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

usb_arm/__init__.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"""
1111
import usb.core
1212
from time import sleep
13+
import logging
14+
logger = logging.getLogger(__name__)
1315

1416

1517
class BitPattern(object):
@@ -61,16 +63,22 @@ def __str__(self):
6163
class Arm(object):
6264
"""Arm interface"""
6365
__slots__ = ['dev']
66+
USB_VENDOR = 0x1267
6467

6568
def __init__(self):
66-
self.dev = usb.core.find(idVendor=0x1267)
69+
self.dev = usb.core.find(idVendor=Arm.USB_VENDOR)
6770
if not self.dev:
6871
raise RuntimeError("USB Arm Not found. Ensure it is plugged in and powered on")
6972
self.dev.set_configuration()
7073

7174
def tell(self, msg):
7275
"""Send a USB messaqe to the arm"""
73-
self.dev.ctrl_transfer(0x40, 6, 0x100, 0, msg)
76+
bmRequestType = 0x40
77+
bRequest = 6
78+
wValue = 0x100
79+
wIndex = 0
80+
logger.debug("Sending ctrl message (%s)", msg)
81+
self.dev.ctrl_transfer(bmRequestType, bRequest, wValue, wIndex, msg)
7482

7583
def safe_tell(self, fn):
7684
"""Send a message to the arm, with a stop

0 commit comments

Comments
 (0)