zoukankan      html  css  js  c++  java
  • 树莓派

    树莓派使用

    树莓派的安装

    • 根据说明书组装设备
    • 安装摄像头,如果后期无法使用,可能需要先使能摄像头。使用raspistillxdg-open拍摄和查看照片。
    • 参考网页

    树莓派连接外设

    • 使用HDMI线连接显示屏

    • 使用USB口连接无线鼠标

    • 使用蓝牙连接无线键盘

    • 连接无线路由器

      • 选Router模式,在无线路由器通电的状态下reset,发现开放wifi(TPlink-XXXX)连接后进入管理页面tplogin.cn,配置登陆密码
      • 进入登陆管理页面,设置无线密码后重新尝试连接

    树莓派ssh管理

    • 开启树莓派ssh服务

      • sudo raspi-config 在系统配置中选 Interfacing Options 开启ssh
      • 默认用户名pi,密码 raspberry
      • 可选:开启root账号
    • 网线直连PC与树莓派,检查两者连接状态

    • 在windows下使用ssh命令(或 putty、winscp工具)连接树莓派 ssh -p22 pi@XXX.XXX.XXX.XXX。此后可在PC端直接操作树莓派,显示屏等外设可不使用。

    • :树莓派与计算机之间的网线直连可能不稳定,当ping不通时,可尝试检查网线连接是否正常,插拔一两次网线可能解决问题。

    树莓派识别二维码

    • 使用python完成摄像头拍照获取二维码、二维码识别、与应用服务器的通信传输二维码代表的字符串信息,可以调用qrcodezxing等库或者qrencodezbarimg工具。参考
    • 通过显示屏了解相机的取景位置,从而可以实现扫描的正确性。
    • 将解析和通信的python代码设置为开机自启动,可以尝试在/etc/init.d 目录下创建相应文件。

    参考代码(树莓派中使用python2,需要将raw_input改为input):

    #coding=utf-8
    import sys
    import socket
    import time 
    import os, signal, subprocess
    
    def scan1(times):
        os.system("raspistill -w 2048 -h 2048 -q 8 -t 2000 -o /home/pi/Pictures/test{}.png".format(times)) #-rot 180
    
    def erzeugen():
        text=raw_input(u"enter text QRCode: ")
        os.system("qrencode -o /home/pi/Pictures/test1.png '"+ str(text) +"'")
        # print (u"QRCode in: "+strfile1+"test1.png")
    
    def lesen(times):
        try:
            zbarcam=subprocess.Popen("zbarimg --raw /home/pi/Pictures/test{}.png".format(times), stdout=subprocess.PIPE, shell=True, preexec_fn=os.setsid)
            qrcodetext=zbarcam.stdout.read()
        except Exception as e:
            print(e)
            qrcodetext=""
        if qrcodetext=="":
            print(u"qrcodetext is empty")
            return ""
        qrcodetext = qrcodetext.strip()
        print('qrcodetext:
    ',qrcodetext)
        try:
            os.killpg(zbarcam.pid, signal.SIGTERM)
        except Exception as e:
            print(e)
            print(u"zbarcam stopped unsuccessfully...")
        return (qrcodetext)
    
    host = '169.254.136.44'
    port = 8899
    try:
        c = socket.socket(socket.AF_INET, socket.SOCK_STREAM)  #TCP
        c.connect((host, port))
        t = -1
        while True:
            print ("1: qrcode create
    2: qrcode identify
    3: exit")
            select=int(raw_input(u"please choose: "))
            t += 1
            if select == 1:
                erzeugen()
                time.sleep(1)
                qrcodetext = lesen('1')
            elif select == 2:
                scan1(str(t))
                time.sleep(1)
                qrcodetext = lesen(str(t))
            else:
                break
            if qrcodetext =='exit':
                break
            c.send(qrcodetext.encode())
    except KeyboardInterrupt:
        sys.exit(1)
    except socket.error as e:
        print(e)
        sys.exit(1)
    

    创建文件myfile.txt作为签名信息

    echo abcdefghijklmnopqrstuvwxyz > myfile.txt
    

    利用私钥对文件内容进行签名

    openssl dgst -sha1 -sign myprivate.pem -out sha1.sign myfile.txt
    

    使用公钥信息验证签名

    openssl dgst -sha1 -verify mypublic.pem -signature sha1.sign myfile.txt
    
  • 相关阅读:
    JS LeetCode 1423. 可获得的最大点数简单题解
    SpringBoot 学集 (第六章) Docker
    Linux 学记 (第三章)
    Linux 学记 (第二章)
    Linux 学记 (第一章)
    SpringBoot 学集 (第五章) Web开发续
    SpringBoot 学集 (第四章)Web开发
    SpringBoot 学集 (第三章) 日志框架
    SpringBoot 学集 (第二章) 配置文件
    SpringBoot 学集 (第一章)
  • 原文地址:https://www.cnblogs.com/joeat1/p/12198352.html
Copyright © 2011-2022 走看看