Skip to content

Commit 626bf15

Browse files
committed
better ftdi.setup error message
1 parent ca086fd commit 626bf15

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

pylabrobot/io/ftdi.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from typing import Optional, cast
77

88
try:
9-
from pylibftdi import Device, LibraryMissingError
9+
from pylibftdi import Device, FtdiError, LibraryMissingError
1010

1111
HAS_PYLIBFTDI = True
1212
except ImportError as e:
@@ -52,7 +52,12 @@ def dev(self) -> "Device":
5252
return self._dev
5353

5454
async def setup(self):
55-
self.dev.open()
55+
try:
56+
self.dev.open()
57+
except FtdiError as e:
58+
raise RuntimeError(
59+
f"Failed to open FTDI device: {e}. Is the device connected? Is it in use by another process? Try restarting the kernel."
60+
) from e
5661
self._executor = ThreadPoolExecutor(max_workers=1)
5762

5863
async def set_baudrate(self, baudrate: int):

0 commit comments

Comments
 (0)