Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions nxpprog.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ def __init__(self, device, baud, xonxoff=False, control=False):
# or the device is in the wrong mode.
# This timeout is too short for slow baud rates but who wants to
# use them?
self._serial.setTimeout(5)
self._serial.timeout = 1
# device wants Xon Xoff flow control
if xonxoff:
self._serial.setXonXoff(1)
Expand Down Expand Up @@ -491,8 +491,8 @@ def write(self, data):

def readline(self, timeout=None):
if timeout:
ot = self._serial.getTimeout()
self._serial.setTimeout(timeout)
ot = self._serial.timeout
self._serial.timeout = timeout

line = b''
while True:
Expand All @@ -512,7 +512,7 @@ def readline(self, timeout=None):
line += c

if timeout:
self._serial.setTimeout(ot)
self._serial.timeout = ot

return line.decode("UTF-8", "ignore")

Expand Down Expand Up @@ -685,8 +685,11 @@ def isp_command(self, cmd):


def sync(self, osc):
self.dev_write(b'?')
s = self.dev_readline()
for _ in range(10):
self.dev_write(b'?')
s = self.dev_readline()
if s:
break
if not s:
panic("Sync timeout")
if s != self.sync_str:
Expand Down Expand Up @@ -1256,7 +1259,7 @@ def main(argv=None):
else:
panic("Unhandled option: %s" % o)

if cpu != "autodetect" and not cpu_parms.has_key(cpu):
if cpu != "autodetect" and not cpu in cpu_parms:
panic("Unsupported cpu %s" % cpu)

if len(args) == 0:
Expand Down