Skip to content
Snippets Groups Projects

Pycardium Improvements

Merged rahix requested to merge rahix/pycardium-improvements into master
All threads resolved!

Various pycardium improvements, most notably a fix for #212 (closed). See the individual commits for details.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • rahix changed milestone to %v1.16

    changed milestone to %v1.16

  • Looks good to me! Thanks for keeping our codebase clean.

    However, I'm only a bot - so a human will still have to approve this request.

  • Author Owner

    While this makes pycard10.py work, the interactions doesn't really look clean to me (g_watch was running normally when I issued a request to load analog_clock):

    [      384130] lifecycle: Loading "apps/g_watch/__init__.py" ...
    --------------------------------
              Pycardium
     Version: v1.15-205-gd1948f73be4f
    --------------------------------
      Loading apps/g_watch/__init__.py ...
    Traceback (most recent call last):
      File "apps/g_watch/__init__.py", line 160, in <module>
    KeyboardInterrupt: 
    [      397150] lifecycle: Loading Python interpreter ...
    --------------------------------
              Pycardium
     Version: v1.15-205-gd1948f73be4f
    --------------------------------
      Entering REPL ...
    MicroPython v1.12 on 2020-10-16; card10 with max32666
    Type "help()" for more information.
    >>> 
    >>> 
    >>> 
    >>> 
    MicroPython v1.12 on 2020-10-16; card10 with max32666
    Type "help()" for more information.
    >>> 
    [      397171] lifecycle: Payload returned successfully
    [      397178] lifecycle: Loading "menu.py" ...
    --------------------------------
              Pycardium
     Version: v1.15-205-gd1948f73be4f
    --------------------------------
      Loading menu.py ...
    'failapp': metadata.json is invalid ... hoping for the best.
    Traceback (most recent call last):
      File "menu.py", line 51, in enumerate_apps
    OSError: [Errno 2] ENOENT
    Traceback (most recent call last):
      File "menu.py", line 185, in <module>
      File "simple_menu.py", line 307, in run
      File "simple_menu.py", line 54, in button_events
    KeyboardInterrupt: 
    [      398108] lifecycle: Loading Python interpreter ...
    --------------------------------
              Pycardium
     Version: v1.15-205-gd1948f73be4f
    --------------------------------
      Entering REPL ...
    MicroPython v1.12 on 2020-10-16; card10 with max32666
    Type "help()" for more information.
    >>> 
    >>> 
    >>> 
    raw REPL; CTRL-B to exit
    >OK>OK

    Do you have an explanation for the weird sequence of interrupting the app, exiting the interpreter again (presumably a ^D), then interrupting the menu.py script to finally go into raw REPL mode and load the script?

  • How it looks like for me. I guess the same just with different timing:

    [           0] startup: Epicardium startup ...
    [           0] startup: Version v1.15-205-ga9c9d666
    MAX7765x DIDM: 0x01 CID: 0x08
    [           0] usb: initializing device cdcacm
    [           0] fatfs: attached
    
    [           0] ble: BLE is enabled.
    [         589] lifecycle: Loading "main.py" ...
    [         621] ble: Setting MAC address to CA:4D:10:3E:FB:BE
    [         625] ble: Ble got evt 100: DM_ERROR_IND
    [         632] ble: Ble got evt 32: DM_RESET_CMPL_IND
    [         634] ble: Bonded. Making connectable
    [         640] ble: Ble got evt 33: DM_ADV_START_IND
    [         641] ble: Advertisement started 0 0
    [         741] ble: Ble got evt 52: DM_SEC_ECC_KEY_IND
    --------------------------------
              Pycardium
     Version: v1.15-205-ga9c9d666
    --------------------------------
      Loading main.py ...
    main.py: Loading apps/g_watch/__init__.py
    [         810] lifecycle: Loading "apps/g_watch/__init__.py" ...
    --------------------------------
              Pycardium
     Version: v1.15-205-ga9c9d666
    --------------------------------
      Loading apps/g_watch/__init__.py ...
    Traceback (most recent call last):
      File "apps/g_watch/__init__.py", line 159, in <module>
    KeyboardInterrupt: 
    [       21511] lifecycle: Loading Python interpreter ...
    --------------------------------
              Pycardium
     Version: v1.15-205-ga9c9d666
    --------------------------------
      Entering REPL ...
    MicroPython v1.12 on 2020-10-15; card10 with max32666
    Type "help()" for more information.
    >>> 
    >>> 
    >>> 
    MicroPython v1.12 on 2020-10-15; card10 with max32666
    Type "help()" for more information.
    >>> 
    [       21533] lifecycle: Payload returned successfully
    [       21536] lifecycle: Loading "menu.py" ...
    --------------------------------
              Pycardium
     Version: v1.15-205-ga9c9d666
    --------------------------------
      Loading menu.py ...
    Traceback (most recent call last):
      File "menu.py", line 178, in <module>
      File "menu.py", line 33, in enumerate_entries
      File "menu.py", line 55, in enumerate_apps
    KeyboardInterrupt: 
    [       22640] lifecycle: Loading Python interpreter ...
    --------------------------------
              Pycardium
     Version: v1.15-205-ga9c9d666
    --------------------------------
      Entering REPL ...
    MicroPython v1.12 on 2020-10-15; card10 with max32666
    Type "help()" for more information.
    >>> 
    >>> 
    >>> 
    raw REPL; CTRL-B to exit
    >OK>OK

    I was only interested in actually resetting the hardware before each run of pycard10. The only way in my MR was to go to a script and interrupt that.

    And you are right: this is all super dirty. Maybe we should simply call os.exec("") to get to a fresh REPL?

    • Resolved by rahix

      I propose the following additional change:

      diff --git a/tools/pycard10.py b/tools/pycard10.py
      index a0ce7419..c8025f34 100755
      --- a/tools/pycard10.py
      +++ b/tools/pycard10.py
      @@ -130,10 +130,14 @@ class PyCard10(Pyboard):
               None
               """
       
      -        self.soft_reset()
      -
               self.serial.write(b"\x03\x03")  # ctrl-C twice: interrupt any running program
       
      +        self.serial.write(b"\x02")  # ctrl-B: ensue it's the normal mode
      +
      +        self.serial.write(b'import os; os.exec("")\r')  # Reset to REPL
      +
      +        time.sleep(1)  # Give epicardium some time to cycle pycardium
      +
               # flush input (without relying on serial.flushInput())
               n = self.serial.inWaiting()
               while n > 0:
  • Looks like the sleep is not actually needed in this case.

  • schneider mentioned in merge request !413 (closed)

    mentioned in merge request !413 (closed)

    • Resolved by rahix

      When pressing CTRL+C and then CTRL+D one now ends up in the menu. I think before the main app was started again. Is that intended?

      I'm wondering if we can maybe make use of this: Allow the menu to react to cursor keys or present a small menu on the console as well. Would eliminate the need to press buttons during development.

  • added 6 - Changes Requested label and removed 6 - Needs Review label

  • rahix added 1 commit

    added 1 commit

    • 260dc5b3 - fix(pycard10): Make pycard10 reset pycardium via os.exec("")

    Compare with previous version

  • rahix mentioned in issue #213

    mentioned in issue #213

  • rahix resolved all threads

    resolved all threads

  • schneider resolved all threads

    resolved all threads

  • schneider mentioned in commit c28aed8d

    mentioned in commit c28aed8d

  • merged

Please register or sign in to reply
Loading