Skip to content

Commit e000d4a

Browse files
committed
Windows device detect workaround
1 parent 6b93dbb commit e000d4a

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

cros_ec_python/cros_ec.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
from .devices import lpc
1313
if os.name == "posix":
1414
from .devices import dev
15+
else:
16+
dev = None
1517

1618

1719
class DeviceTypes(Enum):
@@ -34,9 +36,12 @@ def pick_device() -> DeviceTypes:
3436
* `DeviceTypes.LinuxDev` (see `cros_ec_python.devices.dev.CrosEcDev.detect()`)
3537
* `DeviceTypes.LPC` (see `cros_ec_python.devices.lpc.CrosEcLpc.detect()`)
3638
"""
37-
if dev.CrosEcDev.detect():
39+
if os.name == "nt":
40+
# detect only works on Linux for now
41+
return DeviceTypes.LPC
42+
elif dev and dev.CrosEcDev.detect():
3843
return DeviceTypes.LinuxDev
39-
elif lpc.CrosEcLpc.detect():
44+
elif lpc and lpc.CrosEcLpc.detect():
4045
return DeviceTypes.LPC
4146
else:
4247
raise OSError("Could not auto detect device, check you have the required permissions, or specify manually.")

cros_ec_python/devices/lpc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def detect() -> bool:
4242
"""
4343
Checks for known CrOS EC memory map addresses in `/proc/ioports`.
4444
"""
45+
# TODO: Windows support (Get-CimInstance -Class Win32_PortResource)
4546
with open("/proc/ioports", "r") as f:
4647
for line in f:
4748
if line.lstrip()[:4] in (

0 commit comments

Comments
 (0)