Skip to content

Commit

Permalink
Merge pull request #12 from TEParsons/main-driver-check
Browse files Browse the repository at this point in the history
ENH: Detect when FTDI driver is missing and raise an informative error
  • Loading branch information
TEParsons authored Nov 21, 2024
2 parents d938834 + d89d0b7 commit 90e8cf0
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
17 changes: 17 additions & 0 deletions psychopy_bbtk/tpad.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
import sys
import time


# check whether FTDI driver is installed
hasDriver = False
try:
import ftd2xx
hasDriver = True
except FileNotFoundError:
pass


# possible values for self.channel
channelCodes = {
'A': "Buttons",
Expand Down Expand Up @@ -311,6 +321,13 @@ def __init__(
maxAttempts=1, pauseDuration=1/1000,
checkAwake=True
):
# error if there's no ftdi driver
if not hasDriver:
raise ModuleNotFoundError(
"Could not connect to BBTK device as your computer is missing a necessary "
"hardware driver. You should be able to find the correct driver for your operating "
"system here: https://ftdichip.com/drivers/vcp-drivers/"
)
# get port if not given
if port is None:
port = self._detectComPort()[0]
Expand Down
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ urls.homepage = "https://github.com/psychopy/psychopy-bbtk"
urls.changelog = "https://github.com/psychopy/psychopy-bbtk/blob/main/CHANGELOG.txt"
urls.documentation = "https://pages.github.com/psychopy/psychopy-bbtk"
urls.repository = "https://github.com/psychopy/psychopy-bbtk"
dependencies = [
"ftd2xx"
]

[tool.setuptools.packages.find]
where = ["",]
Expand Down

0 comments on commit 90e8cf0

Please sign in to comment.