diff --git a/drive/drive/calibrate.py b/drive/drive/calibrate.py index 6f44d81..4e90f2f 100644 --- a/drive/drive/calibrate.py +++ b/drive/drive/calibrate.py @@ -30,6 +30,7 @@ import threading import time import subprocess +import os from fibre.libfibre import ObjectLostError @@ -183,22 +184,15 @@ def config_motor(odrv_num, axis_num, clear, powerDC): # Get serial numbers of all connected ODrives def get_all_odrives(): - # Pull all connected devices ID to the list - odrivesSerialList = [] - usbDevices = str(subprocess.run(['lsusb', '-v'], capture_output=True).stdout).split('\\n') - - odriveFound = False - # Find all ODrives connected to the computer - for line in usbDevices: - if "ODrive" in line: - odriveFound = True - print(line) - - if odriveFound and "Serial" in line: - odrivesSerialList.append(line[28:].strip()) - odriveFound = False - - return odrivesSerialList + # Temp hard code + + # Note: Run find_devpath.bash to get odrive serial number. + + # Left, right + return ["366B385A3030", "207937815753"] + + + diff --git a/drive/drive/find_devpath.bash b/drive/drive/find_devpath.bash new file mode 100755 index 0000000..43f6627 --- /dev/null +++ b/drive/drive/find_devpath.bash @@ -0,0 +1,13 @@ +#!/bin/bash +# Finds the USB device path for a given USB system device path. + +for sysdevpath in $(find /sys/bus/usb/devices/usb*/ -name dev); do + ( + syspath="${sysdevpath%/dev}" + devname="$(udevadm info -q name -p $syspath)" + [[ "$devname" == "bus/"* ]] && exit + eval "$(udevadm info -q property --export -p $syspath)" + [[ -z "$ID_SERIAL" ]] && exit + echo "/dev/$devname - $ID_SERIAL" + ) +done