Git Product home page Git Product logo

gpio_lib_python's Introduction

ASUS PYTHON GPIO LIB README

#Download source code
git clone https://github.com/TinkerBoard/gpio_lib_python.git

#Build
sudo apt-get install python-dev python2.7-dev python3-dev
cd ASUS_GPIO_PYTHON_PATH/gpio/
sudo python setup.py install

#A Simple Python Program
import ASUS.GPIO as GPIO
GPIO.setmode(GPIO.ASUS)
GPIO.setup(17, GPIO.OUT)
GPIO.output(17, GPIO.HIGH)

#More Informaion
Send an email to [email protected]

gpio_lib_python's People

Contributors

jamess-huang avatar scorpiochang avatar yishinhung avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gpio_lib_python's Issues

Issuy for test.py

When I execute test.py. It can run LED ON/OFF/PWM. But error appear when ket-in 'y' for BOARD INFORMATION. How to fix it?

`linaro@tinkerboard:~/gpio_lib_python/test$ python test.py
Ftest.py:620: RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead!
GPIO.cleanup()
F..This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
.....
warnings.new gpio = 162
.....
warnings.direction == OUTPUTThis channel is already in use, continuing anyway.
.....
Use GPIO.setwarnings(False) to disable warnings.
PWM tests
Is the LED on (y/n) ? y
Is the LED off (y/n) ? y
LED Brighten/fade test...
Did it work (y/n) ? y
test.py:259: RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead!
GPIO.cleanup()
.This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
GPIO.event_detected() switch bounce test. Press switch at least 10 times and count...
new gpio = 163
Etest.py:379: RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead!
GPIO.cleanup()
This channel is already in use, continuing anyway. Use GPIO.setwarnings(False) to disable warnings.
Switch bounce test. Press switch at least 10 times and count...
new gpio = 163
E
RPi.GPIO version 0.1 - is this correct (y/n) ? n
FRPi Board Information

P1_REVISION => 3
RAM => 1024M
REVISION => 0000
TYPE => Tinker Board
PROCESSOR => ROCKCHIP3288
MANUFACTURER => ASUS

Is this board info correct (y/n) ? y
.

ERROR: testAddEventCallback (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 554, in testAddEventCallback
GPIO.add_event_detect(LOOP_IN, GPIO.FALLING)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testAlreadyAdded (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 466, in testAlreadyAdded
GPIO.add_event_detect(LOOP_IN, GPIO.RISING)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testAlternateWaitForEdge (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 605, in testAlternateWaitForEdge
GPIO.wait_for_edge(LOOP_IN, GPIO.RISING)
RuntimeError: Error waiting for edge

======================================================================
ERROR: testBothEventDetected (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 505, in testBothEventDetected
GPIO.add_event_detect(LOOP_IN, GPIO.BOTH)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testExceptionInCallback (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 540, in testExceptionInCallback
GPIO.add_event_detect(LOOP_IN, GPIO.RISING, callback=cb)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testFallingEventDetected (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 479, in testFallingEventDetected
GPIO.add_event_detect(LOOP_IN, GPIO.FALLING)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testInvalidBouncetime (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 460, in testInvalidBouncetime
GPIO.add_event_detect(LOOP_IN, GPIO.RISING, bouncetime=123)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testRisingEventDetected (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 492, in testRisingEventDetected
GPIO.add_event_detect(LOOP_IN, GPIO.RISING)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testWaitForEdgeInLoop (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 397, in testWaitForEdgeInLoop
GPIO.wait_for_edge(LOOP_IN, GPIO.FALLING)
RuntimeError: Error waiting for edge

======================================================================
ERROR: testWaitForEdgeWithCallback (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 412, in testWaitForEdgeWithCallback
GPIO.add_event_detect(LOOP_IN, GPIO.RISING)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: testWaitForEventSwitchbounce (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 448, in testWaitForEventSwitchbounce
GPIO.wait_for_edge(LOOP_IN, GPIO.RISING, bouncetime=100)
RuntimeError: Error waiting for edge

======================================================================
ERROR: testWaitForFalling (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 531, in testWaitForFalling
GPIO.wait_for_edge(LOOP_IN, GPIO.FALLING)
RuntimeError: Error waiting for edge

======================================================================
ERROR: testWaitForRising (main.TestEdgeDetection)

Traceback (most recent call last):
File "test.py", line 523, in testWaitForRising
GPIO.wait_for_edge(LOOP_IN, GPIO.RISING)
RuntimeError: Error waiting for edge

======================================================================
ERROR: test_alreadyinuse (main.TestSetWarnings)
Test 'already in use' warning

Traceback (most recent call last):
File "test.py", line 266, in test_alreadyinuse
with open('/sys/class/gpio/export','wb') as f:
IOError: [Errno 13] Permission denied: '/sys/class/gpio/export'

======================================================================
ERROR: test_event_detected (main.TestSwitchBounce)

Traceback (most recent call last):
File "test.py", line 371, in test_event_detected
GPIO.add_event_detect(SWITCH_PIN, GPIO.FALLING, bouncetime=200)
RuntimeError: Failed to add edge detection

======================================================================
ERROR: test_switchbounce (main.TestSwitchBounce)

Traceback (most recent call last):
File "test.py", line 362, in test_switchbounce
GPIO.add_event_detect(SWITCH_PIN, GPIO.FALLING, callback=self.cb, bouncetime=200)
RuntimeError: Failed to add edge detection

======================================================================
FAIL: runTest (main.TestAAASetup)

Traceback (most recent call last):
File "test.py", line 61, in runTest
self.assertEqual(str(e.exception), 'Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)')
AssertionError: 'Please set pin numbering mode using GPIO.setmode(GPIO.BOARD), GPIO.setmode(GPIO.ASUS), GPIO.setmode(GPIO.BCM) or GPIO.setmode(GPIO.RK)' != 'Please set pin numbering mode using GPIO.setmode(GPIO.BOARD) or GPIO.setmode(GPIO.BCM)'

======================================================================
FAIL: test_cleanall (main.TestCleanup)

Traceback (most recent call last):
File "test.py", line 622, in test_cleanall
self.assertEqual(GPIO.gpio_function(LOOP_OUT), GPIO.IN)
AssertionError: 1 != 0

======================================================================
FAIL: test_cleanupwarning (main.TestSetWarnings)
Test initial GPIO.cleanup() produces warning

Traceback (most recent call last):
File "test.py", line 310, in test_cleanupwarning
self.assertEqual(len(w),0) # no warnings
AssertionError: 1 != 0

======================================================================
FAIL: test_gpio_version (main.TestVersions)

Traceback (most recent call last):
File "test.py", line 325, in test_gpio_version
self.assertEqual(response, 'Y')
AssertionError: 'N' != 'Y'


Ran 32 tests in 290.548s

FAILED (failures=4, errors=16)
`

How can I install on TinkerBoard with python3?

I have installed this on my TinkerBoard with python2. It worked well. But when I run sudo python3 setup.py install, it raised an error and notice me some warnings and erros on installation progress.
The system is Debian10. Python version is 3.7.3.

Import issue

Follow steps:

  1. python3 setup.py install
  2. No issues on compile/install
  3. import ASUS.GPIO
    Traceback (most recent call last):
    File "", line 1, in
    ImportError: No module named 'ASUS.GPIO'

Same output using python2.7 as well.

Bug: add_event_callback.py does not work with pin=40

Hi all.

When trying to use 40th pin in "add_event_callback.py" sample, I'm getting this error:

new gpio = 188
Traceback (most recent call last):
File "add_event_callback.py", line 23, in
GPIO.add_event_detect(pin, GPIO.BOTH, callback=my_callback)
RuntimeError: Failed to add edge detection

With pin=3 from the original sample, it works.

Error when doing GPIO.cleanup() Possible bug?

Getting RuntimeWarning: No channels have been set up yet - nothing to clean up! Try cleaning up at the end of your program instead! when i try to do GPIO.cleanup() in the end of my program even though it should have been set up earlier in the code?
Anyway here is my code

import ASUS.GPIO as GPIO
import time



GPIO.setmode(GPIO.ASUS)
on = 1
fanenid = 166

GPIO.setup(fanenid,GPIO.OUT)

def fanankontroll():
    while (on == 1):
        inputstringen = raw_input("onoroff")
        if (inputstringen == "on"):
            print "startar fanskapet"
            GPIO.output(fanenid,GPIO.HIGH)

        if (inputstringen == "off"):
            print "stanna duwden"
            GPIO.output(fanenid,GPIO.LOW)


try:
    print "started"
    fanankontroll()


except KeyboardInterrupt:
    GPIO.cleanup()
    print "stopped"


I am having a hard time finding anyone else with the same issue even though there are alot of similar codes out there. Any help would be appreciated! //Frossaren

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.