标签: raspberry-pi

为Raspberry Pi交叉编译C++ 11代码

我正在尝试向Raspberry Pi移植一个大型项目,该项目大量使用C++ 11特性.该项目使用CMAKE,我使用crosstool-ng进行交叉编译.我在Pi上安装了依赖项并在本地复制它们,我设法让CMAKE找到它们.一些代码正确构建并生成ARM输出.但是,大多数代码都因令人困惑的GCC输出而失败,我非常肯定与C++ 11 /模板支持有关.例如,我得到这样的错误:

  • error: 'mutex' in namespace 'std' does not name a type (有问题的文件包含<thread>,如果我还包含<mutex>,则此错误消失,而不是x86 Ubuntu的要求)

  • error: expected class-name before '{' token(前{的行是:template<typename _Res> class __basic_future : public std::__future_base)

  • error: '__result_type' does not name a type (这可能是由于上面的错误而发生的)

这些错误看起来像ARM g ++编译器不太喜欢模板.正在使用的g ++版本是arm-unknown-linux-gnueabi-g++ (crosstool-NG 1.18.0) 4.7.3 20130102 (prerelease).

谁能指出我正确的方向?

编辑:以下是其中一个文件的g ++外观ps:

arm-unknown-linux-gnueabi-g++ -DprojectCore_EXPORTS -fPIC
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/freetype2
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/glib-2.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/lib/arm-linux-gnueabihf/glib-2.0/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/gdk-pixbuf-2.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/gtk-2.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/lib/arm-linux-gnueabihf/gtk-2.0/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/cairo
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/pango-1.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/atk-1.0
-I/home/sagar/workspace/RaspberryPi/target_env/usr/local/include
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/eigen3
-I/home/sagar/workspace/RaspberryPi/target_env/usr/include/flann
-I/home/sagar/workspace/project/include -std=c++0x -Wall -Werror -Wno-deprecated -fPIC -g -O4 …
Run Code Online (Sandbox Code Playgroud)

cross-compiling raspberry-pi

11
推荐指数
1
解决办法
3017
查看次数

如何在QEMU上模拟Raspberry Pi 2?

前段时间我在本文后仿效了Raspberry Pi ,但这种方法有几个问题:

  1. 这很慢.
  2. 显示解决方案限制为800x600.
  3. 你无法模仿超过256mb的ram.

此外,在Qemu中没有新的Broadcom BCM2836或任何其他基于arm7的CPU的仿真.但是,有几个原因,为什么模仿Raspberry Pi会很有趣.因此,我感兴趣的任何提示都可以帮助我在正确的方向上使用Qemu或Linux下的任何其他仿真软件来获得可用的Raspberry Pi 2仿真.

linux qemu emulation raspberry-pi raspberry-pi2

11
推荐指数
3
解决办法
2万
查看次数

如何在Raspberry Pi上安装最新版本的node.js?

我想在Raspberry Pi 3上安装最新的稳定版本的Node.js.我该如何做到这一点a)我总是能够更新到最新的LTS版本b)可以在版本之间轻松切换

node.js raspberry-pi raspbian

11
推荐指数
1
解决办法
2万
查看次数

如何在Mac上安装Raspbian到SD卡

如何在我的Mac上安装Raspbian OS到我的SD卡而无需安装任何其他软件或应用程序.谷歌上发现的大多数教程都需要安装SD Formatter或者没有提供详细步骤.

macos install sd-card raspberry-pi raspbian

11
推荐指数
1
解决办法
9032
查看次数

Python flask-cors ImportError:没有名为“flask-cors”的模块Raspberry pi

我正在关注此处文档中的flask-cors教程:https ://pypi.python.org/pypi/Flask-Cors

但是当我将它安装在我的树莓派上并运行我的 python 应用程序时,我收到了这个错误

Traceback (most recent call last): File "app.py", line 3, in <module> from flask_cors import CORS, cross_origin ImportError: No module named 'flask_cors'

这是我的python脚本:

from flask import Flask
from Main import main
from flask_cors import CORS, cross_origin    
app = Flask(__name__)
CORS(app)
main = main() 

@app.route('/turn' ,methods=['GET', 'OPTIONS'])
def index():
  return main.turn()

if __name__ == '__main__': 
  app.run(debug=True, host='0.0.0.0')
Run Code Online (Sandbox Code Playgroud)

python flask raspberry-pi flask-cors

11
推荐指数
2
解决办法
4万
查看次数

无法通过Raspberry Pi Python SMBus接收的I2C字节

我正在设置Raspberry Pi来记录Sensirion SCD30传感器的数据(CO2,湿度和温度).我的代码在python3中,使用SMBus库通过Pi的GPIO中的I2C引脚与传感器通信.有一个命令可以确定传感器是否准备好发送数据.

链接到SCD30接口数据表

通过Sparkfun链接到arduino的SCD30库

该值0x0202通过I2C发送,并返回3个字节​​的数据:

0x00 0x00 0x81 for data not ready
0x00 0x01 0xB0 for data ready
Run Code Online (Sandbox Code Playgroud)

前两个字节是MSB和数据就绪值的LSB.正确结合他们应该0x00000x0001.第三个字节是前两个字节的CRC8.这是用多项式0x31和初始化计算的0xFF.

大约一半的时间,字节以错误的顺序发送.而不是MSB LSB CRC发送MSB CRC LSB.例如,如果数据准备就绪,则可能发送0x00, 0xB0, 0x01而不是0x00, 0x01, 0xB0.我无法弄清楚为什么会发生这种情况,我担心发送数据时会出现一些损坏或问题.我可以更改代码以识别CRC是否是第二个字节,但我想找到潜在的问题.

我正在使用smbus库发送和接收I2C数据.这是我发送命令和读取数据的代码:

bus = smbus.SMBus(0)
I2C_ADDRESS = 0x61

def sendCommand(self, cmd):  # sends a 2 byte command (cmd)
    data = [0]*2
    data[0] = cmd >> 8  # splits 2 byte command into MSB and …
Run Code Online (Sandbox Code Playgroud)

python sensor i2c raspberry-pi smbus

11
推荐指数
1
解决办法
1058
查看次数

iwconfig - 通过终端上的wifi连接网络

关于覆盆子pi

irukeru@raspberrypi ~ $ sudo iwconfig wlan0 mode managed
irukeru@raspberrypi ~ $ sudo iwconfig wlan0 channel 11
irukeru@raspberrypi ~ $ sudo iwconfig wlan0 essid linksys
irukeru@raspberrypi ~ $ sudo iwconfig wlan0 key xxxxxxx
Error for wireless request "Set Encode" (8B2A) :
    invalid argument "xxxxxxx".
Run Code Online (Sandbox Code Playgroud)

我也试过了

irukeru@raspberrypi ~ $ sudo iwconfig wlan0 key s:xxxxxxx
Error for wireless request "Set Encode" (8B2A) :
    SET failed on device wlan0 ; Invalid argument.
Run Code Online (Sandbox Code Playgroud)

我是否需要编写密钥的bash代码?

linux terminal wifi raspberry-pi raspbian

10
推荐指数
1
解决办法
6万
查看次数

valgrind在Raspberry Pi上返回一条未处理的指令

我一直在试图调试分割故障最近使用我树莓派(B型)的valgrind,运行Debian GNU/Linux7.0(喘息).每次我在编译的C++程序上运行valgrind时,我都得到如下内容:

disInstr(arm): unhandled instruction: 0xF1010200
    cond=15(0xF) 27:20=16(0x10) 4:4=0 3:0=0(0x0)
valgrind: Unrecognized instruction at address 0x4843638.
at 0x4843638: ??? (in /usr/lib/arm-linux-gnueabihf/libconfi_rpi.so)
Run Code Online (Sandbox Code Playgroud)

然后是正常的valgrind东西,导致SIGILL并终止我的程序.起初我假设我的程序中有一些内存泄漏导致它执行一条非指令内存作为指令,但后来我运行了以下hello world代码,得到了相同的结果.

#include <iostream>
using namespace std;

int main() {
cout<<"Hello World"<<endl;

return 0;
}
Run Code Online (Sandbox Code Playgroud)

这可能不会有内存泄漏/段错误,为什么它会给我这个错误?我对valgrind很新,但我用最基本的方式运行它valgrind ./a.out.

c++ valgrind raspberry-pi

10
推荐指数
2
解决办法
4984
查看次数

Raspberry PI mdns getaddrinfo 3008错误

我有这个示例Node.js脚本:

var mdns = require('mdns');

var browser = mdns.createBrowser(mdns.tcp('http'));
browser.on('error', function (error) {
    console.log("error");
    console.log(error);
});
browser.on('serviceUp', function (service) {
    console.log("serviceUp");
    console.log(service);
});
browser.start();
Run Code Online (Sandbox Code Playgroud)

在我的Mac上它工作正常,找到了两个服务.如果我在运行Raspbean的Raspberry PI 2上运行完全相同的脚本(连接到同一网络),我得到这个输出:

pi@raspberrypi ~ $ node mdns.js 
*** WARNING *** The program 'node' uses the Apple Bonjour compatibility layer of Avahi.
*** WARNING *** Please fix your application to use the native API of Avahi!
*** WARNING *** For more information see <http://0pointer.de/avahi-compat?s=libdns_sd&e=node>
*** WARNING *** The program 'node' called 'DNSServiceRegister()' which …
Run Code Online (Sandbox Code Playgroud)

mdns node.js raspberry-pi raspbian raspberry-pi2

10
推荐指数
2
解决办法
1886
查看次数

使用Android的Raspberry Pi 3屏幕方向

我刚买了一台带有7英寸显示屏触摸屏和外壳的Raspberry Pi 3.

不幸的是,外壳不允许我手动旋转屏幕,所以我的应用程序颠倒了.

我尝试使用以下adb命令从控制台执行此操作,但没有运气:

adb shell content insert --uri content://settings/system --bind name:s:accelerometer_rotation --bind value:i:0
Run Code Online (Sandbox Code Playgroud)

然后

adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:1
Run Code Online (Sandbox Code Playgroud)

要么

adb shell content insert --uri content://settings/system --bind name:s:user_rotation --bind value:i:3
Run Code Online (Sandbox Code Playgroud)

有没有办法从配置标志直接执行它,从启动处理屏幕方向?

android raspberry-pi raspberry-pi3 android-things

10
推荐指数
1
解决办法
4637
查看次数