RPi 使用 RF24 库 tmrh20 失败 make examples_RPi for ./gettingstarted

RPi using RF24 library tmrh20 failing make examples_RPi for ./gettingstarted

我正在尝试使用在此处找到的库:

https://tmrh20.github.io/RF24/RPi.html

我是 运行 树莓派 2 B+,目前 Raspbian 2015 年 11 月 12 日

我有一个在 Arduino 上工作的示例,我在将 Arduino 与 Arduino 通信时没有任何问题。但是,当尝试使用 RPi 示例时,我遇到了这个错误。

pi@raspberrypi ~/Desktop/rf24 $ cd rf24libs/RF24/examples_RPi/
pi@raspberrypi ~/Desktop/rf24/rf24libs/RF24/examples_RPi $ make
g++ -Ofast -mfpu=vfp -mfloat-abi=hard -march=armv6zk -mtune=arm1176jzf-s -Wall -I../ -lrf24-bcm transfer.cpp -o transfer
transfer.cpp: In function ‘int main(int, char**)’:
transfer.cpp:129:10: error: ‘sleep’ was not declared in this scope
  sleep(2);
      ^
Makefile:32: recipe for target 'transfer' failed
make: *** [transfer] Error 1

说明非常简单:

wget http://tmrh20.github.io/RF24Installer/RPi/install.sh 
chmod +x install.sh
./install.sh
cd rf24libs/RF24/examples_RPi  
make  
sudo ./gettingstarted

所以我希望 "out of the box" 能够正常运行?显然不是...

我还有构建所需的库,可在此处找到:

http://www.airspayce.com/mikem/bcm2835/

我已经安装好了,可以使用了。但为了继续,我需要能够让这个基本的入门示例发挥作用。我刚开始使用 GPIO,但我已按照此页面上的图表进行操作:

https://raspberrypi.stackexchange.com/questions/22490/rf24-communication-with-arduino

TL;DR

我无法根据使用 RPi 的 RF24 模块和库中包含的入门示例在文档完善且常用的库中找到的代码来运行基本示例。

我邀请你下载这个并尝试自己在你的树莓派上安装它,看看我们是否都有同样的问题。也许我们可以一劳永逸地解决这个问题。

任何帮助将不胜感激,我将关注此线程。

谢谢。

在 transfer.cpp 中的现有包含下面添加以下包含...它看起来像这样...

#include <cstdlib>
#include <iostream>
#include <sstream>
#include <string>
#include <RF24/RF24.h>
#include <unistd.h>

Afterwords 验证 sleep 是否为小写:

if (role == role_ping_out){
        sleep(2);
        printf("Initiating Basic Data Transfer\n\r");

现在应该编译...