-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1510 from benoit-pierre/improve_serial_port_handling
Improve serial port handling
- Loading branch information
Showing
6 changed files
with
140 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Use `/dev/serial/by-id/xxxx` links for each available serial port in the machine configuration dialog. |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Show detailed information about each available serial port in the machine configuration dialog. |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pathlib import Path | ||
|
||
|
||
def patch_ports_info(port_list): | ||
'''Patch serial ports info to use device-by-id links.''' | ||
try: | ||
device_by_id = { | ||
str(device.resolve()): str(device) | ||
for device in Path('/dev/serial/by-id').iterdir() | ||
} | ||
except FileNotFoundError: | ||
device_by_id = {} | ||
for port_info in port_list: | ||
port_info.device = device_by_id.get(port_info.device, port_info.device) | ||
return port_list |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def patch_ports_info(port_list): | ||
'''NOP…''' | ||
return port_list |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# “Microsoft Corp”. | ||
MICROSOFT_VID = 0x045e | ||
|
||
|
||
def patch_ports_info(port_list): | ||
'''Patch serial ports info to remove erroneous manufacturer. | ||
Because on Windows 10 most USB serial devices will use the generic | ||
CDC/ACM driver, their manufacturer is reported as Microsoft. Strip | ||
that information if the vendor ID does not match. | ||
''' | ||
for port_info in port_list: | ||
if port_info.manufacturer == 'Microsoft' \ | ||
and port_info.vid != MICROSOFT_VID: | ||
port_info.manufacturer = None | ||
return port_list |