Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check for smbus loading issues #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion argonone/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,14 @@ class ArgonOneBoard:
def __init__(self, initial_speed: Optional[int] = 0, bus_mutex: Optional[Lock] = None):
self._bus_mutex = bus_mutex if bus_mutex is not None else nullcontext()
# Set up I2C and initialize fan speed
self._bus = smbus.SMBus(_SMBUS_DEV)
try:
self._bus = smbus.SMBus(_SMBUS_DEV)
except FileNotFoundError:
log.warn("i2c device not found. Ensure the necessary i2c kernel modules are loaded")
raise
except PermissionError:
log.warn("i2c device not accessible. Ensure user is a member of the i2c group")
raise
if initial_speed is not None:
self.fan_speed = initial_speed # sets self._fan_speed, and also issues I2C command
else:
Expand Down