le,line=readbyte(line)
da,line=readbyte(line)
sa,line=readbyte(line)
- typ="Error"
+ typ="**********Error**********"
if ds==0x27: typ="Data Request"
if ds==0x27 and da==0xFE: typ="Connection Request"
if ds==0x27 and da==0xFF: typ="Broadcast Request"
return line
def process_timestamp(line):
- timestamp=int(line)
+ timestamp=int(line)/1000
return timestamp
def process(line):
global timezero
global t
- global ref
+ global speed
+ global master
line=line[2:]
packet=line.split(" - ")
n=len(packet)
if n>0:
print("Header:",packet[0])
ds,le,da,sa,typ=process_head(packet[0])
- print("Type:",typ,"Length",le,"Destination",da,"Source",sa)
+ print("Type:",typ,"Length:",le,"Destination:",da,"Source:",sa)
if da==0xF7:
if n>1:
print("Payload:",packet[1])
timestamp=process_timestamp(info[1].strip())
if timezero==0:
timezero=timestamp
- t=t + [timestamp-timezero]
-# ref[0].append([ref1[0]])
-# ref[1].append([ref1[1]])
-# ref[2].append([ref1[2]])
-# ref[3].append([ref1[3]])
+ t=t+[timestamp-timezero]
+ master=master+[1+(sa-31)/10]
+ speed[0]=speed[0]+[ref[0]/254]
+ speed[1]=speed[1]+[ref[1]/254]
+ speed[2]=speed[2]+[ref[2]/254]
+ speed[3]=speed[3]+[ref[3]/254]
return
timezero=0
t=[]
-ref=[]
-ref.append([])
-ref.append([])
-ref.append([])
-ref.append([])
+master=[]
+speed=[]
+speed.append([])
+speed.append([])
+speed.append([])
+speed.append([])
+
for line in fileinput.input():
process(line)
print("------------------------------------------------")
fig=plt.figure()
-plt.plot(t,ref[0])
-plt.plot(t,ref[1])
-plt.plot(t,ref[2])
-plt.plot(t,ref[3])
+plt.xlabel('time/s')
+plt.ylabel('speed/upper')
+plt.plot(t,speed[0],'green')
+plt.plot(t,speed[1],'red')
+plt.plot(t,speed[2],'blue')
+plt.plot(t,speed[3],'magenta')
+plt.legend('1234')
+plt.plot(t,master,'black')
+plt.title('multipump')
plt.show()
plt.close(fig)