element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Raspberry Pi
  • Products
  • More
Raspberry Pi
Raspberry Pi Forum Raspberry Pi and /dev/mem access
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Raspberry Pi to participate - click to join for free!
Featured Articles
Announcing Pi
Technical Specifications
Raspberry Pi FAQs
Win a Pi
Raspberry Pi Wishlist
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 30 replies
  • Subscribers 680 subscribers
  • Views 4851 views
  • Users 0 members are here
  • raspberry
  • pi
  • raspberry_pi
Related

Raspberry Pi and /dev/mem access

Former Member
Former Member over 11 years ago

Question(s) regarding Raspberry Pi and GPIO.

 

Been working with RPi.GPIO for several weeks trying to get the following script to run: (from Third Eye Visions, using the GPIO Python library that they suggest to use)

 

import RPi.GPIO as GPIO

GPIO.setmode (GPIO,BOARD)

GPIO.setup (7, GPIO.OUT)

GPIO.output (7, True)

 

When running from the Lynux command line, an error is posted “no access to /dev/mem.  Try running as root”

 

I go to command line and run sudo/home/pi/file name and another error is returned “command not found”.

 

Doing a brief search on line, I don’t seem to be the only person having this problem.  I simply don’t understand the solutions that are presented and it is not clear that the solutions solve the problem.

 

When using RPi.GPIO 0.5.4 revision of the Python Package Index, isn’t this problem resolved?

 

I am using the Debian Wheezy Rasbiabn 2012.12.img 192, Debian GNU/Linux 7 raspberry pi tty1

 

I have Python 2.7, 3.2 and 3 on the SD and Python IDE.

 

I want to program the raspberry pi using GPIO functions with Python not C or any other script.

 

Why won’t the current upgrade of Raspberry Pi from Third Eye Visions work with the above script?  This is not the only GPIO program (from other sources) that I have tried and receive the same result.  I can control the pins in the command line of Linux from the keyboard using set mode, etc and read the status of the pins using readall.

 

I have used Pygame with this distribution of Debian and it works perfectly.

 

Can anyone supply a simple fix for this problem?  Can it be solved with a new SD loaded with a raspberry pi compatible program set-up with Python?  If so. where can I find one.? Or can I simply add one or two lines to the script that will allow access into

/dev/mem and then reinstate root privileges to /dev/mem at the point of exit from the program?

 

Help!

morgsterdad

  • Sign in to reply
  • Cancel
Parents
  • mconners
    0 mconners over 11 years ago

    if this is what you are typing


    sudo/home/pi/file name


    that's why you are getting the error


    try sudo /home/pi/filename


    make sure there is a space after sudo


    sudo is a command


    good luck,


    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • mconners
    0 mconners over 11 years ago

    if this is what you are typing


    sudo/home/pi/file name


    that's why you are getting the error


    try sudo /home/pi/filename


    make sure there is a space after sudo


    sudo is a command


    good luck,


    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • Former Member
    0 Former Member over 11 years ago in reply to mconners

    Yea, I checked this,  I do have a space between sudo and the command.  This is a typo in the post.  Sorry for the confusion.

     

    Morgsterdad

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • mconners
    0 mconners over 11 years ago in reply to Former Member

    ok, then you probably want to edit the file you are trying to run.

     

    see if the first line is something like

    #!/usr/bin/python

     

    if it is, make sure that python is installed in /usr/bin

     

    you can do this by typing:

    which python

     

    at the command line

     

    the second thing to check is if the file is executable

     

    at the command line type:

    ls -al /home/pi/file name

     

    BTW, if there is actually a space in the file name you have to escape it like:

    ls -al /home/pi/file\ name

     

    the ls -al should return something like:

    -rwxr-xr-x   2 pi     pi            1328 Sep 19 23:36 file name

     

    if the x's are not there, you need to type

    chmod 755 /home/pi/file name

     

    then do the ls -al again

     

    if the x's are there at that point, try :

     

    sudo /home/pi/file name again

     

    good luck,

     

    Mike

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube