当前位置:网站首页>Pyqt5与通信
Pyqt5与通信
2022-04-23 09:45:00 【西木康】
# import bluetooth
# target_name = "HC-05"
# target_address = None
# nearby_devices = bluetooth.discover_devices(lookup_names=True)
#
# for bdaddr,name in nearby_devices:
# if target_name == name:
#
# target_address = bdaddr
# break
# if target_address is not None:
# print ("found target bluetooth device with address ", target_address)
# else:
# print ("could not find target bluetooth device nearby")
#
# print(target_address)
# sock=bluetooth.BluetoothSocket( bluetooth.RFCOMM )
# sock.connect((target_address, 1))
#
# sock.send("download-app")
# sock.close()
import serial
import time
import _thread # 导入线程包
data_ser = serial.Serial("COM7", 9600, timeout=5)
data_ser.flushInput()
def get_data():
while True:
data_count = data_ser.inWaiting()
if data_count != 0:
recv = data_ser.read(data_ser.in_waiting).decode("gbk")
print(time.time(), " --- data_recv --> ", recv)
time.sleep(0.1)
if __name__ == '__main__':
_thread.start_new_thread(get_data, ()) # 开启线程,执行get_data方法
while 1:
time.sleep(2)
data_ser.write(b'1') # 发送二进制1
time.sleep(2)
print("1211515")
data_ser.write(b'2') # 发送二进制0write("1".encode()) #写入一个字符“1”(或者b'1')
self.qwebengine = QWebEngineView(self.centralwidget)
self.qwebengine.setGeometry(QtCore.QRect(10,30,451,321))
self.qwebengine.setAutoFillBackground(False)
self.qwebengine.setStyleSheet("background-color:rgb(170,170,127);")
self.qwebengine.setObjectName("qwebengine")
self.__ui.qwebengine.load(QUrl(r"www.baidu.com"))
self.__ui.qwebengine.load(QUrl(QFileInfo("base.html").absoluteFilePath()))
版权声明
本文为[西木康]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_47654347/article/details/124130866
边栏推荐
- nn. Explanation of module class
- C语言:表达式求值(整型提升、算术转换 ...)
- MySQL of database -- basic common query commands
- Learn FPGA (from Verilog to HLS)
- GUI, CLI and UNIX Philosophy
- What is monitoring intelligent playback and how to use intelligent playback to query video recording
- Kernel PWN learning (4) -- double fetch & 0ctf2018 baby
- Example of data object mask used by SAP translate
- Vivo, hardware safe love and thunder
- Leetcode0587. 安装栅栏(difficult)
猜你喜欢
![[geek challenge 2019] havefun1](/img/8b/b15bf31771d54db25f24d630e64093.png)
[geek challenge 2019] havefun1

Leetcode题库78. 子集(递归 c实现)

#yyds干货盘点#ubuntu18.0.4安装mysql并解决ERROR 1698: Access denied for user ''root''@''localhost''

Comparison of overloading, rewriting and hiding

Vivo, hardware safe love and thunder

Simple understanding of arguments in JS

Enter "net start MySQL" and "system error 5. Access denied" appears. Detailed explanation of the problem

Setnx command execution failed due to full redis memory

SAP pi / PO function operation status monitoring and inspection

108. Convert an ordered array into a binary search tree
随机推荐
面试官:说几个PHP常用函数,幸好我面试之前看到了这篇文章
Leetcode question bank 78 Subset (recursive C implementation)
Easy to understand subset DP
Two declaration methods of functions of JS
Set the maximum width of the body, but why does the background color of the body cover the whole page?
F-niu Mei's apple tree (diameter combined)
MySQL - Chapter 1 (data type 2)
SAP pi / PO soap2proxy consumption external WS example
Alibaba cloud architects interpret the four mainstream game architectures
Solving Lucas number and combination theorem
[reading notes] Chapter 5 conditional statements, circular statements and block statements of Verilog digital system design tutorial (with answers to thinking questions)
[hdu6868] absolute math (pusher + Mobius inversion)
MySQL of database -- Fundamentals
What is monitoring intelligent playback and how to use intelligent playback to query video recording
Go language learning notes - structure | go language from scratch
Exclusive thoughts and cases of JS
(Extended) bsgs and higher order congruence equation
Kettle实验
C语言:表达式求值(整型提升、算术转换 ...)
Creation of raid0 and RAID5 and Simulation of how RAID5 works