格式化

This commit is contained in:
murmur 2023-03-13 19:27:54 +08:00
parent a6ff83f9b7
commit b1de714ddc

View File

@ -15,6 +15,7 @@ p = {}
# 地址 ==ccid
pp = {}
def add_timestamp():
print(datetime.datetime.now(), ":")
@ -95,6 +96,7 @@ def get_ccid(addr):
+--------+--------------+----------+----------+--------------+------------------------+--------+
"""
def tt_hh(addr, data):
"""处理心跳"""
@ -103,7 +105,7 @@ def tt_hh(addr, data):
update_pairs(addr, ccid)
# 组帧再返回
msg = data[:]
msg[12:-1]=val = '%04x'%int(time.time())
msg[12:-1] = val = "%04x" % int(time.time())
# 计算校验和
crc = 0
for i in msg[:-1]:
@ -136,14 +138,15 @@ def tt_hh(addr, data):
del cache[ccid]
save_cache(cache)
return 0
def check_valid(data):
# 检查数据有效性
return bytearray(data[:])
def tt_trans(addr, data):
"""发送数据到指定ccid"""
@ -237,9 +240,7 @@ def tt_decode(addr, data):
return flag
class MyServer(socketserver.BaseRequestHandler):
def handle(self): # 回调
add_timestamp()
print("终端", self.client_address, "已上线等待上报心跳注册ccid。")