mpremote... interrupt to copy files

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
PM-TPI
Posts: 75
Joined: Fri Jun 28, 2019 3:09 pm

mpremote... interrupt to copy files

Post by PM-TPI » Wed Jun 22, 2022 8:28 pm

I have code that is running an async IO loop.
I want a script to halt program, then upload new files.
Can mpremote send a ctrl-c prior to uploading files?
Or any other ideas are welcome !!

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: mpremote... interrupt to copy files

Post by jimmo » Thu Jun 23, 2022 3:59 am

PM-TPI wrote:
Wed Jun 22, 2022 8:28 pm
Can mpremote send a ctrl-c prior to uploading files?
Yes, it does. Is it not working?

PM-TPI
Posts: 75
Joined: Fri Jun 28, 2019 3:09 pm

Re: mpremote... interrupt to copy files

Post by PM-TPI » Thu Jun 23, 2022 7:04 pm

I have a buzzer that beep at beginning of script.
With ESP32 running loop, I start mpremot, hear beep (soft boot)... unit boots and enters loop.

A soft reset with my code cause a...
(spi_master: spi_master_deinit_driver(270): not all CSses freed) error then an abort() and Rebooting...

It's not an issue in pymakr... I stop loop with a CTRL+C that stops code, and I upload files.
But I need a script because I am flashing ~100 boards.

mpremote does a soft boot but does not seem to break code loop.
I realy need a fix soon.

PM-TPI
Posts: 75
Joined: Fri Jun 28, 2019 3:09 pm

Re: mpremote... interrupt to copy files

Post by PM-TPI » Fri Jun 24, 2022 4:49 pm

mpremote is just not stoping loop ...

Code: Select all

PS C:\Users\rlsap\OneDrive - thermcoproducts.com\SmartLOG\CODE\dist> mpremote connect COM13 ls
b'SmartLOG Start\r\npower latched...\r\ntft backlight set...\r\nInitialize WiFi\r\nWiFi... Activated\r\nInitialize BLE\r\nBluetooth... Activated\r\nAmbient Sensor... Activated\r\nassertion "atomic_load(&lock->dev[i]) == (intptr_t)NULL" failed: file "/mnt/c/SmartLOG/FW/Build/esp-idf/components/driver/spi_bus_lock.c", line 560, function: spi_bus_deinit_lock\r\n\r\nabort() was called at PC 0x401eebe0 on core 0\r\n\r\nBacktrace:0x40094b81:0x3ffd1150 0x40095169:0x3ffd1170 0x40098df9:0x3ffd1190 0x401eebe0:0x3ffd1200 0x40192222:0x3ffd1230 0x40191a78:0x3ffd1250 0x400d82e2:0x3ffd1270 0x400d849d:0x3ffd12a0 0x400d86f6:0x3ffd1350 0x400e130d:0x3ffd13b0 0x400e3629:0x3ffd13d0 0x400e5e6e:0x3ffd13f0 0x400dd09c:0x3ffd1490 0x400e3629:0x3ffd14c0 0x400e3652:0x3ffd14e0 0x40104085:0x3ffd1500 0x40104102:0x3ffd1590 0x40104437:0x3ffd15c0 0x400e37fe:0x3ffd16a0 0x400e61c3:0x3ffd16e0 0x400dd09c:0x3ffd1780 0x400e3629:0x3ffd17d0 0x400e3652:0x3ffd17f0 0x400ef4a3:0x3ffd1810 0x400ef86d:0x3ffd18a0 0x400ef8d1:0x3ffd18c0 0x400d6459:0x3ffd18e0\r\n\r\n\r\nELF file SHA256: 52b96e34e8239681\r\n\r\nRebooting...\r\nets Jul 29 2019 12:21:46\r\n\r\nrst:0xc (SW_CPU_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)\r\nconfigsip: 0, SPIWP:0xee\r\nclk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00\r\nmode:DIO, clock div:2\r\nload:0x3fff0030,len:4\r\nload:0x3fff0034,len:5664\r\nho 0 tail 12 room 4\r\nload:0x40078000,len:13248\r\nload:0x40080400,len:4356\r\nentry 0x400806b0\r\nSmartLOG Start\r\npower latched...\r\ntft backlight set...\r\nInitialize WiFi\r\nWiFi... Activated\r\nInitialize BLE\r\nBluetooth... Activated\r\nAmbient Sensor... Activated\r\n[SDCard] v1a card\r\nsectors 1935360\r\nSD card... Mounted\r\nILI9341 initialized\r\nXPT2046 initialized\r\nconfig loaded\r\nStarting WiFi Connection\r\nlvgl label\r\nLooking for... RLSAP2\r\nlvgl label\r\nPSK Network\r\nlvgl label\r\nConnecting to... RLSAP2\r\nlvgl label\r\nConnecting to... RLSAP2\r\nlvgl label\r\nWiFi Connection Succeeded !\r\n\r\nlvgl label\r\nSettings Available\r\nContinuing Boot...\r\nlvgl label\r\nGet Network Time\r\nlvgl label\r\nNTP Time...\r\n(2022, 6, 24, 16, 30, 18, 4, 175)\r\nlvgl label\r\nTime Zone Adjusted...\r\n(2022, 6, 24, 11, 30, 18, 4, 175)\r\nlvgl label\r\nFlash Memory... OK\r\nlvgl label\r\nSending Alert Messaage...\r\nDDL Booted!\r\nlvgl label\r\n11:30am 6/24/2022 DDL Booted!\r\nEmail Not Confg\r\n\r\n\r\nlvgl label\r\nScan for Sensor Temp(s)\r\nlvgl label\r\nscan time: 9.308\r\nFile Appended: 2022-06-24.csv\r\n2022-06-24,11:30,26.2,72.5,100,24.6,100,24.6,100,boot\r\n\r\n11:30am 6/24/2022 POWER Failure\r\r\nON Battery Backup 100% remaining\r\nEmail Not Confg\r\n\r\n\r\n\r\n\t11:30am 6/24/2022\r\n\t{\'p2[2]\': [\'\', \'\'], \'pwr[1]\': [\'dl_pwr\', \'12:30\'], \'p1[2]\': [\'\', \'\'], \'p1[1]\': [\'\', \'\'], \'p2[0]\': [\'\', \'\'], \'p2[1]\': [\'\', \'\'], \'p1[0]\': [\'\', \'\']}\r\n\t[-27, 100, 24.6, 24.6, \'11:30am 6/24/2022\', 24.6, \'11:30am 6/24/2022\', 
0, \'73.00\']\r\n\t[-27, 100, 24.6, 24.6, \'11:30am 6/24/2022\', 24.6, \'11:30am 6/24/2022\', 0, \'73.00\']\r\n\tMin Max: [\'60.0\', \'100.0\', \'60.0\', \'100.0\']\r\n\twifi rssi: -72 sig%: 75\r\n\tvoltage: 4.202v  batt%: 100\r\n\ttemp: 26.2 humd: 72.5\r\n\talarm: False\r\n\tmute: False\r\n\tsnooze: False\r\n\t15\r\n\t\r\n'
Traceback (most recent call last):
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\Scripts\mpremote.exe\__main__.py", line 7, in <module>
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\mpremote\main.py", line 478, in main
    pyb.enter_raw_repl(soft_reset=auto_soft_reset)
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\mpremote\pyboard.py", line 355, in enter_raw_repl
    raise PyboardError("could not enter raw repl")
mpremote.pyboard.PyboardError: could not enter raw repl
PS C:\Users\rlsap\OneDrive - thermcoproducts.com\SmartLOG\CODE\dist> 

Same issue with rshell

Code: Select all

PS C:\Users\rlsap\OneDrive - thermcoproducts.com\SmartLOG\CODE\dist> rshell -p COM13 ls
Using buffer-size of 32
Connecting to COM13 (buffer-size 32)...
Trying to connect to REPL  connected
repl connects but does't take control... need to interrupt, stop code

rshell shows all booting print staments then...

Code: Select all

Traceback (most recent call last):
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\Scripts\rshell-script.py", line 33, in <module>
    sys.exit(load_entry_point('rshell==0.0.31', 'console_scripts', 'rshell')())
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\command_line.py", line 4, in main
    rshell.main.main()
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 3082, in main
    real_main()
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 3044, in real_main
    connect(args.port, baud=args.baud, wait=args.wait, user=args.user, password=args.password)
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 1387, in connect
    connect_serial(port, baud=baud, wait=wait)
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 1411, in connect_serial
    dev = DeviceSerial(port, baud, wait)
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 1742, in __init__
    Device.__init__(self, pyb)
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 1495, in __init__
    self.sysname = self.remote_eval(sysname)
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 1630, in remote_eval
    return eval(self.remote(func, *args, **kwargs))
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\main.py", line 1608, in remote
    self.pyb.enter_raw_repl()
  File "C:\Users\rlsap\AppData\Local\Programs\Python\Python39\lib\site-packages\rshell\pyboard.py", line 209, in enter_raw_repl
    raise PyboardError('could not enter raw repl')
rshell.pyboard.PyboardError: could not enter raw repl
PS C:\Users\rlsap\OneDrive - thermcoproducts.com\SmartLOG\CODE\dist> 
I'm not sure if this could cause an issue... boot> impot main.mpy

What I need is.. these tools to inject a KeyboardInterrupt after the soft rest (to break async IO) then upload the files.
Thats how I do it with Pymakr

Post Reply