45 lines
558 B
Python
45 lines
558 B
Python
import prottcp
|
|
import time
|
|
import numpy as np
|
|
|
|
|
|
|
|
#测试小板功能
|
|
|
|
|
|
|
|
|
|
def random():
|
|
return int(np.random.random_sample()*10000%10000)
|
|
|
|
|
|
|
|
def numlist_to_str(numlist:list):
|
|
s=""
|
|
for i in numlist:
|
|
s+=str(i)+','
|
|
return s[:-1]
|
|
|
|
|
|
def randomlist(num:int):
|
|
l=[]
|
|
for i in range(num):
|
|
l.append(random())
|
|
return l
|
|
|
|
|
|
if __name__ == '__main__':
|
|
u=prottcp.protu()
|
|
u.init("com11:38400")
|
|
u.start_recv()
|
|
for i in range(10):
|
|
s='test '+numlist_to_str(randomlist(20))
|
|
print("send:",s)
|
|
u.send_str(s)
|
|
time.sleep(1)
|
|
u.close()
|
|
|
|
|
|
|
|
|