Created
December 28, 2023 23:57
-
-
Save thewh1teagle/16b71a8fdf8c6343c0b247a44a90d8a2 to your computer and use it in GitHub Desktop.
enumerate devices pyserial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import serial | |
| if os.name == 'nt': # sys.platform == 'win32': | |
| from serial.tools.list_ports_windows import comports | |
| elif os.name == 'posix': | |
| from serial.tools.list_ports_posix import comports | |
| ports = comports() | |
| for port in ports: | |
| print(port.device) | |
| if port.pid == 10: # PI Pico | |
| print('reset device', port) | |
| ser = serial.Serial(port=port.device) | |
| ser.baudrate = 1200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment