Skip to content
This repository was archived by the owner on Nov 12, 2019. It is now read-only.

Commit 0db54b0

Browse files
author
nicolas-rabault
committedMar 24, 2016
Allow no root to use gpio for raspberry pi 2
1 parent 9297cd6 commit 0db54b0

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed
 

‎Adafruit_DHT/Raspberry_Pi_2.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def read(sensor, pin):
3131
# Signal no result could be obtained, but the caller can retry.
3232
return (None, None)
3333
elif result == common.DHT_ERROR_GPIO:
34-
raise RuntimeError('Error accessing GPIO. Make sure program is run as root with sudo!')
34+
raise RuntimeError('Error accessing GPIO.')
3535
elif result != common.DHT_SUCCESS:
3636
# Some kind of error occured.
3737
raise RuntimeError('Error calling DHT test driver read: {0}'.format(result))

‎source/Raspberry_Pi_2/pi_2_mmio.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ int pi_2_mmio_init(void) {
5353
uint32_t gpio_base = peri_base + GPIO_BASE_OFFSET;
5454
fclose(fp);
5555

56-
int fd = open("/dev/mem", O_RDWR | O_SYNC);
56+
int fd = open("/dev/gpiomem", O_RDWR | O_SYNC);
5757
if (fd == -1) {
58-
// Error opening /dev/mem. Probably not running as root.
58+
// Error opening /dev/gpiomem.
5959
return MMIO_ERROR_DEVMEM;
6060
}
6161
// Map GPIO memory to location in process space.

0 commit comments

Comments
 (0)