sim scanner catchup
This commit is contained in:
parent
33c578e90a
commit
bf74da8aef
@ -149,10 +149,10 @@ class NotesMenu(MenuSystem):
|
||||
elif got.startswith('otpauth-migration://offline'):
|
||||
# see <https://github.com/qistoph/otp_export>
|
||||
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'
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
|
||||
@ -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])
|
||||
|
||||
Loading…
Reference in New Issue
Block a user