soc/tools/remote/comm_uart: be sure to flush in waiting bytes before read and write
This commit is contained in:
parent
d3ecdd9995
commit
ff155a474d
|
@ -38,7 +38,12 @@ class CommUART:
|
||||||
remaining -= written
|
remaining -= written
|
||||||
pos += written
|
pos += written
|
||||||
|
|
||||||
|
def _flush(self):
|
||||||
|
if self.port.inWaiting() > 0:
|
||||||
|
self.port.read(self.port.inWaiting())
|
||||||
|
|
||||||
def read(self, addr, length=None):
|
def read(self, addr, length=None):
|
||||||
|
self._flush()
|
||||||
data = []
|
data = []
|
||||||
length_int = 1 if length is None else length
|
length_int = 1 if length is None else length
|
||||||
self._write([self.msg_type["read"], length_int])
|
self._write([self.msg_type["read"], length_int])
|
||||||
|
@ -53,6 +58,7 @@ class CommUART:
|
||||||
return data
|
return data
|
||||||
|
|
||||||
def write(self, addr, data):
|
def write(self, addr, data):
|
||||||
|
self._flush()
|
||||||
data = data if isinstance(data, list) else [data]
|
data = data if isinstance(data, list) else [data]
|
||||||
length = len(data)
|
length = len(data)
|
||||||
offset = 0
|
offset = 0
|
||||||
|
|
Loading…
Reference in New Issue