28 lines
848 B
Python
28 lines
848 B
Python
import os
|
|
import sys
|
|
import serial.tools.list_ports
|
|
|
|
def find_com_port(vid, pid):
|
|
ports = serial.tools.list_ports.comports()
|
|
for port in ports:
|
|
if port.vid == vid and port.pid == pid:
|
|
print(f"Found device: {port.device}")
|
|
print(f"Description: {port.description}")
|
|
print(f"HWID: {port.hwid}")
|
|
return port.device
|
|
print(f"No COM port found for VID={vid:04X}, PID={pid:04X}")
|
|
return None
|
|
|
|
def main(args):
|
|
os.chdir(os.path.dirname(os.path.realpath(__file__)))
|
|
portname = find_com_port(0x1915, 0x521F)
|
|
if portname is None:
|
|
return
|
|
else:
|
|
os.system('nrfutil dfu usb-serial -pkg OTA_bmd380_peripheral.zip -b 115200 -p ' + portname)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv)
|
|
|
|
#nrfutil dfu usb-serial -pkg OTA_bmd380_peripheral.zip -snr DC051F1F71DA |