Skip to content
This repository has been archived by the owner on Aug 4, 2024. It is now read-only.

Commit

Permalink
Hard code serial numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Supernova1114 committed May 26, 2023
1 parent 1ad9496 commit dd0dabc
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 16 deletions.
26 changes: 10 additions & 16 deletions drive/drive/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import threading
import time
import subprocess
import os

from fibre.libfibre import ObjectLostError

Expand Down Expand Up @@ -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"]






Expand Down
13 changes: 13 additions & 0 deletions drive/drive/find_devpath.bash
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit dd0dabc

Please sign in to comment.