当前位置:网站首页>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
边栏推荐
- JSON input of Chapter 14 of kettle paoding jieniu
- Redis exception read error on connection solution
- Redis 内存占满导致的 Setnx 命令执行失败
- Cloud identity is too loose, opening the door for attackers
- Kettle experiment
- JS what is an event? Event three elements and operation elements
- ES-aggregation聚合分析
- Yyds dry goods inventory ubuntu18 0.4 install MySQL and solve error 1698: access denied for user ''root' '@' 'localhost' '
- 亚马逊云科技入门资源中心,从0到1轻松上云
- Simply understand = = and equals, why can string not use new
猜你喜欢
SAP salv14 background output salv data can directly save files and send emails (with sorting, hyperlink and filtering format)
Leetcode0587. Install fence
Cloud identity is too loose, opening the door for attackers
Simple understanding of arguments in JS
Where is int a = 1 stored
The sap export excel file opens and shows that the file format and extension of "XXX" do not match. The file may be damaged or unsafe. Do not open it unless you trust its source. Do you still want to
Pre parsing of JS
653. Sum of two IV - input BST
MySQL of database -- Fundamentals
Using sqlmap injection to obtain the account and password of the website administrator
随机推荐
Three ways to create objects in JS
JS scope, scope chain, global variables and local variables
Three challenges that a successful Devops leader should be aware of
golang力扣leetcode 396.旋转函数
Codeforces Round #784 (Div. 4)
Redis 异常 read error on connection 解决方案
Acquisition of DOM learning elements JS
ES-aggregation聚合分析
Using JS to realize a thousandth bit
Where is int a = 1 stored
Kettle experiment conversion case
云身份过于宽松,为攻击者打开了大门
Go language learning notes - language interface | go language from scratch
重载、重写、隐藏的对比
MacOS下使用CLion编译调试MySQL8.x
SAP salv14 background output salv data can directly save files and send emails (with sorting, hyperlink and filtering format)
Explanation of order and primitive root of number theory
Leetcode0587. Install fence
个人主页软件Fenrus
High paid programmer & interview question series 91 limit 20000 loading is very slow. How to solve it? How to locate slow SQL?