我尝试在启动时使用终端以 sudo 身份运行可执行文件,但遇到一些问题。我在其他答案中找不到解决方案,所以我打开了这个。我使用的是 Raspberry Pi 3 B+ 以及 Raspbian Stretch 桌面版和从 Raspberry Pi 官方网站下载的推荐软件。
我有一个需要使用 sudo 运行的可执行文件(我使用 Pigpio 库通过 SPI 与另一个硬件进行通信,如果我不使用 sudo 运行该可执行文件,则 Pigpio 将无法工作)。我想要实现的是,当 Pi 完成启动图形界面时,它将运行 LXTerminal 并执行“sudo home/pi/myfolder/myprogram”。
我试过了:
sudo nano ~/.config/autostart/myprogram.desktop
[Desktop Entry]
Encoding=UTF-8
Type=Application
Name=myprogram
Exec=lxterminal -e "sudo /home/pi/myfolder/myprogram"
Terminal=true
sudo chmod a+r ~/.config/autostart/myprogram.desktop
Run Code Online (Sandbox Code Playgroud)
还尝试过:
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
lxterminal --command="sudo /home/pi/myfolder/myprogram"
Run Code Online (Sandbox Code Playgroud)
这两种方法都在启动时打开了lxterminal,但没有执行我的程序。谁能帮我吗?
我创建了一个流光溢彩的克隆作为个人学习项目。它使用USB网络摄像头从电视捕获所需的RGB数据;它目前功能齐全。我的问题是我的 RasPi 目前是无头的,我希望能够在 HDMI 输出上显示内容;例如,用 RGB(0,255,0) 填充屏幕,用于从网络摄像头图像中查找电视屏幕。
目前,我正在使用一个名为 Hdmi 的类。它使用 PyGame surfarray 允许在帧缓冲区上显示 NumPy 数组。当使用“sudo $(which python) webcambilight.py”运行代码时,这工作得很好。但使用系统时,明显没有界面。它不会给出任何错误;它只是停止运行。如果我删除 Hdmi 类,一切正常。
这将问题缩小到这段代码:
os.putenv('SDL_FBDEV', '/dev/fb0')
os.putenv('SDL_VIDEODRIVER', 'fbcon')
pygame.display.init()
Run Code Online (Sandbox Code Playgroud)
我对Linux不是很有经验,但我的理解是从systemd运行时没有fb0?我知道服务通常是在后台运行的。但这是一个特殊情况。我想在设备打开时自动启动该服务。理想情况下,我永远不需要使用 SSH 登录设备。
根据 StackOverflow 上的另一个问题/答案,我在 .service 文件中尝试了此代码。
Environment="DISPLAY=:0"
Environment="XAUTHORITY=/home/pi/.Xauthority"
Run Code Online (Sandbox Code Playgroud)
这没有帮助,我认为这是因为我没有显示器。fb0 和 fbcon 并没有真正显示在 display=:0 上,对吗?
我的 .service 文件的内容当前为:
[Unit]
Description=Webcambilight
After=network.target
[Service]
Type=idle
WorkingDirectory=/home/pi/webcambilight
ExecStart=/home/pi/.virtualenvs/py3cv4/bin/python -u webcambilight.py
[Install]
WantedBy=multi-user.target
Run Code Online (Sandbox Code Playgroud)
笔记!当 Hdmi 未使用时,此功能正常工作。但我很想用它。现在,如果我不小心移动了网络摄像头或电视,我将不得不使用电视打开 YouTube 并播放绿屏视频,然后按下树莓派上的校准按钮(这是一个 GPIO 按钮)。
我想要做的是将输入更改为连接到 RasPi 的 HDMI 4。然后,通过按下 GPIO 校准按钮,我的 Hdmi 类将用 (0,255,0) 填充整个 1920x1080 帧缓冲区。
Sooo..关于在运行 systemd …
我已经使用普通的apt-get 安装方法在 Raspberry Pi 3 上安装了 Qt 和 Qtcreator 。一切似乎都工作正常,除了当我尝试构建声明性相机示例或其他多媒体示例时,我收到一条错误消息module "QtMultimedia" is not installed。然后弹出空白的白色应用程序窗口。
我已经尝试安装和重新安装所有必需的软件包,例如libqt5multimedia5,,它只是说它们安装了最新版本。qtmultimedia5-devetc
有没有人在树莓派上成功地让qt多媒体工作?
编辑:
我尝试使用建议的解决方案:
sudo apt-get install qtdeclarative5-qtmultimedia-plugin
这给了我一个错误:
E: Unable to locate package qtdeclarative5-qtmultimedia-plugin
我们正在学校里做一个需要进行基本图像处理的项目。我们的目标是为Raspberry Pi使用每个视频帧并进行实时图像处理。
我们试图将raspistill包含在我们的python程序中,但到目前为止没有任何效果。我们项目的目标是在图像处理的帮助下设计一辆遵循蓝色/红色/任何彩色线条的RC汽车。
我们认为制作一个进行所有图像处理必要的python程序是一个好主意,但是目前我们正努力将记录的图像引入python程序中。有没有办法用picamera做到这一点,还是我们应该尝试其他方式?
对于任何好奇的人,这就是我们程序当前的外观
while True:
#camera = picamera.PiCamera()
#camera.capture('image1.jpg')
img = cv2.imread('image1.jpg')
width = img.shape[1]
height = img.shape[0]
height=height-1
for x in range (0,width):
if x>=0 and x<(width//2):
blue = img.item(height,x,0)
green = img.item(height,x,1)
red = img.item(height,x,2)
if red>green and red>blue:
Run Code Online (Sandbox Code Playgroud)
预先感谢炭疽。
我正在尝试在带有 Raspbian Jessie 的 Raspberry Pi 3 上安装 Jekyll。
我已经有了最新的 LTS nodejs 4.4.7 并且我已经通过执行以下操作将 Gem 更新到最新版本:
sudo gem update --system
Run Code Online (Sandbox Code Playgroud)
然后我通过执行以下操作安装了 Ruby:
sudo apt-get install ruby-full
Run Code Online (Sandbox Code Playgroud)
然而,做完之后
ruby -v
Run Code Online (Sandbox Code Playgroud)
我得到的版本号为 ruby 2.1.5。最新版本是 2.3.1。
我尝试通过从 ruby 的网站下载源代码来安装源代码,然后在解压缩源文件夹后运行以下命令:
./configure
make
sudo make install
Run Code Online (Sandbox Code Playgroud)
做完之后,我去看看ruby是什么版本,还是2.1.5。
之前有没有其他人在 Raspberry Pi 3 上玩过 Jekyll?虽然我有 ruby 2.1.5,但我在运行时收到此错误消息:
jekyll -v
Run Code Online (Sandbox Code Playgroud)
“依赖错误:哎呀!看起来你没有安装分类器或其依赖之一。为了使用当前配置的 Jekyll,你需要安装这个 gem……”
我该如何解决这个问题?(对不起,我是新手。)
我正在尝试创建一个初始化树莓和arduino之间串行连接的类.该类还应该能够通过已建立的串行连接进行读写.
我使用的代码来自微软开发者网站.
using Windows.Storage.Streams;
using Windows.Devices.Enumeration;
using Windows.Devices.SerialCommunication;
public async void Serial()
{
/* Find the selector string for the serial device */
string aqs = SerialDevice.GetDeviceSelector("UART0");
/* Find the serial device with our selector string */
var dis = await DeviceInformation.FindAllAsync(aqs);
/* Create an serial device with our selected device */
SerialDevice SerialPort = await SerialDevice.FromIdAsync(dis[0].Id);
/* Configure serial settings */
SerialPort.WriteTimeout = TimeSpan.FromMilliseconds(1000);
SerialPort.ReadTimeout = TimeSpan.FromMilliseconds(1000);
SerialPort.BaudRate = 9600;
SerialPort.Parity = SerialParity.None;
SerialPort.StopBits = SerialStopBitCount.One;
SerialPort.DataBits …Run Code Online (Sandbox Code Playgroud) 我正在尝试创建一个脚本来重新加载 bashrc 一次,但它没有用。
#!bin/bash
source ~/.bashrc
rm reloader.sh
Run Code Online (Sandbox Code Playgroud) 我试图将我的汇编代码与我的C代码分开,因为有关于另一个问题的建议,但我收到此错误:
arm-linux-gnueabihf-gcc -O0 -g3 -Wall -c -fmessage-length=0 -mfpu=neon -o src/ASM.o ../src/ASM.c
In file included from ../src/ASM.c:1:0:
../src/asm.S:1:12: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token
mul64x64asm:
^
Run Code Online (Sandbox Code Playgroud)
我尝试在一堆地方放一个分号,但它没有解决我的问题,即使它与这个问题无关,任何帮助都会受到赞赏.这是我的ASM.c和asm.S文件:
ASM.c
#include "asm.S"
int main(void) {
extern void mul64x64asm();
mul64x64asm();
return 1;
}
Run Code Online (Sandbox Code Playgroud)
asm.S
mul64x64asm:
MOVW R0,0x12f4
MOVT R0,0x5678
Run Code Online (Sandbox Code Playgroud)
更新:我尝试了建议的答案,最后得到了这个
arm-linux-gnueabihf-as -g --gstabs -o src/asm.o ../src/asm.S
arm-linux-gnueabihf-gcc -O0 -g3 -Wall -c -fmessage-length=0 -mfpu=neon -o src/ASM.o ../src/ASM.c
arm-linux-gnueabihf-gcc -o ASM src/ASM.o src/asm.o ../src/asm.S
src/ASM.o: In function `main':
/home/yunus/eclipse-workspace/ASM/Debug/../src/ASM.c:4: undefined reference …Run Code Online (Sandbox Code Playgroud) 我正在使用Raspberry Pi 3并使用Python控制三个LED.我可以说我对Python很好.这是我的代码:
import RPi.GPIO as GPIO
import time
#GPIO Pins
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)
GPIO.setup(17,GPIO.OUT)
GPIO.setup(27,GPIO.OUT)
GPIO.setup(22,GPIO.OUT)
def led(color,state):
if state == "on":
if color == "g": #green
GPIO.output(27,GPIO.HIGH)
elif color == "y": #yellow
GPIO.output(22,GPIO.HIGH)
elif color == "r": #red
GPIO.output(17,GPIO.HIGH)
print ("LED on")
elif state == "off":
if color == "g":
GPIO.output(27,GPIO.LOW)
elif color == "y":
GPIO.output(22,GPIO.LOW)
elif color == "r":
GPIO.output(17,GPIO.LOW)
print ("LED off")
while True:
leds_col = input("Color (r, g, y): ")
leds_stat = input("On or Off: ") …Run Code Online (Sandbox Code Playgroud) raspberry-pi3 ×10
python ×2
python-3.x ×2
raspberry-pi ×2
adb ×1
arm ×1
assembly ×1
asynchronous ×1
bash ×1
c ×1
c# ×1
command-line ×1
eclipse ×1
executable ×1
jekyll ×1
linux ×1
opencv ×1
pygame ×1
qt ×1
qtmultimedia ×1
raspbian ×1
startup ×1
sudo ×1
systemd ×1
terminal ×1
usb ×1