mirror of
https://github.com/dakhnod/fzfs.git
synced 2025-05-16 07:10:20 -07:00
Add an autodiscovery feature
This commit is contained in:
parent
1608e14b30
commit
78ae8f30af
13
fzfs.py
13
fzfs.py
@ -18,8 +18,19 @@ import argparse
|
||||
import pathlib
|
||||
import serial
|
||||
import serial_ble
|
||||
import serial.tools.list_ports
|
||||
import sys
|
||||
|
||||
flipperusbid = "USB VID:PID=0483:5740"
|
||||
|
||||
def autodiscover():
|
||||
ports = serial.tools.list_ports.comports()
|
||||
for check_port in ports:
|
||||
if flipperusbid in check_port.hwid:
|
||||
print("Found: ", check_port.description, "(",check_port.device,")")
|
||||
return check_port.device
|
||||
return None
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='FUSE driver for flipper serial connection')
|
||||
parser.add_argument('-d', '--device', help='Serial device to connect to', dest='serial_device')
|
||||
@ -39,6 +50,8 @@ def main():
|
||||
print('mountpoint must be an empty folder')
|
||||
return
|
||||
|
||||
if args.serial_device is None:
|
||||
args.serial_device = autodiscover()
|
||||
|
||||
if args.serial_device is None and args.ble_address is None:
|
||||
print('either serial_device or ble_address required')
|
||||
|
Loading…
x
Reference in New Issue
Block a user