@@ -46,6 +46,7 @@ def __init__(self, parent=None, hintSignal=lambda type, title, msg: None, rmCall
4646 self .setLayout (self .layout )
4747 self .plotWin = pg .GraphicsLayoutWidget ()
4848 self .plotWin .setMinimumHeight (200 )
49+ self .default_x = 0 ;
4950 pg .setConfigOptions (antialias = True )
5051 rmBtn = QPushButton (_ ("Remove" ))
5152 clearBtn = QPushButton (_ ("Clear" ))
@@ -215,9 +216,11 @@ def decodeDataAscii(self, data: bytes):
215216 '''
216217 @data bytes, protocol:
217218 $[line name],[x],[y]<,checksum>\n
219+ or $[line name],[y]
218220 "$" means start of frame, "," means separator,
219221 checksum is optional, checksum is sum of all bytes in frame except ",checksum".
220222 e.g.
223+ "$roll,2.0\n "
221224 "$roll,1.0,2.0\n "
222225 "$pitch,1.0,2.0\r \n "
223226 "$pitch,1.0,2.0,179\n " , the 179 = sum(ord(c) for c in "$pitch,1.0,2.0") % 256
@@ -245,12 +248,17 @@ def decodeDataAscii(self, data: bytes):
245248 frame = self .rawData [1 :idx ] # pitch,1.0,2.0 pitch,1.0,2.0,179
246249 self .rawData = self .rawData [idx + 1 :]
247250 items = frame .split (b"," )
248- if len (items ) != 3 and len (items ) != 4 :
251+ if len (items ) != 2 and len ( items ) != 3 and len (items ) != 4 :
249252 print ("-- format error, frame item len(%s, should 3 or 4) error: %s" % (len (items ), frame ))
250253 return False , self .data
251254 try :
252- x = float (items [1 ])
253- y = float (items [2 ])
255+ if len (items ) == 2 :
256+ x = float (self .default_x )
257+ y = float (items [1 ])
258+ self .default_x += 1
259+ else :
260+ x = float (items [1 ])
261+ y = float (items [2 ])
254262 except Exception :
255263 print ("-- x or y format error, frame: %s" % frame )
256264 return False , self .data
0 commit comments