Skip to content

Commit 3819003

Browse files
committed
added buffer flush
1 parent 6ed4ee2 commit 3819003

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

src/tinySA_python.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,15 @@ def disconnect(self):
169169
self.ser.close()
170170

171171

172-
def tinySA_serial(self, writebyte, printBool=False):
172+
def tinySA_serial(self, writebyte, printBool=False, pts=None):
173173
# write out to serial, get message back, clean up, return
174174

175+
# clear INPUT buffer
176+
self.ser.reset_input_buffer()
177+
# clear OUTPUT buffer
178+
self.ser.reset_output_buffer()
179+
180+
175181
self.ser.write(bytes(writebyte, 'utf-8'))
176182
msgbytes = self.get_serial_return()
177183
msgbytes = self.clean_return(msgbytes)
@@ -208,8 +214,11 @@ def get_serial_return(self):
208214

209215
return bytearray(complete)
210216

217+
def scan_raw_get_serial(self, pts):
218+
pass
211219

212-
def read_until_end_marker(self, end_marker=b'}', timeout=5.0):
220+
221+
def read_until_end_marker(self, end_marker=b'}', timeout=10.0):
213222
# scan and scan raw might return early with tinySA_serial
214223
# so this is written to
215224
import time
@@ -1462,7 +1471,7 @@ def scan_raw(self, start, stop, pts=250, unbuf=1):
14621471

14631472
# write out to serial, get message back, clean up, return
14641473
self.print_message("scanning...")
1465-
msgbytes = self.tinySA_serial(writebyte, printBool=False)
1474+
msgbytes = self.tinySA_serial(writebyte, printBool=False, pts=pts) #pts added for error checking
14661475
return msgbytes
14671476
else:
14681477
self.print_message("ERROR: unrecognized UBUF for scanraw")

0 commit comments

Comments
 (0)