标签: raspberry-pi

Mono中的DateTime.ToString返回无效日期("00/734718/0001 01:41:38")

我试图使用raspbian发行版("Debian GNU/Linux wheezy/sid")获得单声道(Debian 2.10.8.1-5)在我的覆盆子pi上正常运行.我用apt-get install mono-complete安装了mono.

但是,我遇到了一个我无法弄清楚的有趣问题.DateTime.ToString()方法返回无效字符串.

您可以在下面找到我的示例程序和控制台输出:

using System;

namespace MonoTest
{
    class Program
    {
        static void Main(string[] args)
        {
            DateTime now = DateTime.Now;
            Console.WriteLine("Year: " + now.Year);
            Console.WriteLine("Month: " + now.Month);
            Console.WriteLine("Day: " + now.Day);
            Console.WriteLine("DayOfWeek: " + now.DayOfWeek);
            Console.WriteLine("DateTime.Now: " + DateTime.Now);
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd"));
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

输出:

pi@raspberrypi ~/bin $ mono MonoTest.exe
Year: 2012
Month: 8
Day: 3
DayOfWeek: Friday
DateTime.Now: 00/734718/0001 01:41:38
0001-00-734718
Run Code Online (Sandbox Code Playgroud)

有趣的是,734718似乎是自01/01/0001以来直到今天所经过的天数.我已尝试在第二块板上进行全新安装,但遇到同样的问题.

有没有人知道这里的问题是什么以及如何说服DateTime.ToString()返回正确的值?

更新(2012年8月4日):经过长时间挖掘单声道源代码后,我能够将问题追溯到System.Math.Floor.显然,它总是返回0.我将测试程序改为简单:

static void Main(string[] args)
{
    Console.WriteLine("Floor(1.5): " + System.Math.Floor(1.5)); …
Run Code Online (Sandbox Code Playgroud)

mono datetime raspberry-pi

12
推荐指数
2
解决办法
3735
查看次数

轻量级詹金斯的替代品?

我正在尝试使用Raspberry Pi作为家庭开发服务器.我需要在它上面运行一个构建服务器.

Jenkins速度非常慢,只需加载10-15秒即可加载启动页面,当我尝试访问管理页面时,我必须在100%cpu负载运行15分钟后停止Jenkins服务器.

这是无法接受的.

当我只使用ant + git构建并希望为少数项目存档构建时,什么被认为是Jenkins的最佳替代品?

有没有可能加快我目前的Jenkins安装速度?我目前正在使用Oracle Java 8 JDK for ARM并尝试使用Jenkins v1.447.2(我使用默认Rasbian软件包源代码获得的"apt-get install jekins"版本)以及v1.502(最新版本,速度更快)但仍然无法忍受).

java performance jenkins raspberry-pi raspbian

12
推荐指数
0
解决办法
7400
查看次数

无法启动VNC服务器,因为:0已被占用

我有Raspberry Pi和Raspbian OS.安装VNC后,我试图启动服务器并返回:

 ~ $ vncserver :0

Warning: raspberrypi:0 is taken because of /tmp/.X0-lock
Remove this file if there is no X server raspberrypi:0
A VNC server is already running as :0
Run Code Online (Sandbox Code Playgroud)

如果我删除该临时文件,请返回:

~ $ vncserver :0

Warning: raspberrypi:0 is taken because of /tmp/.X11-unix/X0
Remove this file if there is no X server raspberrypi:0
A VNC server is already running as :0
Run Code Online (Sandbox Code Playgroud)

如果我再次删除,服务器启动,但通过VNC客户端显示一个普通的灰色屏幕.总之,之后:

~ $ sudo rm /tmp/.X11-unix/X0
~ $ sudo rm /tmp/.X0-lock
~ $ vncserver :0

New 'X' desktop …
Run Code Online (Sandbox Code Playgroud)

vnc raspberry-pi raspbian

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

通过USB连接Android设备控制Raspberry Pi

我有一个运行自定义服务器的Raspberry Pi没有连接到互联网(离线系统).

我想通过USB线将Android设备连接到rPi并与之通信.

由于Raspberry Pi未连接到互联网,因此它没有IP地址(通过DHCP提供).

如何使用通过USB连接的Android设备与rPi通信?

也许是本地DHCP服务器?

谢谢

android tethering raspberry-pi raspbian

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

从Php执行Python脚本

我的覆盆子pi上有一个PHP网页,带有2个按钮(打开和关闭)按钮按钮重定向到On.php关闭按钮重定向到Off.php在"/ usr/lib/cgi-bin"我有一个python脚本我想执行(script.py)我可以通过键入从终端完美地执行它

cd /usr/lib/cgi-bin
sudo python script.py
Run Code Online (Sandbox Code Playgroud)

如果我从终端这样做,它的工作原理.

问题是我的"/ var/www"文件夹中的PHP文件(On.php).这就是我写的:

<?php
exec('cd /usr/lib/cgi-bin');
exec('sudo python script.py');
?>
Run Code Online (Sandbox Code Playgroud)

为什么脚本从终端执行,而不是从我的PHP执行?

php python apache2 execute raspberry-pi

12
推荐指数
1
解决办法
4万
查看次数

无法连接到Raspberry Pi上的BLE设备

我正在尝试连接到Raspberry Pi 2上的BLE设备(心率传感器,Polar H7).我使用的是上一版本的bluez(5.35):http://www.bluez.org/download/ 但是,当我尝试连接使用时gatttool,我总是有"连接被拒绝"错误.

这是我做的:

pi@raspberrypi ~ $ sudo su
root@raspberrypi:/home/pi# hciconfig dev
hci0:   Type: BR/EDR  Bus: USB
        BD Address: 5C:F3:70:69:54:3D  ACL MTU: 1021:8 SCO MTU: 64:1
        DOWN
        RX bytes:616 acl:0 sco:0 events:34 errors:0
        TX bytes:380 acl:0 sco:0 commands:34 errors:0

root@raspberrypi:/home/pi# hciconfig dev up
root@raspberrypi:/home/pi# hcitool lescan
LE Scan ...
00:22:D0:6D:E0:E6 (unknown)
00:22:D0:6D:E0:E6 Polar H7 6DE0E61C
^Croot@raspberrypi:/home/pi# hcitool lecc 00:22:D0:6D:E0:E6
Connection handle 64
root@raspberrypi:/home/pi# gatttool -b 00:22:D0:6D:E0:E6 -I
[00:22:D0:6D:E0:E6][LE]> connect
Attempting to connect to …
Run Code Online (Sandbox Code Playgroud)

bluetooth raspberry-pi bluetooth-lowenergy bluez

12
推荐指数
3
解决办法
1万
查看次数

Python按钮功能奇怪,不做同样的事情

我目前有两个连接到我的Raspberry Pi的按钮(这些是带有环形LED的那些)并且我正在尝试执行此代码

#!/usr/bin/env python
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17, GPIO.OUT) #green LED
GPIO.setup(18, GPIO.OUT) #red LED
GPIO.setup(4, GPIO.IN, GPIO.PUD_UP) #green button
GPIO.setup(27, GPIO.IN, GPIO.PUD_UP) #red button

def remove_events():
        GPIO.remove_event_detect(4)
        GPIO.remove_event_detect(27)

def add_events():
        GPIO.add_event_detect(4, GPIO.FALLING, callback=green, bouncetime=800)
        GPIO.add_event_detect(27, GPIO.FALLING, callback=red, bouncetime=800)

def red(pin):
        remove_events()
        GPIO.output(17, GPIO.LOW)
        print "red pushed"
        time.sleep(2)
        GPIO.output(17, GPIO.HIGH)
        add_events()

def green(pin):
        remove_events()
        GPIO.output(18, GPIO.LOW)
        print "green pushed"
        time.sleep(2)
        GPIO.output(18, GPIO.HIGH)
        add_events()

def main():
    while True:
        print "waiting"
        time.sleep(0.5)

GPIO.output(17, GPIO.HIGH)
GPIO.output(18, GPIO.HIGH)
GPIO.add_event_detect(4, …
Run Code Online (Sandbox Code Playgroud)

python gpio raspberry-pi

12
推荐指数
1
解决办法
361
查看次数

关于Raspberry PI Rev. 1的Qt-QML JIT

我和我的朋友正在研究由Raspberry PI B +和一个小触摸屏驱动的便携式互联网收音机.我正在使用Qt-5.9开发接口,我已经为PI的ARMv6 CPU交叉编译了.我的界面正在使用QML,所以当我启动我的应用程序时,每一个工作但QML动画都是滞后的.因此控制台告诉我QML JIT没有启用(JIT is disabled for QML. Property bindings and animations will be very slow. Visit https://wiki.qt.io/V4 to learn about possible solutions for your platform.),所以我在给定的页面上查找了关于V4引擎的信息,经过大约两周的试用,我发现问题是缺少使用Thumb的可能性-1指令集,V4需要,以及在Pi上运行的Raspbian Jessie的HardFP配置.所以现在我认为如果我让交叉编译器使用Thumb-1集合它会工作.我尝试了很多,最后我遇到了两个问题.

  1. 当我-mthumb在命令行中使用该标志时,我收到此错误:sorry, unimplemented: Thumb-1 hard-float VFP ABI.我需要Thumb-1,我无法更改整个操作系统的Hard-Float实现,并且ARMv6没有合适的编译器标志来禁用VFP.
  2. 当我-mthumb-interwork在命令行中使用该标志时,编译工作,但由于ABI设置,可执行文件不会更改(https://gcc.gnu.org/onlinedocs/gcc-4.8.5/gcc/ARM-Options .html #ARM-Options)(-mthumb-interwork: ... In AAPCS (the ABI) configurations this option is meaningless.).我尝试了所有可能的ABI但没有一个工作并编译正在运行的程序.

我也读过关于RPi的一些补丁,但很久以前它们被包含在上游Qt中.

我稍微修改了编译器参数(文件:QT/qtbase/mkspecs/devices/linux-rasp-pi-g ++/qmake.conf):

QMAKE_CFLAGS           += \
                      -mthumb \
                      -mfpu=vfp \
                      -mtune=arm1176jzf-s \
                      -march=armv6zk \
                      -mabi=aapcs-linux
Run Code Online (Sandbox Code Playgroud)

(此配置不起作用)

我使用以下参数配置QT:

./configure -release -opengl …
Run Code Online (Sandbox Code Playgroud)

c++ qt jit qml raspberry-pi

12
推荐指数
1
解决办法
942
查看次数

Docker运行不显示任何输出

我在raspberry-pi上安装了docker(通过ssh连接)安装成功。

但是运行docker run hello-world不会产生任何输出。

请注意,我第一次收到有关安装映像的其他消息

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world ad0f38092cf2: Pull complete Digest: sha256:e366bc07db5e8a50dbabadd94c2a95d212bc103e3557e47df8a2eebd8bb46309 Status: Downloaded newer image for hello-world:latest

但是hello world脚本没有实际输出

注意我使用命令安装了docker curl -sSL https://get.docker.com | sh

我也尝试了以下命令

sudo usermod -aG docker pi
sudo systemctl start docker
sudo docker run hello-world
Run Code Online (Sandbox Code Playgroud)

尝试了以下命令docker ps -a

CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS                           PORTS               NAMES
734dd8f733d7        hello-world         "/hello"            About a minute ago   Exited (139) 59 seconds ago                          thirsty_bhaskara
Run Code Online (Sandbox Code Playgroud)

ssh raspberry-pi docker

12
推荐指数
3
解决办法
1万
查看次数

输入图像中的通道数无效

我在运行我的程序时收到一个错误,我特别想到 OpenCV 库中的颜色操作。

我正在尝试构建一个程序,该程序从 Raspberry Pi 相机获取视频源并对其进行分析。我想找到视频中最亮的点并计算该点与视频源中心的距离和角度。

我正在做的项目将相机指向一个暗盒的中心,有一个移动的光点。

我在 Raspberry Pi 3 以及raspicam库上使用 OpenCV 4.0.0 和 C++ 。

我从指南中获取指导,但我使用的是 C++ 和视频源,而不是 Python 和静态图像。

    raspicam::RaspiCam_Cv Camera;
    cv::Mat image;
    cv::Mat gray;
    int nCount=100;
    int nR, nC;         // numRows, numCols
    cv::Point imgMid;
    Vect toCenter;

    // for recording brightest part of img
    double minVal, maxVal;
    cv::Point minLoc, maxLoc;

    Camera.set(cv::CAP_PROP_FORMAT, CV_8UC1);

    #ifdef DEBUG
    cout << "Opening camera..." << endl;
    if (!Camera.open()) {
        cerr << "Error opening the camera" << endl;
        return …
Run Code Online (Sandbox Code Playgroud)

c++ opencv raspberry-pi

12
推荐指数
1
解决办法
3万
查看次数