Coder Social home page Coder Social logo

eutim / opi.gpio Goto Github PK

View Code? Open in Web Editor NEW
57.0 5.0 20.0 66 KB

A python GPIO library for Orange Pi Zero2, OrangePi Zero 2, Orange Pi3, and Orange Pi Lite2.

License: MIT License

Python 7.62% C 92.38%
orangepi orangepi-zero2 orangepi-3 orangepi-lite-2 python gpio library

opi.gpio's People

Contributors

eutim 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

opi.gpio's Issues

doesn't build on armbian debian 11 bullseye

debian 11 bullseye
Python 3.9.2

sudo python3 setup.py install

linker throws about 50 multiple definition errors

/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/holla/OPI.GPIO/source/constants.h:30: multiple definition of `pud_off'; build/temp.linux-aarch64-3.9/source/constants.o:/home/holla/OPI.GPIO/source/constants.h:30: first defined here

OPi.GPIO has no attribute setboard

Hello,

I have stumbled upon an error.

When trying to run the blink_led.py example there is a message:

The start of the code:

import OPi.GPIO as GPIO
from time import sleep

GPIO.setboard(GPIO.H616) # in my case its H616
GPIO.setmode(GPIO.BOARD)
GPIO.setup(11, GPIO.OUT)

The error occurs at line 8:
'module' object has no attribute 'setboard'.

as OPi.GPIO is our module there seems to be a problem there. Inside the OPi file I can only see one Init file which doesn't include any attributes.

Is there an attribute file missing?

Thanks for your help in advance

OPi.GPİO installation error

i try to install OPi.GPIO on my orange pi 3 lts and when i got to the sudo python setup.py install part it give me a error saying "collect2: error: ld returned 1 exit status " "error: command 'aarch64-linux-gnu-gcc' failed with exit status " if some one can help me i would appreciate

Orange Pi 3 LTS

Hi, I installed this lib on my Orange Pi 3 LTS and for instance when I used example code blink_led.py I changed setboard to GPIO.PI3 and code worked witout error but also without impact on GPIO, when I used lib from this https://github.com/orangepi-xunlong/wiringOP and used bash or C, all working properly, Could you help and write what I can do to setup GPIO with Python on Orange Pi 3 LTS?

Doesn't build on Zero 2 Pi with Debian Bullseye

The install was attempted on what was essentially a fresh install of Debian 11 Bullseye on an OrangePi Zero 2, after a restart and updating with apt update and apt upgrade.

Followed the instructions written on the landing page, ended up with a failed build, log below:

orangepi@JSI1:~/OPI.GPIO$ sudo python3 setup.py install
/usr/lib/python3.9/distutils/dist.py:274: UserWarning: Unknown distribution option: 'long_description_content_type'
  warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib.linux-aarch64-3.9
creating build/lib.linux-aarch64-3.9/OPi
copying OPi/__init__.py -> build/lib.linux-aarch64-3.9/OPi
running build_ext
building 'OPi.GPIO' extension
creating build/temp.linux-aarch64-3.9
creating build/temp.linux-aarch64-3.9/source
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/boards.c -o build/temp.linux-aarch64-3.9/source/boards.o
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/c_gpio.c -o build/temp.linux-aarch64-3.9/source/c_gpio.o
source/c_gpio.c: In function ‘readl’:
source/c_gpio.c:39:63: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 4 has type ‘volatile uint32_t *’ {aka ‘volatile unsigned int *’} [-Wformat=]
   39 | printf("mmap_base = 0x%x\t mmap_seek = 0x%x\t gpio_map = 0x%x\t total = 0x%x\n",mmap_base,mmap_seek,gpio_map,(gpio_map + mmap_seek));
      |                                                            ~^                                       ~~~~~~~~
      |                                                             |                                       |
      |                                                             unsigned int                            volatile uint32_t * {aka volatile unsigned int *}
      |                                                            %ls
source/c_gpio.c:39:78: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 5 has type ‘volatile uint32_t *’ {aka ‘volatile unsigned int *’} [-Wformat=]
   39 | se = 0x%x\t mmap_seek = 0x%x\t gpio_map = 0x%x\t total = 0x%x\n",mmap_base,mmap_seek,gpio_map,(gpio_map + mmap_seek));
      |                                                            ~^                                 ~~~~~~~~~~~~~~~~~~~~~~
      |                                                             |                                           |
      |                                                             unsigned int                                volatile uint32_t * {aka volatile unsigned int *}
      |                                                            %ls
source/c_gpio.c: In function ‘setup’:
source/c_gpio.c:64:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   64 |  if ((uint32_t)gpio_mem % PAGE_SIZE)
      |      ^
source/c_gpio.c:65:28: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   65 |   gpio_mem += PAGE_SIZE - ((uint32_t)gpio_mem % PAGE_SIZE);
      |                            ^
source/c_gpio.c:70:25: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 2 has type ‘uint8_t *’ {aka ‘unsigned char *’} [-Wformat=]
   70 |   printf("gpio_mem = 0x%x\t gpio_map = 0x%x\n",gpio_mem,gpio_map);
      |                        ~^                      ~~~~~~~~
      |                         |                      |
      |                         unsigned int           uint8_t * {aka unsigned char *}
      |                        %hhn
source/c_gpio.c:70:43: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘volatile uint32_t *’ {aka ‘volatile unsigned int *’} [-Wformat=]
   70 |   printf("gpio_mem = 0x%x\t gpio_map = 0x%x\n",gpio_mem,gpio_map);
      |                                          ~^             ~~~~~~~~
      |                                           |             |
      |                                           unsigned int  volatile uint32_t * {aka volatile unsigned int *}
      |                                          %ls
source/c_gpio.c:72:6: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   72 |  if ((uint32_t)gpio_map < 0)
      |      ^
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/common.c -o build/temp.linux-aarch64-3.9/source/common.o
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/constants.c -o build/temp.linux-aarch64-3.9/source/constants.o
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/event_gpio.c -o build/temp.linux-aarch64-3.9/source/event_gpio.o
source/event_gpio.c: In function ‘event_cleanup’:
source/event_gpio.c:444:15: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]
  444 |     if ((gpio == -666) || (gpio_list->gpio == gpio))
      |               ^~
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/py_gpio.c -o build/temp.linux-aarch64-3.9/source/py_gpio.o
source/py_gpio.c: In function ‘py_setup_channel’:
source/py_gpio.c:184:13: warning: unused variable ‘fn’ [-Wunused-variable]
  184 |   int func, fn;
      |             ^~
source/py_gpio.c:184:7: warning: variable ‘func’ set but not used [-Wunused-but-set-variable]
  184 |   int func, fn;
      |       ^~~~
source/py_gpio.c: In function ‘py_gpio_function_string’:
source/py_gpio.c:357:7: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]
  357 |   str = FUNCTIONS[fn];
      |       ^
source/py_gpio.c: In function ‘PyInit_GPIO’:
source/py_gpio.c:733:3: warning: ‘PyEval_ThreadsInitialized’ is deprecated [-Wdeprecated-declarations]
  733 |   if (!PyEval_ThreadsInitialized())
      |   ^~
In file included from /usr/include/python3.9/Python.h:145,
                 from source/py_gpio.c:23:
/usr/include/python3.9/ceval.h:129:36: note: declared here
  129 | Py_DEPRECATED(3.9) PyAPI_FUNC(int) PyEval_ThreadsInitialized(void);
      |                                    ^~~~~~~~~~~~~~~~~~~~~~~~~
source/py_gpio.c:734:5: warning: ‘PyEval_InitThreads’ is deprecated [-Wdeprecated-declarations]
  734 |     PyEval_InitThreads();
      |     ^~~~~~~~~~~~~~~~~~
In file included from /usr/include/python3.9/Python.h:145,
                 from source/py_gpio.c:23:
/usr/include/python3.9/ceval.h:130:37: note: declared here
  130 | Py_DEPRECATED(3.9) PyAPI_FUNC(void) PyEval_InitThreads(void);
      |                                     ^~~~~~~~~~~~~~~~~~
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/py_pwm.c -o build/temp.linux-aarch64-3.9/source/py_pwm.o
aarch64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -I/usr/include/python3.9 -c source/soft_pwm.c -o build/temp.linux-aarch64-3.9/source/soft_pwm.o
aarch64-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fwrapv -O2 -Wl,-z,relro -g -fwrapv -O2 -g -ffile-prefix-map=/build/python3.9-PN012d/python3.9-3.9.2=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-aarch64-3.9/source/boards.o build/temp.linux-aarch64-3.9/source/c_gpio.o build/temp.linux-aarch64-3.9/source/common.o build/temp.linux-aarch64-3.9/source/constants.o build/temp.linux-aarch64-3.9/source/event_gpio.o build/temp.linux-aarch64-3.9/source/py_gpio.o build/temp.linux-aarch64-3.9/source/py_pwm.o build/temp.linux-aarch64-3.9/source/soft_pwm.o -o build/lib.linux-aarch64-3.9/OPi/GPIO.cpython-39-aarch64-linux-gnu.so
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/common.h:48: multiple definition of `gpio_mode'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:48: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/common.h:49: multiple definition of `pin_to_gpio'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:49: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/common.h:52: multiple definition of `setup_error'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:52: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/common.h:53: multiple definition of `module_setup'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:53: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/common.h:51: multiple definition of `gpio_direction'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:51: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/common.h:47: multiple definition of `board_type'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:47: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:32: multiple definition of `FUNCTIONS'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:32: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:30: multiple definition of `pin_to_gpio_prime'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:30: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:29: multiple definition of `pin_to_gpio_pc2'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:29: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:28: multiple definition of `pin_to_gpio_pc'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:28: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:27: multiple definition of `pin_to_gpio_zero2'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:27: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:26: multiple definition of `pin_to_gpio_zero'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:26: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:25: multiple definition of `pin_to_gpio_lite2'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:25: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:24: multiple definition of `pin_to_gpio_pi3'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:24: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/common.o:/home/orangepi/OPI.GPIO/source/boards.h:23: multiple definition of `pin_to_gpio_h616'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:23: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/common.h:53: multiple definition of `module_setup'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:53: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/common.h:52: multiple definition of `setup_error'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:52: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/common.h:51: multiple definition of `gpio_direction'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:51: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/common.h:49: multiple definition of `pin_to_gpio'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:49: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/common.h:48: multiple definition of `gpio_mode'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:48: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/common.h:47: multiple definition of `board_type'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:47: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/event_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:53: multiple definition of `module_setup'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:53: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/event_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:52: multiple definition of `setup_error'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:52: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/event_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:51: multiple definition of `gpio_direction'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:51: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/event_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:49: multiple definition of `pin_to_gpio'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:49: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/event_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:48: multiple definition of `gpio_mode'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:48: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/event_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:47: multiple definition of `board_type'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:47: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:48: multiple definition of `gpio_mode'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:48: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:52: multiple definition of `setup_error'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:52: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:47: multiple definition of `board_type'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:47: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:49: multiple definition of `pin_to_gpio'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:49: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:29: multiple definition of `pin_to_gpio_pc2'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:29: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:25: multiple definition of `pin_to_gpio_lite2'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:25: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:23: multiple definition of `pin_to_gpio_h616'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:23: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:27: multiple definition of `pin_to_gpio_zero2'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:27: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:28: multiple definition of `pin_to_gpio_pc'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:28: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:24: multiple definition of `pin_to_gpio_pi3'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:24: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:26: multiple definition of `pin_to_gpio_zero'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:26: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:30: multiple definition of `pin_to_gpio_prime'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:30: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:51: multiple definition of `gpio_direction'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:51: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/common.h:53: multiple definition of `module_setup'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:53: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/boards.h:32: multiple definition of `FUNCTIONS'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/boards.h:32: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:50: multiple definition of `bpi3'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:50: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:49: multiple definition of `blite2'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:49: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:48: multiple definition of `bh616'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:48: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:47: multiple definition of `bprime'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:47: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:46: multiple definition of `bpc2'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:46: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:45: multiple definition of `bpc'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:45: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:44: multiple definition of `bzeroplus3'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:44: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:43: multiple definition of `bzeroh5'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:43: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:42: multiple definition of `bzeroh2'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:42: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:41: multiple definition of `bunknown'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:41: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:40: multiple definition of `version'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:40: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:39: multiple definition of `soc'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:39: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:38: multiple definition of `bcm'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:38: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:37: multiple definition of `board'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:37: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:36: multiple definition of `unknown'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:36: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:35: multiple definition of `both_edge'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:35: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:34: multiple definition of `falling_edge'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:34: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:33: multiple definition of `rising_edge'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:33: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:32: multiple definition of `pud_down'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:32: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:31: multiple definition of `pud_up'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:31: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:30: multiple definition of `pud_off'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:30: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:29: multiple definition of `output'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:29: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:28: multiple definition of `input'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:28: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:27: multiple definition of `low'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:27: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/constants.h:26: multiple definition of `high'; build/temp.linux-aarch64-3.9/source/constants.o:/home/orangepi/OPI.GPIO/source/constants.h:26: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:51: multiple definition of `gpio_direction'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:51: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_pwm.o:/home/orangepi/OPI.GPIO/source/py_pwm.h:23: multiple definition of `PWMType'; build/temp.linux-aarch64-3.9/source/py_gpio.o:/home/orangepi/OPI.GPIO/source/py_pwm.h:23: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:53: multiple definition of `module_setup'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:53: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:52: multiple definition of `setup_error'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:52: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:49: multiple definition of `pin_to_gpio'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:49: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:48: multiple definition of `gpio_mode'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:48: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/py_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:47: multiple definition of `board_type'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:47: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/soft_pwm.o:/home/orangepi/OPI.GPIO/source/soft_pwm.c:29: multiple definition of `threads'; build/temp.linux-aarch64-3.9/source/event_gpio.o:/home/orangepi/OPI.GPIO/source/event_gpio.c:58: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/soft_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:53: multiple definition of `module_setup'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:53: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/soft_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:52: multiple definition of `setup_error'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:52: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/soft_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:51: multiple definition of `gpio_direction'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:51: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/soft_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:49: multiple definition of `pin_to_gpio'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:49: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/soft_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:48: multiple definition of `gpio_mode'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:48: first defined here
/usr/bin/ld: build/temp.linux-aarch64-3.9/source/soft_pwm.o:/home/orangepi/OPI.GPIO/source/common.h:47: multiple definition of `board_type'; build/temp.linux-aarch64-3.9/source/boards.o:/home/orangepi/OPI.GPIO/source/common.h:47: first defined here
collect2: error: ld returned 1 exit status
error: command '/usr/bin/aarch64-linux-gnu-gcc' failed with exit code 1

"This channel is already in use" error

I have tried to use soft PWM for control of dual motor controller for speed changes.
Following code is almost identical to the one that I have used for Orange Pi Zero with no problem.
It is differ only the pin numbers to match with Orange Pi Zero 2.
When I tried to use the pins, error message came out as "Pin# is reserved".
However, if I manually set the pin as output once using "gpio mode wPI# out" for 4 pints, then this code runs without an error.
I guess, it is missing initialization step somewhere.

softPWM_Zero2

#!/usr/bin/env python

-- coding: utf-8 --

Original Base Demo File : pwm_dutycycle.py

import OPi.GPIO as GPIO
from time import sleep

GPIO.setboard(GPIO.H616) # It is for Orange Pi Zero 2 board
GPIO.setmode(GPIO.BOARD) # set up BOARD BCM numbering

GPIO.setup(7, GPIO.OUT) # set Motor A : right wheel forward
GPIO.setup(19, GPIO.OUT) # set Motor A : right wheel backward
GPIO.setup(15, GPIO.OUT) # set Motor B : left wheel forward
GPIO.setup(21, GPIO.OUT) # set Motor B : left wheel backward

rwf = GPIO.PWM(7, 10) # new PWM on 7 freq.=30Hz
rwb = GPIO.PWM(19, 10) # new PWM on 19 freq.=30Hz
lwf = GPIO.PWM(15, 10) # new PWM on 15 freq.=30Hz
lwb = GPIO.PWM(21, 10) # new PWM on 21 freq.=30Hz

def stop_motors() :
rwf.start(0)
rwb.start(0)
lwf.start(0)
lwb.start(0)

try:
stop_motors()
while 1:
for dc in range(0, 101, 5):
rwf.ChangeDutyCycle(dc)
lwf.ChangeDutyCycle(dc)
sleep(0.1)
stop_motors()
sleep(1)
for dc in range(0, 101, 5):
rwb.ChangeDutyCycle(dc)
lwb.ChangeDutyCycle(dc)
sleep(0.1)
stop_motors()
sleep(1)

except KeyboardInterrupt:
pass

rwf.stop()
rwb.stop()
lwf.stop()
lwb.stop()

GPIO.cleanup()

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.