我正在我的Raspberry Pi上运行一个应用程序,它在shell脚本中包含以下行,
sleep 1800
Run Code Online (Sandbox Code Playgroud)
然后我发现Raspberry Pi没有办法保留时间.如何添加驱动程序和/或应用程序以获取时间?
我正在尝试实现adafruit为其中一个为覆盆子pi设计的gps单元提供的示例脚本.代码如下:
==============
import gps
# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
while True:
try:
report = session.next()
# Wait for a 'TPV' report and display the current time
# To see all report data, uncomment the line below
# print report
if report['class'] == 'TPV':
if hasattr(report, 'time'):
print report.time
except KeyError:
pass
except KeyboardInterrupt:
quit()
except StopIteration:
session = None
print "GPSD has terminated"
Run Code Online (Sandbox Code Playgroud)
==============
所以我将"#!/ usr/bin/python -tt"添加到"gps.py"文件的顶部,然后"chmod u + x …
我在Raspberry pi上运行Raspbian.标准终端是LXDE
我很好,但面板栏弹出我正在播放的视频.
有没有办法禁用它,如果它也可以在视频停止运行后重新启动(从脚本),这将是完美的.
我找到的唯一答案是使用
pkill -9 lxpanel
Run Code Online (Sandbox Code Playgroud)
但是我也发现kill -9非常不精确,也是p命令.
我的Python代码适用于运行Ubuntu的32位intel机器,我需要在Raspberry Pi上运行此代码.我需要某种交叉编译吗?我有python中包含的32位.so文件.
我想在我的Raspberry上使用C#开始SPI通信。bcm2835库支持所需的命令,例如:
bcm2835_spi_begin()bcm2835_spi_end()在C中,您必须执行,#include < bcm2835.h >但在C#using bcm2835;中不起作用。
RaspberryPiDotNet已安装,并且bcm2835库也已安装。
可以通过GPIOMem使用bcm2835库的命令来控制GPIO引脚。
C#如何使用bcm2835的SPI命令?网上的所有内容都适用于C或C ++。
我遇到了当前Python脚本的问题.'progress'变量的目的是在通过其中一个if循环时获取特定值.但是,该程序永远不会超过第一个if语句.看起来好像每个if语句都有自己的变量叫做'progress'.有人可以帮帮我吗?见下面的代码.
from bottle import run, route, template, error, static_file
import RPi.GPIO as GPIO
import time
switch1 = 21
switch2 = 20
switch3 = 26
switch4 = 16
switch5 = 19
led1 = 13
led2 = 12
led3 = 6
led4 = 5
led5 = 25
GPIO.setmode(GPIO.BCM)
GPIO.setup(switch1, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch2, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch3, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch4, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(switch5, GPIO.IN, pull_up_down=GPIO.PUD_UP)
GPIO.setup(led1, GPIO.OUT)
GPIO.setup(led2, GPIO.OUT)
GPIO.setup(led3, GPIO.OUT)
GPIO.setup(led4, GPIO.OUT)
GPIO.setup(led5, GPIO.OUT)
@route("/")
def hello():
progress = 0
while True:
if …Run Code Online (Sandbox Code Playgroud) 我正在研究一个使用python读取树莓派数字输入的项目.我想将其中一个按钮变成一个切换按钮,因为只要按下它就会在1和0之间切换一个值.一切都工作正常,除了部分:
if(a == 0.0):
a = 1.0
if(a == 1.0):
a = 0.0
Run Code Online (Sandbox Code Playgroud)
似乎这应该与其余的代码一起使用,只要按下按钮,值就会在1和0之间切换,但每次都打印为0.0,是否有人知道这是为什么?
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setup(4, GPIO.IN, pull_up_down = GPIO.PUD_DOWN)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_UP)
a = 0.0
b = 0.0
c = 0
while True:
if(GPIO.input(4) ==1 and c ==0):
print 'Button 1 Pressed'
if(a == 0.0):
a = 1.0
if(a == 1.0):
a = 0.0
c = 1
print a
if(GPIO.input(4) !=1):
c = 0
if(GPIO.input(24) ==0):
print 'Button 2 Pressed'
Run Code Online (Sandbox Code Playgroud) 美好的一天,
我在Master(Raspberry pi 2B,使用Lazarus)和Slave - Arduino Nano之间进行I2C通信.在Arduino我定义了
typedef union
{
float Temperature;
uint8_t bytes[4];
} floatuint;
floatuint fu;
Run Code Online (Sandbox Code Playgroud)
我已经定义了覆盆子pi
TFloatUint = packed record
case Boolean of
False: (dabDouble: Double);
True: (dabByte: packed array[0..3] of cuint8);
end;
Run Code Online (Sandbox Code Playgroud)
使用命令
count := FpRead(I2DeviceHandle, fl.dabByte, 4);
Run Code Online (Sandbox Code Playgroud)
我收到字节数组的相同值,但fl.dabDouble显示不同的结果.
例如:
fu.Temperature = 19.19;
fu.bytes = (0, 128, 153, 65);
fl.dabByte = (0, 128, 153, 65);
fl.dabDouble = 2.6656892163191751e-314
Run Code Online (Sandbox Code Playgroud)
我犯了哪个错误?
我在Ubuntu 14.04中使用GCC编译了一个C代码,除其他外,创建一个文件,写入8个字节,然后关闭它.该代码在我的i7 64位pc中运行良好.问题是,当我在32位架构(raspberry pi 2 with raspbian)上编译和执行我的代码时,此操作会创建一个大小为4294967304字节的文件.我不知道出了什么问题.奇怪的是,我的程序创建3个文件的方式应该是空的,但每个文件的大小为4 Gb,而我的可用内存只有8 Gb.这让我相信我打破了文件系统(ext4),但我不知道为什么.代码是这样的:
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
int main(int argc, char *argv[])
{
int outImpFile = open(argv[1], O_RDWR | O_LARGEFILE | O_CREAT, 0);
long long int imp = 89;
write(outImpFile, &imp, sizeof(long long int));
close(outImpFile);
}
Run Code Online (Sandbox Code Playgroud)
当我用ghex打开创建的文件时,我只看到8个字节,但是当我使用hexdiff时,开头有很多空字节,最后写了8个字节.