Software source reference
"""
Contains a helper function to set the GPIO permissions.
Authors:
Min Tai Yap
"""
import subprocess
[docs]
def set_gpio_permissions():
"""
Changes the ownership of the /dev/gpiomem to root:gpio and gives read and write
access to the gpio group.
"""
try:
# Change the ownership of /dev/gpiomem to root:gpio
subprocess.run(['sudo', 'chown', 'root:gpio', '/dev/gpiomem'], check=True)
# Change the permissions to give read/write access to the gpio group
subprocess.run(['sudo', 'chmod', 'g+rw', '/dev/gpiomem'], check=True)
print("Permissions for /dev/gpiomem have been successfully updated.")
except subprocess.CalledProcessError as e:
print(f"Error: {e}")
print("Failed to update permissions for /dev/gpiomem.")
