看起来好一些
This commit is contained in:
parent
844cc1a558
commit
7a7c77fefb
@ -109,11 +109,11 @@ def read_data(num=16):
|
||||
byte_list = []
|
||||
i = 1000 # 经过测试,发现正常接收16位耗时大概为500
|
||||
# 该函数中的两处time.sleep(0.001)会影响CAN接收速度,如果要提高CAN读取速度,可以将这两行注释掉,并将上面的i改成一个较大的值,比如5000
|
||||
while uart.inWaiting() == 0 and i > 0: # To do:
|
||||
while uart.in_waiting() == 0 and i > 0: # To do:
|
||||
i -= 1
|
||||
# time.sleep(0.001)
|
||||
# time.sleep(0.001)
|
||||
while uart.inWaiting() > 0:
|
||||
while uart.in_waiting() > 0:
|
||||
byte_list.append(list(uart.read(1))[0])
|
||||
if len(byte_list) == num:
|
||||
READ_FLAG = 1
|
||||
@ -187,6 +187,15 @@ data_map_dict = {
|
||||
|
||||
|
||||
def format_data(data, data_format="f f", decode: bool = True):
|
||||
"""
|
||||
格式化数据
|
||||
Args:
|
||||
data: 数据
|
||||
data_format: 数据格式
|
||||
decode: 是否解码
|
||||
Returns:
|
||||
格式化后的数据
|
||||
"""
|
||||
format_list = data_format.split()
|
||||
rdata = []
|
||||
if decode:
|
||||
@ -239,12 +248,6 @@ def dump_error(rdata):
|
||||
Args:
|
||||
rdata: 故障反馈帧内容
|
||||
|
||||
Returns:
|
||||
无
|
||||
|
||||
Raises:
|
||||
无
|
||||
|
||||
"""
|
||||
|
||||
# [0x08 mode cmd_data[1] cmd_data[0] id_num data0 data1 data2 data3 data4 data5 data6 data7]
|
||||
|
Loading…
Reference in New Issue
Block a user