JavaGuySoho / RaspberryPI

0 stars 0 forks source link

Raspberry 4B #1

Open JavaGuySoho opened 4 years ago

JavaGuySoho commented 4 years ago

https://www.raspberrypi.org/downloads/raspberry-pi-os/

JavaGuySoho commented 4 years ago

Raspberry Pi OS (32-bit) with desktop Image with desktop based on Debian Buster Version:May 2020 Release date:2020-05-27 Kernel version:4.19 Size: 1128 MB

http://downloads.raspberrypi.org/raspios_armhf/images/raspios_armhf-2020-05-28/2020-05-27-raspios-buster-armhf.zip

JavaGuySoho commented 4 years ago

https://sourceforge.net/projects/win32diskimager/

win32diskimager-1.0.0-install.exe

JavaGuySoho commented 4 years ago

https://blog.csdn.net/qq_36398005/article/details/103811154

############################################################################ sudo passwd root sudo passwd --unlock root ############################################################################ sudo vi /etc/ssh/sshd_config

PermitRootLogin without-password ====> PermitRootLogin yes ############################################################################

############################################################################ sudo systemctl enable ssh sudo systemctl start ssh ############################################################################ pi raspberry ############################################################################

python3 –V pip3 -V

############################################################################ sudo apt-get update

sudo apt-get install python3-pip python3-dev

sudo apt-get install python3-pyqt5 ############################################################################

JavaGuySoho commented 4 years ago

https://blog.csdn.net/bona020/article/details/51340756

JavaGuySoho commented 4 years ago

##################### Auto Login ##################### sudo vi /etc/inittab

1:2345:respawn:/sbin/getty 115200 tty1 ==> 1:2345:respawn:/bin/login -f pi tty1 /dev/tty1 2>&1 ##################### Auto Login #####################

JavaGuySoho commented 4 years ago

##################### XWin Login ##################### sudo vi /etc/rc.local

su pi -c startx ##################### XWin Login #####################

JavaGuySoho commented 4 years ago

mkdir ~/cd .config/autostart cd ~/cd .config/autostart ##################### Desktop Login ##################### vi ~/cd .config/autostart/autorun.desktop

[Desktop Entry] Type=Application Exec=python /home/pi/AlphaLogic/main.py ##################### Desktop Login #####################

JavaGuySoho commented 4 years ago

pip3 install pypiwin32

import win32api, win32gui

ct = win32api.GetConsoleTitle() hd = win32gui.FindWindow(0,ct) win32gui.ShowWindow(hd,0)

JavaGuySoho commented 4 years ago

XCommand > <XWindow.XWindow object at 0x000001F1F1612798> XSerial > <XWindow.XWindow object at 0x000001F1F1612798> 51 CMD_SYSTEM_GET_CONFIG HEAD : 51 BODY : callJS({"service":"webInit","data":{"systemMode":"server","comPort":"COM11","baudRate":"38400","byteSize":"8","Parity":"N","stopBits":"1"}}) invoke : PyQt52Web('{"service":"webInit","data":{"systemMode":"server","comPort":"COM11","baudRate":"38400","byteSize":"8","Parity":"N","stopBits":"1"}}');

JavaGuySoho commented 4 years ago

pyinstaller main.py -F

AttributeError: module 'enum' has no attribute 'IntFlag' ????

pip uninstall enum34

JavaGuySoho commented 4 years ago

import ctypes ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("ir2020")

JavaGuySoho commented 4 years ago

1 官网www.pyinstaller.org下载Pyinstaller安装包; 2 解压缩安装包 3 CD到该文件夹,运行sudo su获得root权限 4 执行python3 setup.py install进行安装 5 执行pyinstaller *.py打包为可执行程序,加-F为打包成单个文件 6 在dist文件中找到该文件

JavaGuySoho commented 4 years ago

pip3 install PyInstaller

pyinstaller main.py -w

-F 指定打包后只生成一个exe格式的文件 -D –onedir 创建一个目录,包含exe文件,但会依赖很多文件(默认选项) -c –console, –nowindowed 使用控制台,无界面(默认) -w –windowed, –noconsole 使用窗口,无控制台 -p 添加搜索路径,让其找到对应的库。 -i 改变生成程序的icon图标

JavaGuySoho commented 4 years ago

@E:

@CD E:\Python\AlphaCS\master

@pyinstaller -w -i logo.ico -F main.py XCommand.py XConfig.py XDateTime.py XGlobal.py XImage.py XInstruction.py XPicture.py XPlot.py XPresentation.py XSerial.py XService.py XShared.py XSqlite.py XString.py XSystem.py XWindow.py

@PAUSE

JavaGuySoho commented 4 years ago

pyinstaller -i logo.ico -w -D main.py

JavaGuySoho commented 4 years ago

main.spec

pyinstaller -D main.spec

JavaGuySoho commented 4 years ago

from numba import autojit @autojit

JavaGuySoho commented 4 years ago

Raspibran buster

PyQt 5.11.3

JavaGuySoho commented 4 years ago

https://blog.csdn.net/qq_36470971/article/details/105194082

https://packages.debian.org/search?keywords=buster

libqt5webengine5_5.11.3+dfsg-2+deb10u1_armhf.deb
libqt5webenginecore5_5.11.3+dfsg-2+deb10u1_armhf.deb
libqt5webenginewidgets5_5.11.3+dfsg-2+deb10u1_armhf.deb qtwebengine5-dev_5.11.3+dfsg-2+deb10u1_armhf.deb

JavaGuySoho commented 4 years ago

wget http://mirrors.ustc.edu.cn/debian/pool/main/q/qtwebengine-opensource-src/libqt5webengine-data_5.11.3+dfsg-2+deb10u1_all.deb wget http://mirrors.ustc.edu.cn/debian/pool/main/q/qtwebengine-opensource-src/libqt5webengine5_5.11.3+dfsg-2+deb10u1_armhf.deb wget http://mirrors.ustc.edu.cn/debian/pool/main/q/qtwebengine-opensource-src/libqt5webenginecore5_5.11.3+dfsg-2+deb10u1_armhf.deb wget http://mirrors.ustc.edu.cn/debian/pool/main/q/qtwebengine-opensource-src/libqt5webenginewidgets5_5.11.3+dfsg-2+deb10u1_armhf.deb wget http://mirrors.ustc.edu.cn/debian/pool/main/q/qtwebengine-opensource-src/qtwebengine5-dev_5.11.3+dfsg-2+deb10u1_armhf.deb

JavaGuySoho commented 4 years ago

sudo dpkg -i libqt5webengine-data_5.11.3+dfsg-2+deb10u1_all.deb sudo dpkg -i libqt5webengine5_5.11.3+dfsg-2+deb10u1_armhf.deb sudo dpkg -i libqt5webenginecore5_5.11.3+dfsg-2+deb10u1_armhf.deb sudo dpkg -i libqt5webenginewidgets5_5.11.3+dfsg-2+deb10u1_armhf.deb sudo dpkg -i qtwebengine5-dev_5.11.3+dfsg-2+deb10u1_armhf.deb

JavaGuySoho commented 4 years ago

alias god='cd /cygdrive/d/OSPurvar/SPNet4/_environment'

alias cs='cd /cygdrive/e/Python/AlphaCS'

JavaGuySoho commented 4 years ago

apt list | grep -i qt5

JavaGuySoho commented 4 years ago

https://www.cnblogs.com/leokale-zz/p/13141751.html

JavaGuySoho commented 4 years ago

self.browser = QWebEngineView() self.browser.load(QUrl.fromLocalFile(url))

self.browser.page().runJavaScript('fullName("' + value + '");')

JavaGuySoho commented 4 years ago

树莓派4B:安装QT5开发环境

https://blog.csdn.net/xiaolong1126626497/article/details/106100342?utm_medium=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase&depth_1-utm_source=distribute.pc_relevant.none-task-blog-BlogCommendFromMachineLearnPai2-1.nonecase

JavaGuySoho commented 4 years ago

pyQt5 Qwebview网页调用python方法

https://www.cnblogs.com/6min/articles/10756318.html

import sys, os from PyQt5.QtWidgets import (QApplication, QWidget, QGridLayout) from PyQt5.QtWebKitWidgets import (QWebView) from PyQt5 import (QtCore)

def PyQt52Web(self, str): self.webview.page().mainFrame().evaluateJavaScript("PyQt52Web('%s')" % str)

class handleJS(QtCore.QObject): def init(self): super().init() self.frm = None

@QtCore.pyqtSlot(str)
def process(self, msg):
    self.frm.process(msg)

if name == 'main': app = QApplication(sys.argv) frm = MainFrm() hjs = handleJS() page = frm.webview.page().mainFrame() hjs.frm = frm page.javaScriptWindowObjectCleared.connect( lambda: page.addToJavaScriptWindowObject('observerWindow', hjs) ) sys.exit(app.exec_())

/ JQ / function Web2PyQt5(){ observerWindow.process('hello world'); }

JavaGuySoho commented 4 years ago

https://blog.csdn.net/qq_36398005/article/details/103811154

JavaGuySoho commented 4 years ago

https://mirrors.tuna.tsinghua.edu.cn/debian/pool/main/m/minizip/

sudo apt-get install libminizip1 sudo apt-get install libre2-5

sudo apt install -y python3-pyqt5.qtwebkit sudo apt install -y python3-pyqt5.qtwebengine

https://packages.debian.org/buster/python3-pyqt5.qtwebkit https://packages.debian.org/buster/python3-pyqt5.qtwebengine

JavaGuySoho commented 4 years ago

https://www.raspberrypi.org/forums/viewtopic.php?f=63&t=257914 https://www.raspberrypi.org/forums/search.php?keywords=QtWebEngine&sid=baf45d74bdcf6cce1ac8d57a1cfe54c5

JavaGuySoho commented 4 years ago

树莓派4b安装ubuntu-18.04.3

https://www.jianshu.com/p/8e9dfac49670?from=singlemessage

JavaGuySoho commented 4 years ago

pip install PyQtWebEngine

JavaGuySoho commented 4 years ago

树莓派爱好者基地最新2.0版本64位系统下载地址: 无桌面基础版:链接:https://pan.baidu.com/s/1NQo_5bHM5VCQ0FTKLUiJNQ 密码:jvdy 无桌面加强版:链接:https://pan.baidu.com/s/15To-sFGRX10crdZfx5ZynA 密码:cv6w Xfce桌面版本:链接:https://pan.baidu.com/s/1MpvMzYEEy07Y8p_9_lsaow 密码:lgqp 深度桌面版本:链接:https://pan.baidu.com/s/1Lh2wnvpSyHOuDINpJtA_WA 密码:mnut

JavaGuySoho commented 4 years ago

D:\ProgramData\Anaconda3\Lib\site-packages\matplotlib\mpl-data D:\ProgramData\Anaconda3\Lib\site-packages\matplotlib\mpl-data\fonts\msyh.ttf D:\ProgramData\Anaconda3\Lib\site-packages\matplotlib\mpl-data\matplotlibrc

font.family : sans-serif font.sans-serif : Microsoft YaHei, DejaVu Sans, Bitstream Vera Sans, Computer Modern Sans Serif, Lucida Grande, Verdana, Geneva, Lucid, Arial, Helvetica, Avant Garde, sans-serif

C:\Users\55829.matplotlib tex.cache fontList.json

from matplotlib.font_manager import _rebuild _rebuild()

JavaGuySoho commented 4 years ago

https://stackoverflow.com/questions/38977929/pyinstaller-creating-exe-runtimeerror-maximum-recursion-depth-exceeded-while-ca

@pyinstaller -w -i logo.ico -F main.py common.py server.py XCommand.py XConfig.py XDateTime.py XGlobal.py XImage.py XInstruction.py XObject.py XPicture.py XPlot.py XPresentation.py XSafety.py XSerial.py XShared.py XSqlite.py XString.py XSystem.py XWebkitShared.py XWebkitWindow.py XWindow.py

===> main.spec

import sys sys.setrecursionlimit(5000)

====> pyinstaller main.spec

JavaGuySoho commented 4 years ago

-- mode: python ; coding: utf-8 --

import sys sys.setrecursionlimit(5000)

block_cipher = None

a = Analysis(['main.py', 'common.py', 'server.py', 'XCommand.py', 'XConfig.py', 'XDateTime.py', 'XGlobal.py', 'XImage.py', 'XInstruction.py', 'XObject.py', 'XPicture.py', 'XPlot.py', 'XPresentation.py', 'XSafety.py', 'XSerial.py', 'XShared.py', 'XSqlite.py', 'XString.py', 'XSystem.py', 'XWebkitShared.py', 'XWebkitWindow.py', 'XWindow.py'], pathex=['E:\Python\AlphaCS\webkit'], binaries=[], datas=[], hiddenimports=[], hookspath=[], runtime_hooks=[], excludes=[], win_no_prefer_redirects=False, win_private_assemblies=False, cipher=block_cipher, noarchive=False) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz, a.scripts, a.binaries, a.zipfiles, a.datas, [], name='main', debug=False, bootloader_ignore_signals=False, strip=False, upx=True, upx_exclude=[], runtime_tmpdir=None, console=False , icon='logo.ico')

JavaGuySoho commented 4 years ago

350305 INFO: Looking for eggs 350305 INFO: Using Python library d:\programdata\anaconda3\python37.dll 350307 INFO: Found binding redirects: [] 350332 INFO: Warnings written to E:\Python\AlphaCS\webkit\build\main\warn-main.txt 350747 INFO: Graph cross-reference written to E:\Python\AlphaCS\webkit\build\main\xref-main.html 351337 INFO: checking PYZ 351338 INFO: Building PYZ because PYZ-00.toc is non existent 351340 INFO: Building PYZ (ZlibArchive) E:\Python\AlphaCS\webkit\build\main\PYZ-00.pyz 364797 INFO: Building PYZ (ZlibArchive) E:\Python\AlphaCS\webkit\build\main\PYZ-00.pyz completed successfully. 364877 INFO: checking PKG 364878 INFO: Building PKG because PKG-00.toc is non existent 364880 INFO: Building PKG (CArchive) PKG-00.pkg 575002 INFO: Building PKG (CArchive) PKG-00.pkg completed successfully. 575227 INFO: Bootloader d:\programdata\anaconda3\lib\site-packages\PyInstaller\bootloader\Windows-64bit\runw.exe 575227 INFO: checking EXE 575230 INFO: Building EXE because EXE-00.toc is non existent 575230 INFO: Building EXE from EXE-00.toc 575262 INFO: Copying icons from ['logo.ico'] 575294 INFO: Writing RT_GROUP_ICON 0 resource with 20 bytes 575295 INFO: Writing RT_ICON 1 resource with 16144 bytes 575320 INFO: Updating manifest in E:\Python\AlphaCS\webkit\build\main\runw.exe.b5ma9ttm 575323 INFO: Updating resource type 24 name 1 language 0 575336 INFO: Appending archive to EXE E:\Python\AlphaCS\webkit\dist\main.exe 578500 INFO: Building EXE from EXE-00.toc completed successfully.

JavaGuySoho commented 4 years ago

failed to execute script pyi_rth_pkgres

JavaGuySoho commented 4 years ago

pip3 install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

Collecting https://github.com/pyinstaller/pyinstaller/archive/develop.zip Using cached https://github.com/pyinstaller/pyinstaller/archive/develop.zip (4.2 MB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing wheel metadata ... done Requirement already satisfied: pefile>=2017.8.1; sys_platform == "win32" in d:\programdata\anaconda3\lib\site-packages (from pyinstaller==4.0.dev0) (2019.4.18) Requirement already satisfied: altgraph in d:\programdata\anaconda3\lib\site-packages (from pyinstaller==4.0.dev0) (0.17) Requirement already satisfied: pywin32-ctypes>=0.2.0; sys_platform == "win32" in d:\programdata\anaconda3\lib\site-packages (from pyinstaller==4.0.dev0) (0.2.0) Requirement already satisfied: setuptools in d:\programdata\anaconda3\lib\site-packages (from pyinstaller==4.0.dev0) (45.0.0) Requirement already satisfied: future in d:\programdata\anaconda3\lib\site-packages (from pefile>=2017.8.1; sys_platform == "win32"->pyinstaller==4.0.dev0) (0.18.2) Building wheels for collected packages: pyinstaller Building wheel for pyinstaller (PEP 517) ... done Created wheel for pyinstaller: filename=pyinstaller-4.0.dev0-py3-none-any.whl size=2938013 sha256=b6659d85b827567ebc9987a2dcf580fa6fb3de1b4bd44ae799929a700358cbea Stored in directory: C:\Users\55829\AppData\Local\Temp\pip-ephem-wheel-cache-wd3tm11w\wheels\8a\8d\79\5d8288416c36a101b9acc7bf6b88e3b61357156c6a1efa63df Successfully built pyinstaller Installing collected packages: pyinstaller Successfully installed pyinstaller-4.0.dev0 WARNING: You are using pip version 20.1; however, version 20.1.1 is available. You should consider upgrading via the 'd:\programdata\anaconda3\python.exe -m pip install --upgrade pip' command.

pip3 show pyinstaller

Name: pyinstaller Version: 4.0.dev0 Summary: PyInstaller bundles a Python application and all its dependencies into a single package. Home-page: http://www.pyinstaller.org/ Author: Hartmut Goebel, Giovanni Bajo, David Vierra, David Cortesi, Martin Zibricky Author-email: None License: GPLv2-or-later with a special exception which allows to use PyInstaller to build and distribute non-free programs (including commercial ones) Location: d:\programdata\anaconda3\lib\site-packages Requires: altgraph, pywin32-ctypes, setuptools, pefile Required-by:

JavaGuySoho commented 4 years ago

pip3 install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

JavaGuySoho commented 4 years ago

pip3 install easycython -i https://pypi.douban.com/simple

JavaGuySoho commented 4 years ago

cp common.pyx common.py cp isPackage.pyx isPackage.py cp main.pyx main.py cp server.pyx server.py cp setup.pyx setup.py cp XCommand.pyx XCommand.py cp XConfig.pyx XConfig.py cp XDateTime.pyx XDateTime.py cp XGlobal.pyx XGlobal.py cp XImage.pyx XImage.py cp XInstruction.pyx XInstruction.py cp XLogger.pyx XLogger.py cp XObject.pyx XObject.py cp XPicture.pyx XPicture.py cp XPlot.pyx XPlot.py cp XPresentation.pyx XPresentation.py cp XSafety.pyx XSafety.py cp XSerial.pyx XSerial.py cp XService.pyx XService.py cp XShared.pyx XShared.py cp XSqlite.pyx XSqlite.py cp XString.pyx XString.py cp XSystem.pyx XSystem.py cp XWebkitShared.pyx XWebkitShared.py cp XWebkitWindow.pyx XWebkitWindow.py cp XWindow.pyx XWindow.py

JavaGuySoho commented 4 years ago

cd ./debug

MAX=$1 if [ $# -eq 0 ]; then MAX=1 fi

for ((i=1; i<=$MAX; i++)) do python3 client.py send "01 03 08 00 00 00 64 00 00 00 64 E5 F4" sleep 0.5 python3 client.py send "01 03 08 00 00 00 5A 00 00 00 6E 4C 36" sleep 0.5 python3 client.py send "01 03 08 00 00 00 46 00 00 00 64 1D F3" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 19 00 00 00 6F D6 00 00 19 64 00 00 6F FE 00 00 19 1E 00 01 64 96 00 00 18 F6 00 01 64 72 31 52" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 31 F0 00 00 39 1B 00 00 30 67 00 01 26 6D 00 00 32 A4 00 00 4C 16 00 00 34 3A 00 01 39 76 EB 63" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 31 FA 00 00 39 00 00 00 30 65 00 01 26 58 00 00 32 AA 00 00 4C 0E 00 00 34 3A 00 01 39 4C 72 DB" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 31 FA 00 00 38 FC 00 00 30 64 00 01 26 67 00 00 32 AD 00 00 4C 1B 00 00 34 3D 00 01 39 63 4F 6D" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 32 01 00 00 38 FA 00 00 30 65 00 01 26 5A 00 00 32 BF 00 00 4C 12 00 00 34 41 00 01 39 53 60 A3" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 31 F8 00 00 39 0A 00 00 30 62 00 01 26 5B 00 00 32 B3 00 00 4C 12 00 00 34 3D 00 01 39 54 7B 34" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 31 FF 00 00 39 05 00 00 30 5F 00 01 26 6A 00 00 32 C4 00 00 4C 15 00 00 34 3E 00 01 39 7F 01 3C" sleep 0.5 python3 client.py send "01 10 00 00 00 10 20 00 00 31 F6 00 00 39 08 00 00 30 60 00 01 26 61 00 00 32 B8 00 00 4C 12 00 00 34 3C 00 01 39 5F 27 4F" sleep 0.5 done

JavaGuySoho commented 4 years ago

校准 calibration

光栅尺校准

JavaGuySoho commented 4 years ago
    # 800 x 400
    figure, alpha = plt.subplots(figsize=(8, 4), dpi = 100)

    self.initAxis()
    alpha.axis([0, self._track_width, 0, 600])
    grating_ruler_height = 450

    track = mpathes.Rectangle((0, 0), self._track_width, grating_ruler_height, facecolor = 'orange', fill = False, edgecolor='#DEB883', linewidth=1)
    alpha.add_patch(track)
    leftCleft = mpathes.Rectangle((0, 0), self._left_cleft, grating_ruler_height, facecolor = 'green', fill = True)
    alpha.add_patch(leftCleft)
    rightCleft = mpathes.Rectangle((self._track_width - self._right_cleft, 0), self._right_cleft, grating_ruler_height, facecolor = 'blue', fill = True, edgecolor='#DEB883', linewidth=1)
    alpha.add_patch(rightCleft)

    plt.plot(0, 475, label='光栅尺左侧位移 : %5.2fmm' % (self._left_cleft),  color='green')
    plt.plot(0, 450, label='光栅尺右侧位移 : %5.2fmm' % (self._right_cleft), color='blue')
    plt.legend(loc="upper center")