标签: raspberry-pi

Raspberry Pi没有IP地址?

我想通过SSH将一些文件从我的Mac传输到我的Raspberry Pi,但是当我尝试在lx终端中使用ifconfig命令找到Raspberry Pi的IP地址时,每个人都说的行告诉你IP地址不存在! ,它刚刚消失.我的终端看起来像这样:

      eth0      Link encap:Ethernet  HWaddr b8:27:eb:63:40:b8
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:27224 errors:0 dropped:0 overruns:0 frame:0
      TX packets:733 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:2801074 (2.6 MiB)  TX bytes:107019 (104.5 KiB)

      lo        Link encap:Local Loopback
      inet addr:127.0.0.1  Mask:255.0.0.0
      UP LOOPBACK RUNNING  MTU:16436  Metric:1
      RX packets:0 errors:0 dropped:0 overruns:0 frame:0
      TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
Run Code Online (Sandbox Code Playgroud)

因为这不是我实际的Raspberry Pi,所以请不要从中扣除.只是因为我无法从Raspberry Pi传输文件,我无法获得实际文本的副本.

很抱歉代码搞砸了,它看起来就像这个网站:http: //learn.adafruit.com/adafruits-raspberry-pi-lesson-3-network-setup/finding-your-pis-ip-address

除了没有第2行的ethO.

linux ip raspberry-pi

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

如何通过检测按键来打破Python中的这个循环

from subprocess import call
try:
    while True:
        call (["raspivid -n -b 2666666.67 -t 5000 -o test.mp4"],shell=True)
        call (["raspivid -n -b 2666666.67 -t 5000 -o test1.mp4"],shell=True)
except KeyboardInterrupt:
    pass
Run Code Online (Sandbox Code Playgroud)

当我按任何按钮时,我打算让它打破循环.但是我尝试了许多方法来打破它们并且没有一个工作.

python python-2.7 raspberry-pi

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

Raspbian python代码冻结

我正在运行python代码来进行某些Web抓取,这意味着该代码有时会将数据写入(附加)到文本文件中。有时代码只会冻结,但Shell中不会显示任何错误消息。我想知道这是否更有可能是因为raspbian系统不可靠,还是因为我的代码存在一些隐藏问题。

python raspberry-pi raspbian

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

Raspberry Pi:没有名为nmap的模块

我正在尝试为我的pi安装nmap,我这样做了:

sudo apt-get install nmap
Run Code Online (Sandbox Code Playgroud)

这似乎工作得很好.但是当我打开python会话并尝试导入nmap时:

>>> import nmap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named nmap
Run Code Online (Sandbox Code Playgroud)

这是非常奇怪的,因为我安装得很好,或者至少我认为.任何想法为什么会这样?

python nmap raspberry-pi

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

如何在Windows 10 ioT中设置设备的时间?

我有一个带有Windows 10 ioT的Raspberry Pi 2.如何使用C#设置设备的时间?谢谢

PS如果不可能,我该如何设置时区?

raspberry-pi iot windows-10-iot-core

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

更新网页中的变量,而无需以简单的方式重新加载

同事,

我在raspberry pi中收到序列信息,需要将其发送到浏览器.我使用python捕获数据和烧瓶作为Web框架.我面临的主要问题是如何像每一秒一样自动刷新网页.实际上只刷新变量.正在浏览几个帖子,每个人似乎都指向AJAX/JSON/JQUERY,但对于我的简单应用程序,似乎很多.有什么简单的方法可以做我需要的吗?

python应用程序

from flask import Flask,render_template

app = Flask(__name__)

@app.route('/')
def index():
    return render_template('index.html', ent_direc ="120")

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

在这种情况下ent_direc(固定为120用于测试,但是通过pyserial接收)是我传递给我的html页面的变量,在那里我有java脚本(+ html canvas)来显示一个量表.

index.html - 只是几行

<!DOCTYPE html>
<html>
<body>

<canvas id="canvas" width="400" height="400" style="background-color:#ffffff"></canvas>

<script>
 var canvas = document.getElementById("canvas");
 var ctx = canvas.getContext("2d");
 var radius = canvas.height / 2;
 var ent_direc;
 ctx.translate(radius, radius);
 radius = radius * 0.90;
 drawClock();




function drawClock() {
    drawFace(ctx, radius);
    drawNumbers(ctx, radius);
    drawTime(ctx, radius);
    drawMajorticks(ctx,radius);
    drawMinorticks(ctx,radius);
}
Run Code Online (Sandbox Code Playgroud)

更新:

我一直在努力,但需要更多的帮助.似乎我的服务器端应用程序(app.py)没有"点击"网页index.html.我这样说是因为当我刷新页面时,我确实在网页中看到了我的变量,只是文本.我的所有画布都没有显示.实际上删除了index.html和相同的结果.这是app.py,它基本上从串行接收两个变量并返回它们.我的文件结构是:webapp/app.py templates/index.html static/jquery-1.11.3.min.js …

html python jquery flask raspberry-pi

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

Python 3人工智能:离线STT和TTS

所以我已经使用python编程了一段时间了。我用python创建了一些简单的AI聊天机器人,它们通过文本进行通信。我想将其提升到一个新的水平,类似于个人伴侣AI。我的目标是放在树莓派上(我有一个与pi兼容的便携式充电器,麦克风和扬声器),并使其成为离线AI,可以与之交谈,做笔记,记住信息等。我想知道一种方法将离线STT和TTS引擎合并到我的python程序中。(我发现的大多数STT和TTS引擎都是通过google,亚马逊等在线提供的。)预先感谢。

python raspberry-pi

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

如何使用raspberry Pi或任何其他Linux PC或设备创建虚拟/模拟USB鼠标

我需要创建一个模拟的USB设备.插入PC或平板电脑时,设备应该像USB鼠标一样.动机是检查系统的鼠标驱动程序.我想让其中一个Raspberry Pi USB端口像鼠标一样.

当我将Raspberry Pi USB端口连接到我的PC时,它应该显示鼠标已连接.

如何制作这种虚拟/模拟设备?

此外,我需要监控并向PC发送点击消息.

embedded usb linux-device-driver embedded-linux raspberry-pi

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

与加速度计接口的C分段故障

我使用代码将Raspberry Pi与加速度计连接:

#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <linux/i2c-dev.h>
#include "LSM9DS0.h"

void readBlock(uint8_t command, uint8_t size, uint8_t *data);
void selectDevice(int file, int addr);
void readACC(int  *a);
void writeAccReg(uint8_t reg, uint8_t value);
void enableIMU();
int file;

void  readBlock(uint8_t command, uint8_t size, uint8_t *data)
{
    int result = i2c_smbus_read_i2c_block_data(file, command, size, data);
    if (result != size)
    {
        printf("Failed to read block from I2C.");
        exit(1);
    }
}

void selectDevice(int file, int addr)
{
        if (ioctl(file, I2C_SLAVE, addr) < 0) { …
Run Code Online (Sandbox Code Playgroud)

c accelerometer segmentation-fault raspberry-pi

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

如何使用gpiozero button.when_pressed函数使用输入和输出整数的函数?

我正在尝试对Raspberry Pi上的按钮进行编程,以将一个整数添加到另一个整数,以便可以while通过检查变量mod 2是否为0来在循环中的条件之间来回切换。我本质上是在尝试while通过检查变量是奇数还是偶数来翻转循环中的条件。

我正在尝试使用该gpiozero库的when_pressed函数,但是它似乎无法调用添加和输出整数的函数。

所以,我的代码是:

from gpiozero import Button
btn = Button(17) #the button is wired to GPIO pin 17

def addSurf(a):
    a = a + 1
    return(a)

x = 0
btn.when_pressed = addSurf(x)

while True:
    if x == 0:
        #do some stuff
    else:
        #do some other stuff
Run Code Online (Sandbox Code Playgroud)

为什么我尝试运行此程序,我明白了TypeError: unsupported operand type(s) for +: 'Button' and 'int'

如何使用该btn.when_pressed函数使用输入和输出整数的函数?

或者,是否还有其他[更好的]方法来使按钮在while循环中切换两个状态?

python function while-loop gpio raspberry-pi

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