diff --git a/shared/notes.py b/shared/notes.py index ea40e2d4..b60e2964 100644 --- a/shared/notes.py +++ b/shared/notes.py @@ -149,10 +149,10 @@ class NotesMenu(MenuSystem): elif got.startswith('otpauth-migration://offline'): # see tmp.title = 'Google Auth' - elif '://' in got: + elif '://' in got[0:20]: # might be a URL, try to get the domain name as title try: - tmp.title = got.split('://', 1)[1].split('/', 1)[0] + tmp.title = (got.split('://', 1)[1].split('/', 1)[0])[0:32] except: tmp.title = 'Scanned URL' diff --git a/shared/scanner.py b/shared/scanner.py index 4682eaa8..560e5045 100644 --- a/shared/scanner.py +++ b/shared/scanner.py @@ -189,6 +189,7 @@ class QRScanner: await self.wakeup() # begin scan, in continuous mode + await self.txrx('S_CMD_0407') # turn on signal for our yellow led await self.tx('S_CMD_020E') # Continuous scanning mode start try: @@ -206,12 +207,17 @@ class QRScanner: finally: # Problem: another valid scan can come in just as we are trying # to get out of scanner mode - for retry in range(3): + for retry in range(10): try: await self.txrx('S_CMD_020D') # return to "Command mode" - await self.txrx('S_CMD_03L0') # turn off light + await self.txrx('S_CMD_03L0') # turn off bright light + await self.txrx('S_CMD_0406') # turn off signal for our yellow led + print('rest after %d retries' % retry) break except: pass + await asyncio.sleep_ms(25) + else: + print('reset failed') await self.goto_sleep() self.busy_scanning = False @@ -263,7 +269,7 @@ class QRScanner: async def flush_junk(self): while n := self.stream.s.any(): junk = await self.stream.readexactly(n) - #print('Scan << (junk) ' + B2A(junk)) + print('Scan << (junk) ' + B2A(junk)) async def tx(self, msg): # Send a command, don't wait for response @@ -299,7 +305,8 @@ class QRScanner: except asyncio.TimeoutError: if timeout is None: continue - raise RuntimeError("no rx after %s" % msg) + print("no rx after %s" % msg) + raise RuntimeError #print('txrx << ' + B2A(rx)) @@ -344,7 +351,8 @@ class QRScanner: #print("Bad Rx: %s=%r" % (B2A(rx), rx)) #print(" exc: %s" % exc) # this generally does not happen with all above complexity - raise RuntimeError("bad frame after %s" % msg) + print("bad frame after %s" % msg) + raise RuntimeError def torch_control_sync(self, on): # sync wrapper diff --git a/shared/selftest.py b/shared/selftest.py index f2b37f68..1cd81cdd 100644 --- a/shared/selftest.py +++ b/shared/selftest.py @@ -88,9 +88,9 @@ async def test_qr_scanner(): from glob import SCAN # Can take 2+ seconds to setup the QR scanner (from powerup), and - # if batteries are right, we can hit that timeframe in this test. + # if batteries are right, we can hit that timeframe in factory test case. for i in range(25): - if SCAN.version is not None: + if SCAN.setup_done: break await sleep_ms(100) diff --git a/shared/ux_q1.py b/shared/ux_q1.py index 3027b5e8..31a52e77 100644 --- a/shared/ux_q1.py +++ b/shared/ux_q1.py @@ -767,7 +767,7 @@ class QRScannerInteraction: while 1: if task.done(): data = await task - print("Scanned: %r" % data) + #print("Scanned: %r" % data) break dis.image(None, 40, 'scan_%d' % frames[ph])