Gpio error wile using GPIOtest.py
#1
Greetings,

Well received my board yesterday. Tried to use GPIO in a small python code used library from https://github.com/Leapo/Rock64-R64.GPIO. But even the test file in it shows error.  Looking for help need to finish my college project asap.
Code:
import R64.GPIO as GPIO
from time import sleep

print("Testing R64.GPIO Module...")

# Test Variables
print("")
print("Module Variables:")
print("Name           Value")
print("----           -----")
print("GPIO.ROCK      " + str(GPIO.ROCK))
print("GPIO.BOARD     " + str(GPIO.BOARD))
print("GPIO.BCM       " + str(GPIO.BCM))
print("GPIO.OUT       " + str(GPIO.OUT))
print("GPIO.IN        " + str(GPIO.IN))
print("GPIO.HIGH      " + str(GPIO.HIGH))
print("GPIO.LOW       " + str(GPIO.LOW))
print("GPIO.PUD_UP    " + str(GPIO.PUD_UP))
print("GPIO.PUD_DOWN  " + str(GPIO.PUD_DOWN))
print("GPIO.VERSION   " + str(GPIO.VERSION))
print("GPIO.RPI_INFO  " + str(GPIO.RPI_INFO))

# Set Variables
var_gpio_out = 16
var_gpio_in = 18

# GPIO Setup
GPIO.setwarnings(True)
GPIO.setmode(GPIO.BOARD)
GPIO.setup(var_gpio_out, GPIO.OUT, initial=GPIO.HIGH)       # Set up GPIO as an output, with an initial state of HIGH
GPIO.setup(var_gpio_in, GPIO.IN, pull_up_down=GPIO.PUD_UP)  # Set up GPIO as an input, pullup enabled

# Test Output
print("")
print("Testing GPIO Input/Output:")

var_gpio_state = GPIO.input(var_gpio_out)                   # Return state of GPIO
print("Output State : " + str(var_gpio_state))              # Print results
sleep(1)
GPIO.output(var_gpio_out, GPIO.LOW)                         # Set GPIO to LOW

# Test Input
var_gpio_state = GPIO.input(var_gpio_in)                    # Return state of GPIO
print("Input State  : " + str(var_gpio_state))              # Print results
sleep(0.5)

# Test interrupt
print("")
print("Waiting 3 seconds for interrupt...")
var_interrupt = GPIO.wait_for_edge(var_gpio_in, GPIO.FALLING, timeout=3000)
if var_interrupt is None:
    print("Timeout!")
else:
    print("Detected!")

# Test PWM Output
p=GPIO.PWM(var_gpio_out, 60)                                # Create PWM object/instance

print("")
print("Testing PWM Output - DutyCycle - High Precision:")
print("60Hz at 50% duty cycle for 1 second")
p.start(50)
sleep(1)
print("60Hz at 25% duty cycle for 1 second")
p.ChangeDutyCycle(25)
sleep(1)
print("60Hz at 10% duty cycle for 1 second")
p.ChangeDutyCycle(10)
sleep(1)
print("60Hz at  1% duty cycle for 1 second")
p.ChangeDutyCycle(1)
sleep(1)
p.stop()

print("")
print("Testing PWM Output - DutyCycle - Low Precision:")
print("60Hz at 50% duty cycle for 1 second")
p.start(50, pwm_precision=GPIO.LOW)
sleep(1)
print("60Hz at 25% duty cycle for 1 second")
p.ChangeDutyCycle(25)
sleep(1)
print("60Hz at 10% duty cycle for 1 second")
p.ChangeDutyCycle(10)
sleep(1)
print("60Hz at  1% duty cycle for 1 second")
p.ChangeDutyCycle(1)
sleep(1)
p.stop()

print("")
print("Testing PWM Output - Frequency - Low Precision:")
print("60Hz at 50% duty cycle for 1 second")
p.start(50, pwm_precision=GPIO.LOW)
sleep(1)
print("30Hz at 50% duty cycle for 1 second")
p.ChangeFrequency(30)
sleep(1)
print("20Hz at 50% duty cycle for 1 second")
p.ChangeFrequency(20)
sleep(1)
print("10Hz at 50% duty cycle for 1 second")
p.ChangeFrequency(10)
sleep(1)
p.stop()

GPIO.cleanup([var_gpio_in, var_gpio_out])                   # Perform cleanup on specified GPIOs

print("")
print("Test Complete")

----------------------------------------------------------------------------------------------------------------------------------------------------------

###########OUTPUT################
Testing R64.GPIO Module...

Module Variables:
Name           Value
----           -----
GPIO.ROCK      ROCK
GPIO.BOARD     BOARD
GPIO.BCM       BCM
GPIO.OUT       out
GPIO.IN        in
GPIO.HIGH      1
GPIO.LOW       0
GPIO.PUD_UP    0
GPIO.PUD_DOWN  1
GPIO.VERSION   0.6.3
GPIO.RPI_INFO  {'P1_REVISION': 3, 'RAM': '1024M', 'REVISION': 'a22082', 'TYPE': 'Pi 3 Model B', 'PROCESSOR': 'BCM2837', 'MANUFACTURER': 'Embest'}
Error: Unable to export GPIO
Error: Unable to set GPIO direction
Error: Unable to export GPIO
Error: Unable to set GPIO direction

Testing GPIO Input/Output:
You must setup() the GPIO channel (BOARD 27) first
Output State : None
You must setup() the GPIO channel (BOARD 27) as an output first
You must setup() the GPIO channel (BOARD 32) first
Input State  : None

Waiting 3 seconds for interrupt...
You must setup() the GPIO channel (BOARD 32) as an input first
Timeout!
You must setup() the GPIO channel (BOARD 27) as an output first

Testing PWM Output - DutyCycle - High Precision:
60Hz at 50% duty cycle for 1 second
Traceback (most recent call last):
 File "R64-GPIO-test.py", line 71, in <module>
   p.start(50)
 File "/home/rock64/camcode/R64/_GPIO.py", line 351, in start
   self.pwm_calc()
 File "/home/rock64/camcode/R64/_GPIO.py", line 368, in pwm_calc
   self.sleep_low = (1.0 / self.freq) * ((100 - self.dutycycle) / 100.0)
AttributeError: PWM instance has no attribute 'freq'
  Reply


Messages In This Thread
Gpio error wile using GPIOtest.py - by Aditya Rastogi - 01-31-2019, 02:41 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  opemmediavault plugin error on "Check" clach04 0 5,106 04-21-2020, 10:13 PM
Last Post: clach04
  Memory addresses of GPIO pins AckRite 3 5,513 10-23-2018, 03:18 PM
Last Post: AckRite
  gstreamer error sdarktemplar 1 3,120 08-02-2018, 11:08 PM
Last Post: tllim
  GPIO indicators via DTB Mentaluproar 0 1,655 07-10-2018, 04:58 PM
Last Post: Mentaluproar
  docker contaainer error on "docker login" edwinbmiller 0 1,770 06-18-2018, 10:08 AM
Last Post: edwinbmiller
  Apt-get update duplicate entry error Jxck 1 3,405 06-02-2018, 02:26 PM
Last Post: evilbunny
  mmc0: error -110 edwinbmiller 6 7,861 03-29-2018, 12:44 PM
Last Post: edwinbmiller
  Onboard LEDs connected to the RK805-1 out1 and out2 GPIO pins prof7bit 8 7,702 03-03-2018, 02:58 PM
Last Post: prof7bit
  Error building Rock 64 kernel Bapple 3 5,095 02-13-2018, 08:23 AM
Last Post: xalius
Question LoadTrustBL error when booting pedroz 0 1,851 02-09-2018, 08:35 AM
Last Post: pedroz

Forum Jump:


Users browsing this thread: 1 Guest(s)