rpi raspberry event add_event_detect python linux raspberry-pi gpio

python - raspberry - rpi.gpio install



Sin acceso a/dev/mem. Intenta ejecutar como root (1)

No solo se puede privilegiar el acceso a / dev para acceder, sino que también es probable que el dispositivo esté protegido.

Debería hacer un ls -l / dev y verificar el dispositivo de E / S al que está intentando acceder. Una vez que vea el grupo, intente agregarse a ese grupo:

$ sudo usermod -aG <iogroup> user

Después de eso, es probable que deba cerrar la sesión y volver a ingresar para que se agregue el grupo.

De lo contrario, podría cambiar el permiso al 777 (del dispositivo ), pero cambiar el grupo es más correcto.

¡Soy un novato!

Tengo el código de archivos python para encender la luz: intenté aquí y aquí y aquí aquí en el foro i chmod pi para / dev, archivo de grupo adduser 1

print "================================" print "ROBOT: DANG MO QUAT" print "================================" os.system("aplay -D hw:1,0 /home/pi/jasper/static/audio/dangmoquat.wav") minh.main([''-p'',pin,''on''])

archivo 2 de acceso a GPIO:

def GPIO_SETMODE(pin): if int(pin) in GPIOs: # GPIO.cleanup() GPIO.setmode(GPIO.BOARD) ## Use BOARD pin numbering GPIO.setup(int(pin), GPIO.OUT) return True else: return False def main(argv): type = '''' try: opts, args = getopt.getopt(argv,"b:p:h:s:r",[''input='', ''params='', ''help'']) except getopt.GetoptError: print ''Wrong command'' sys.exit(2) print opts,args for opt, arg in opts: #...........doing something here....................# elif opt in ("-p", "--power"): input = arg if GPIO_SETMODE(input):#------------> errror occurs here# if args[0] == ''on'': Power(int(input), True) elif args[0] == ''off'': Power(int(input), False) else: print ''Please choose on or off''

El error ocurre aquí.

"Sin acceso a / dev / mem. ¡Prueba a ejecutar como root!" lo intento aquí

y aquí y aquí aquí en el foro

y google. Estuve despierto hasta el amanecer. Tengo chmod 777 pi dev -R ¿Qué puedo saber? Por favor, ayúdame.