fix apt-get install wiringpi errors All In One
fix apt-get install wiringpi errors All In One
C 语言版本
wiringpi
fix: E: Package 'wiringpi' has no installation candidate
error
修复 E: 软件包 wiringpi:armhf 没有可安装候选
错误
WiringPi
WiringPi is a PIN
based GPIO
access library written in C
for the BCM2835
, BCM2836
and BCM2837
SoC devices used in all Raspberry Pi
versions.
The source code is not publicly available but may be made available to those who wish commercial support.
It is designed for use with C
and RTB (BASIC) ON THE RASPBERRY PI ONLY.
It’s designed to be familiar to people who have used the Arduino
“wiring” system1 and is intended for use by experienced C/C++
programmers.
It is not a newbie
learning tool.
error ❌
$ sudo apt-get install wiringpi
pi@raspberrypi:~/Desktop $ sudo apt-get install wiringpi
正在读取软件包列表... 完成
正在分析软件包的依赖关系树... 完成
正在读取状态信息... 完成
没有可用的软件包 wiringpi:armhf,但是它被其它的软件包引用了。
这可能意味着这个缺失的软件包可能已被废弃,
或者只能在其他发布源中找到
E: 软件包 wiringpi:armhf 没有可安装候选
pi@raspberrypi:~/Desktop $
pi@raspberrypi:~/Desktop $ gcc -o b-led c-led.c -lwiringPi
c-led.c:1:9: fatal error: wiringPi.h: 没有那个文件或目录
1 | #include<wiringPi.h>
| ^~~~~~~~~~~~
compilation terminated.
solution ✅
$ sudo apt-get update
# $ sudo apt-get install build-essential
$ git clone https://github.com/WiringPi/WiringPi.git
$ cd WiringPi/ && ./build
test ✅
$ gpio -v
$ gpio readall
pi@raspberrypi:~/WiringPi $ gpio -v
gpio version: 2.70
Copyright (c) 2012-2018 Gordon Henderson
This is free software with ABSOLUTELY NO WARRANTY.
For details type: gpio -warranty
Raspberry Pi Details:
Type: Pi 3, Revision: 02, Memory: 1024MB, Maker: Embest
* Device tree is enabled.
*--> Raspberry Pi 3 Model B Rev 1.2
* This Raspberry Pi supports user-level GPIO access.
pi@raspberrypi:~/WiringPi $
pi@raspberrypi:~/WiringPi $ gpio readall
+-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| | | 3.3v | | | 1 || 2 | | | 5v | | |
| 2 | 8 | SDA.1 | IN | 1 | 3 || 4 | | | 5v | | |
| 3 | 9 | SCL.1 | IN | 1 | 5 || 6 | | | 0v | | |
| 4 | 7 | GPIO. 7 | IN | 1 | 7 || 8 | 0 | IN | TxD | 15 | 14 |
| | | 0v | | | 9 || 10 | 1 | IN | RxD | 16 | 15 |
| 17 | 0 | GPIO. 0 | IN | 0 | 11 || 12 | 0 | IN | GPIO. 1 | 1 | 18 |
| 27 | 2 | GPIO. 2 | IN | 0 | 13 || 14 | | | 0v | | |
| 22 | 3 | GPIO. 3 | IN | 0 | 15 || 16 | 0 | IN | GPIO. 4 | 4 | 23 |
| | | 3.3v | | | 17 || 18 | 0 | IN | GPIO. 5 | 5 | 24 |
| 10 | 12 | MOSI | IN | 0 | 19 || 20 | | | 0v | | |
| 9 | 13 | MISO | IN | 0 | 21 || 22 | 0 | IN | GPIO. 6 | 6 | 25 |
| 11 | 14 | SCLK | IN | 0 | 23 || 24 | 1 | IN | CE0 | 10 | 8 |
| | | 0v | | | 25 || 26 | 1 | IN | CE1 | 11 | 7 |
| 0 | 30 | SDA.0 | IN | 1 | 27 || 28 | 1 | IN | SCL.0 | 31 | 1 |
| 5 | 21 | GPIO.21 | IN | 1 | 29 || 30 | | | 0v | | |
| 6 | 22 | GPIO.22 | IN | 1 | 31 || 32 | 0 | IN | GPIO.26 | 26 | 12 |
| 13 | 23 | GPIO.23 | IN | 0 | 33 || 34 | | | 0v | | |
| 19 | 24 | GPIO.24 | IN | 0 | 35 || 36 | 0 | IN | GPIO.27 | 27 | 16 |
| 26 | 25 | GPIO.25 | IN | 0 | 37 || 38 | 0 | IN | GPIO.28 | 28 | 20 |
| | | 0v | | | 39 || 40 | 0 | IN | GPIO.29 | 29 | 21 |
+-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
| BCM | wPi | Name | Mode | V | Physical | V | Mode | Name | wPi | BCM |
+-----+-----+---------+------+---+---Pi 3B--+---+------+---------+-----+-----+
pi@raspberrypi:~/WiringPi $
demos
#include<wiringPi.h>
#define GPIO_PIN 25
int main()
{
// wiringPi 模式
if(wiringPiSetup() < 0) {
return 1;
// 设置 PIN 为输出针脚
pinMode(GPIO_PIN, OUTPUT);
for (int i = 0; i < 10; i++)
{
// 写入 高电平
digitalWite(GPIO_PIN, 1);
delay(200);
// 写入 低电平
digitalWite(GPIO_PIN, 0);
delay(200);
}
}
return 0;
}
/*
https://aka.ms/vcpkg
vcpkg
C/C++ dependency manager from Microsoft
For all platforms, buildsystems, and workflows
*/
(🐞 反爬虫测试!打击盗版⚠️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!
WiringPi
Python
# Python 2
$ pip install wiringpi
# Python 3
$ pip3 install wiringpi
# 或
$ python3 -m pip3 install wiringpi
https://github.com/WiringPi/WiringPi-Python
Node.js
$ npm i wiring-pi
# $ npm i wiringpi-node
https://www.npmjs.com/package/wiring-pi
https://www.npmjs.com/package/wiringpi-node
https://github.com/WiringPi/WiringPi-Node#install
C
https://github.com/WiringPi/WiringPi
make
/ Make / CMake
make
/ Make / CMake
#!/bin/sh -e
# build
# Simple wiringPi build and install script
#
# Copyright (c) 2012-2015 Gordon Henderson
#################################################################################
# This file is part of wiringPi:
# A "wiring" library for the Raspberry Pi
#
# wiringPi is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# wiringPi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
#################################################################################
#
# wiringPi is designed to run on a Raspberry Pi only.
# However if you're clever enough to actually look at this script to
# see why it's not building for you, then good luck.
#
# To everyone else: Stop using cheap alternatives. Support the
# Raspberry Pi Foundation as they're the only ones putting money
# back into education!
#################################################################################
check_make_ok() {
if [ $? != 0 ]; then
echo ""
echo "Make Failed..."
echo "Please check the messages and fix any problems. If you're still stuck,"
echo "then raise a GitHub issue with the output and as many details as you can"
echo " https://github.com/WiringPi/WiringPi/issues"
echo ""
exit 1
fi
}
sudo=${WIRINGPI_SUDO-sudo}
if [ x$1 = "xclean" ]; then
cd wiringPi
echo -n "wiringPi: " ; make clean
cd ../devLib
echo -n "DevLib: " ; make clean
cd ../gpio
echo -n "gpio: " ; make clean
cd ../examples
echo -n "Examples: " ; make clean
cd Gertboard
echo -n "Gertboard: " ; make clean
cd ../PiFace
echo -n "PiFace: " ; make clean
cd ../q2w
echo -n "Quick2Wire: " ; make clean
cd ../PiGlow
echo -n "PiGlow: " ; make clean
cd ../scrollPhat
echo -n "scrollPhat: " ; make clean
cd ../..
echo -n "Deb: " ; rm -f debian-template/wiringpi*.deb
echo
exit
fi
if [ x$1 = "xuninstall" ]; then
cd wiringPi
echo -n "wiringPi: " ; $sudo make uninstall
cd ../devLib
echo -n "DevLib: " ; $sudo make uninstall
cd ../gpio
echo -n "gpio: " ; $sudo make uninstall
exit
fi
# Only if you know what you're doing!
if [ x$1 = "xdebian" ]; then
here=`pwd`
deb_destdir=${here}/debian-template/wiringPi
cd debian-template/wiringPi
rm -rf usr
cd $here/wiringPi
make install-deb DEB_DESTDIR=${deb_destdir}
cd $here/devLib
make install-deb INCLUDE='-I. -I../wiringPi' DEB_DESTDIR=${deb_destdir}
cd $here/gpio
make install-deb INCLUDE='-I../wiringPi -I../devLib' LDFLAGS=-L../debian-template/wiringPi/usr/lib DEB_DESTDIR=${deb_destdir}
cd $here/debian-template
fakeroot dpkg-deb --build wiringPi
mv wiringPi.deb wiringpi-`cat $here/VERSION`-1.deb
exit
fi
if [ x$1 != "x" ]; then
echo "Usage: $0 [clean | uninstall]"
exit 1
fi
echo "wiringPi Build script"
echo "====================="
echo
hardware=`fgrep Hardware /proc/cpuinfo | head -1 | awk '{ print $3 }'`
echo
echo "WiringPi Library"
cd wiringPi
$sudo make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
else
make -j5
check_make_ok
$sudo make install
fi
check_make_ok
echo
echo "WiringPi Devices Library"
cd ../devLib
$sudo make uninstall
if [ x$1 = "xstatic" ]; then
make -j5 static
check_make_ok
$sudo make install-static
else
make -j5
check_make_ok
$sudo make install
fi
check_make_ok
echo
echo "GPIO Utility"
cd ../gpio
make -j5
check_make_ok
$sudo make install
check_make_ok
# echo
# echo "wiringPi Daemon"
# cd ../wiringPiD
# make -j5
# check_make_ok
# $sudo make install
# check_make_ok
# echo
# echo "Examples"
# cd ../examples
# make
# cd ..
echo
echo All Done.
echo ""
echo "NOTE: To compile programs with wiringPi, you need to add:"
echo " -lwiringPi"
echo " to your compile line(s) To use the Gertboard, MaxDetect, etc."
echo " code (the devLib), you need to also add:"
echo " -lwiringPiDev"
echo " to your compile line(s)."
echo ""
refs
https://www.cnblogs.com/xgqfrms/p/17365120.html#5173365
http://wiringpi.com/wiringpi-updated-to-2-52-for-the-raspberry-pi-4b/
https://zhuanlan.zhihu.com/p/487729568
https://blog.csdn.net/jidhdhnd/article/details/122716016
https://blog.csdn.net/weixin_42194402/article/details/123764537
©xgqfrms 2012-2021
www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms, 禁止转载 🈲️,侵权必究⚠️!
本文首发于博客园,作者:xgqfrms,原文链接:https://www.cnblogs.com/xgqfrms/p/17369876.html
未经授权禁止转载,违者必究!