locked
Azure IoT edge solution module (Dockerfile)- RPi.GPIO RuntimeError on raspberry pi RRS feed

  • Question

  • Hi everyone ,  I created a solution module (python) using VS code for Blinking Led on raspberry pi . To make use of RPi pins installed RPi.GPIO library and created a docker image . When i run this docker image on raspberry pi its throwing a run-time error which is as follows.

    

    Traceback (most recent call last):

    File "main.py", line 8, in <module>

    GPIO.setup(18, GPIO.OUT)

    RuntimeError: No access to /dev/mem. Try running as root!

    

    main.py program

    <style type="text/css">@page { margin: 2cm } p { margin-bottom: 0.25cm; line-height: 115% } a:link { so-language: zxx } </style>

    #!/usr/bin/env python
    import RPi.GPIO as GPIO
    import time
    
    # Configure the PIN # 18
    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(18, GPIO.OUT)
    GPIO.setwarnings(False)
    
    # Blink Interval 
    blink_interval = .5 #Time interval in Seconds
    
    # Blinker Loop
    while True:
     GPIO.output(18, True)
     time.sleep(blink_interval)
     GPIO.output(18, False)
     time.sleep(blink_interval)
    
    # Release Resources
    GPIO.cleanup()

    Dockerfile.arm32v7

    FROM resin/raspberrypi3-debian:stretch
    
    WORKDIR /app
    ENV PYTHONUNBUFFERED=1
    RUN [ "cross-build-start" ]
    RUN echo "deb http://deb.debian.org/debian jessie main" >> /etc/apt/sources.list
    RUN sudo apt-get update  && sudo apt-get install -y \
        build-essential \
        python-dev \
        python-pip \
        python-setuptools \
        swig \
        zlib1g-dev 
    
    COPY requirements.txt ./
    RUN sudo pip install --upgrade pip
    RUN sudo pip install -r requirements.txt 
    RUN sudo apt-get install RPi.GPIO
    
    COPY . .
    
    CMD ["sudo", "python3","main.py" ]
    
    RUN [ "cross-build-end" ]

    and attaching error screenshot

    Thanks for your time


    Friday, January 17, 2020 6:53 AM

Answers

All replies