coolpi 4b python3 gpio operation compatable with raspberry pi
- 
					
					
					
					
 download and install with root user. sudo pip3 install CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whlfor ubuntu 20.04 
 CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whlfor ubuntu 22.04 
 CPi.GPIO-1.0.0-cp310-cp310-linux_aarch64.whlother 
 CPi.GPIO-1.0.0-cp39-cp39-linux_aarch64.whldefault gpio cfg with system image: 
  
 gpio_coolpi
 running test: sudo python3 test.py#!/usr/bin/env python3 import CPi.GPIO as GPIO import time PIN = 40 GPIO.setmode(GPIO.BOARD) GPIO.setup(PIN, GPIO.OUT) while True: GPIO.output(PIN, 0) time.sleep(1) GPIO.output(PIN, 1) time.sleep(1)其中GPIO.setmode(GPIO.BOARD)表示使用coolpi 4b板子自然编号Pin number。如果要使用Rockchip gpio编号,需要引用GPIO.setmode(GPIO.RK)。  if you want to remove this module, exec command: sudo pip3 uninstall CPi.GPIO
- 
					
					
					
					
 也适用于debain等其他系统嘛 
- 
					
					
					
					
 @花月 注意python版本,其它都是一样的。ubuntu22.04 默认python3.10,要注意切换一下。 
- 
					
					
					
					
 @george SPI 怎么开,在debain下安装完输入gpio_coolpi显示命令找不到 
 是否有比较全的示例介绍SPI
- 
					
					
					
					
 @花月 
 系统中若无该命令,请将附件文件拷贝到/usr/sbin/,再执行chmod a+x /usr/sbin/gpio_coolpiSPI与I2C操作使用标准python或标准C调用API 
- 
					
					
					
					
 @jack_admin 这个附件名称是什么,下载是数字的名称,有后缀嘛? 
- 
					
					
					
					
 @花月 可以拷贝重命名/usr/sbin/gpio_coolpi 
- 
					
					
					
					
 @george Is there any way to use GPIOs without sudo priviledge, such as in a ros package? 
- 
					
					
					
					
 @dreamer 
 hi, please add extra operation for coolpi user.Add rules for normal user: sudo echo "SUBSYSTEM==\"gpio*\", ACTION==\"add\", PROGRAM=\"/bin/bash -c 'chown root:coolpi /sys/class/gpio/export /sys/class/gpio/unexport;chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'\"" > /lib/udev/rules.d/99-gpio.rules sudo echo "SUBSYSTEM==\"gpio*\", ACTION==\"add\", PROGRAM=\"/bin/bash -c 'chown root:coolpi /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low; chmod 0660 /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low'\"" >> /lib/udev/rules.d/99-gpio.rules sudo reboot
 Check rules: coolpi@coolpi:~/Desktop$ cat /lib/udev/rules.d/99-gpio.rules SUBSYSTEM=="gpio*", ACTION=="add", PROGRAM="/bin/bash -c 'chown root:coolpi /sys/class/gpio/export /sys/class/gpio/unexport;chmod 220 /sys/class/gpio/export /sys/class/gpio/unexport'" SUBSYSTEM=="gpio*", ACTION=="add", PROGRAM="/bin/bash -c 'chown root:coolpi /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low; chmod 0660 /sys%p/direction /sys%p/value /sys%p/edge /sys%p/active_low'"
 Test case: coolpi@coolpi:~/Desktop$ echo 115 > /sys/class/gpio/export coolpi@coolpi:~/Desktop$ ls /sys/class/gpio/gpio115 active_low device direction edge power subsystem uevent value coolpi@coolpi:~/Desktop$ echo out > /sys/class/gpio/gpio115/direction coolpi@coolpi:~/Desktop$ echo 1 > /sys/class/gpio/gpio115/value coolpi@coolpi:~/Desktop$ echo 0 > /sys/class/gpio/gpio115/value coolpi@coolpi:~/Desktop$ 
- 
					
					
					
					
 请问跟RPi.GPIO的函数完全兼容吗? 
 GPIO.setwarnings(False) 之类的函数都有吗
 @大法师
- 
					
					
					
					
 @AugustRobot_Zou 
 还未完整测试所有接口。
- 
				Referenced by 大法师 大法师
- 
					
					
					
					
 @大法师 
 请问有支持python3.6的 .whl安装包吗?
 我的docker环境是unbuntu18.04+py2.7+py3.6.9的,CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whl安装不了。
 或者有没有其他方式,驱动gpio
- 
					
					
					
					
 @AugustRobot_Zou 
 所有的底层封装操作都是基于访问/sys/class/gpio/
- 
					
					
					
					
 @大法师 
 请问能麻烦编译一个python3.6.9的安装包吗?
 使用CPi.GPIO-1.0.0-cp38-cp38-linux_aarch64.whl,必须装上python3.8。
 我的docker环境是ubuntu18.04+python3.6.9+ROS。装了python3.8后,同时存在python3.8和python3.6,导致原本的代码程序很多python版本适配问题,这几天为这个问题搞得头大,很难兼顾 CPi.GPIO库和原来的程序,模块脚本的#!/usr/bin/python3 只能配置2选1(3.8 or 3.6 )。  
- 
					
					
					
					
 @AugustRobot_Zou okay! 
- 
					
					
					
					
 
- 
					
					
					
					
 @jack_admin @大法师 
 Really appreciate your help!
 Now our system is basically compatible with coolp4B,which used to running on raspberry-pi4B.
- 
				Referenced by A AugustRobot_Zou
- 
				Referenced by J jack_admin
- 
					
					
					
					
 有python3.9版本的吗 
- 
					
					
					
					
 @xingzhan2012 有。在帖子最顶楼 
- 
					
					
					
					
 @jack_admin 谢谢 
- 
					
					
					
					
 Does the coolpi have a DPI mode for the gpio like the RPI4? 
- 
					
					
					
					
 @Macs said in coolpi 4b python3 gpio operation compatable with raspberry pi: Does the coolpi have a DPI mode for the gpio like the RPI4? WiringPi ? 
- 
					
					
					
					
 @jack_admin I mean can output video signal on the gpio using with custom timings, like you can on the RPI4? 
- 
					
					
					
					
 请问支持C++语言吗 
- 
					
					
					
					
 @Orion C++可以代码文件操作gpio,不需要调用python库 
- 
					
					
					
					
 @jack_admin 请问C++需要包含哪个库呢,是writtingPi吗 
- 
					
					
					
					
 @Orion 直接裸操作/sys/class/gpio,不做二次包装 
- 
					
					
					
					
 it says in the GPIO page that all gpio are configurable with pullup or pulldown mode. How can we access the pull down resistor on a input pin say pin 32 GPIO105 that is default set to pullup? I tried the same convention as raspberry pi python access which is GPIO.setup([pin#], GPIO.IN, pull_up_down=GPIO.PUD_DOWN) and i get the error no PUD_DOWN in the module. Can you post the entire documentation with included commands in this module? 
- 
					
					
					
					
 @zensation not support setting pullup/down in user space now. 
- 
					
					
					
					
 This post is deleted!