mirror of
https://github.com/odriverobotics/ODrive.git
synced 2026-09-21 15:34:33 +08:00
Merge pull request #28 from Wetmelon/test_bulk_fix
Test bulk timeout fix
This commit is contained in:
@@ -108,9 +108,9 @@ class ODriveBulkDevice():
|
||||
#return -1
|
||||
raise
|
||||
|
||||
def recieve(self, bufferLen):
|
||||
def receive(self, bufferLen):
|
||||
try:
|
||||
ret = self.epr.read(bufferLen, 0)
|
||||
ret = self.epr.read(bufferLen, 100)
|
||||
return ret
|
||||
except usb.core.USBError:
|
||||
#return -1
|
||||
@@ -119,5 +119,5 @@ class ODriveBulkDevice():
|
||||
def send_max(self):
|
||||
return 64
|
||||
|
||||
def recieve_max(self):
|
||||
def receive_max(self):
|
||||
return 64
|
||||
|
||||
+10
-4
@@ -26,28 +26,34 @@ def main(args):
|
||||
print("\tPOSITION_CONTROL:\n\t\tp MOTOR_NUMBER POSITION VELOCITY CURRENT")
|
||||
print("\tVELOCITY_CONTROL:\n\t\tv MOTOR_NUMBER VELOCITY CURRENT")
|
||||
print("\tCURRENT_CONTROL:\n\t\tc MOTOR_NUMBER CURRENT")
|
||||
print("\tQuit Python Script:\n\t\tq")
|
||||
print("---------------------------------------------------------------------")
|
||||
# query device
|
||||
dev = usbbulk.poll_odrive_bulk_device(printer=print)
|
||||
print (dev.info())
|
||||
print (dev.init())
|
||||
# thread
|
||||
thread = threading.Thread(target=recieve_thread, args=[dev])
|
||||
thread = threading.Thread(target=receive_thread, args=[dev])
|
||||
thread.start()
|
||||
while running:
|
||||
time.sleep(0.1)
|
||||
try:
|
||||
command = input("Enter ODrive command:\n")
|
||||
dev.send(command)
|
||||
if 'q' in command:
|
||||
running = False
|
||||
sys.exit()
|
||||
else:
|
||||
dev.send(command)
|
||||
except:
|
||||
running = False
|
||||
|
||||
def recieve_thread(dev):
|
||||
def receive_thread(dev):
|
||||
global ready
|
||||
|
||||
while running:
|
||||
time.sleep(0.1)
|
||||
try:
|
||||
message = dev.recieve(dev.recieve_max())
|
||||
message = dev.receive(dev.receive_max())
|
||||
message_ascii = bytes(message).decode('ascii')
|
||||
print(message_ascii, end='')
|
||||
if "ODrive Firmware" in message_ascii:
|
||||
|
||||
Reference in New Issue
Block a user