添加save2file实现
This commit is contained in:
parent
39c35f06a0
commit
e17194b628
11
s2f.py
11
s2f.py
@ -1,3 +1,8 @@
|
|||||||
|
import datetime
|
||||||
def save2file(data):
|
def save2file(data,isR=1):
|
||||||
pass
|
# pass
|
||||||
|
t= datetime.datetime.now()
|
||||||
|
l=f"{'[R]' if isR else '[T]'} - {str(t)} --- {data.hex(' ')}\n"
|
||||||
|
f=open('./rxlog.txt','a')
|
||||||
|
f.write(l)
|
||||||
|
f.close
|
@ -341,6 +341,7 @@ def tt_trans(addr, data):
|
|||||||
try:
|
try:
|
||||||
add_timestamp()
|
add_timestamp()
|
||||||
taddr.send(msg)
|
taddr.send(msg)
|
||||||
|
s2f.save2file(msg,0)
|
||||||
print("数据发送成功。", sccid, "-->", tccid)
|
print("数据发送成功。", sccid, "-->", tccid)
|
||||||
s2wx("","",f"匹配到在线终端, 数据发送成功。 \n{sccid.decode()} ---> {tccid.decode()}")
|
s2wx("","",f"匹配到在线终端, 数据发送成功。 \n{sccid.decode()} ---> {tccid.decode()}")
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -405,6 +406,7 @@ class MyServer(socketserver.BaseRequestHandler):
|
|||||||
def setup(self):
|
def setup(self):
|
||||||
self.request.settimeout(60*10)
|
self.request.settimeout(60*10)
|
||||||
self.err = " "
|
self.err = " "
|
||||||
|
self.recDataBuff=[]
|
||||||
|
|
||||||
def handle(self): # 回调
|
def handle(self): # 回调
|
||||||
add_timestamp()
|
add_timestamp()
|
||||||
@ -424,11 +426,14 @@ class MyServer(socketserver.BaseRequestHandler):
|
|||||||
if not data:
|
if not data:
|
||||||
break
|
break
|
||||||
add_timestamp()
|
add_timestamp()
|
||||||
|
self.recDataBuff.extend(data)
|
||||||
s2f.save2file(data)
|
s2f.save2file(data)
|
||||||
t = f"从{str(self.client_address)}<->[{get_ccid(conn).decode() if get_ccid(conn) else 'None'}]接收到新数据,长度{len(data)}字节。"
|
t = f"从{str(self.client_address)}<->[{get_ccid(conn).decode() if get_ccid(conn) else 'None'}]接收到新数据,长度{len(data)}字节。"
|
||||||
print(t)
|
print(t)
|
||||||
print(data)
|
print(data.hex(" "))
|
||||||
s2wx("","",t)
|
s2wx("","",t)
|
||||||
|
print("--",len(self.recDataBuff))
|
||||||
|
print(self.recDataBuff[:])
|
||||||
if tt_decode(conn, data):
|
if tt_decode(conn, data):
|
||||||
self.err= "切断。"
|
self.err= "切断。"
|
||||||
print(self.client_address, "疑是非法连接")
|
print(self.client_address, "疑是非法连接")
|
||||||
|
Loading…
Reference in New Issue
Block a user