Skip to content

Commit

Permalink
soc/tools/remote/comm_uart: be sure to flush in waiting bytes before …
Browse files Browse the repository at this point in the history
…read and write
  • Loading branch information
enjoy-digital committed Feb 15, 2019
1 parent d3ecdd9 commit ff155a4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions litex/soc/tools/remote/comm_uart.py
Expand Up @@ -38,7 +38,12 @@ def _write(self, data):
remaining -= written
pos += written

def _flush(self):
if self.port.inWaiting() > 0:
self.port.read(self.port.inWaiting())

def read(self, addr, length=None):
self._flush()
data = []
length_int = 1 if length is None else length
self._write([self.msg_type["read"], length_int])
Expand All @@ -53,6 +58,7 @@ def read(self, addr, length=None):
return data

def write(self, addr, data):
self._flush()
data = data if isinstance(data, list) else [data]
length = len(data)
offset = 0
Expand Down

0 comments on commit ff155a4

Please sign in to comment.