I'm having great trouble trying to build a snap for a simple python code for Rpi2.
Code I would like to put into a Snap is:
# External module imports
import RPi.GPIO as GPIO
import time
print("Hello LED")
ledPin = 9
print("Setting Broadcom Mode")
# Pin Setup:
GPIO.setmode(GPIO.BCM) # Broadcom pin-numbering scheme
GPIO.setup(ledPin, GPIO.OUT)
print("Here we go! Press CTRL+C to exit")
try:
while 1:
print ("OFF");
GPIO.output(ledPin, GPIO.LOW)
time.sleep(1.00)
print ("ON");
GPIO.output(ledPin, GPIO.HIGH)
time.sleep(1)
except KeyboardInterrupt: # If CTRL+C is pressed, exit cleanly:
GPIO.cleanup() # cleanup all GPIO
The thing is that I don't seem to find in the documentation how to import rpi.GPIO Is this even possible?
Searched in https://github.com/ubuntu/snappy-playpen with no results
Thats the hard question. Easier question is.. How do I execute a python script with a snap? I tried putting in:
apps:
helloLed:
command: sudo python helloLed.py
and without the sudo
, after it triggered error for permission.
Thank you in advance! Will be posting full example tutorial when complete!