mu-editor / mu

A small, simple editor for beginner Python programmers. Written in Python and Qt5.
http://codewith.mu
GNU General Public License v3.0
1.41k stars 435 forks source link

Problem after successful file transfer: "There was a problem getting the list of files on the micro:bit" #566

Open nbogie opened 6 years ago

nbogie commented 6 years ago

TASK:

Trying to transfer a small text file using the Files feature, and get an updated file listing.

Steps to repeat:

1: Click "Files" (I got the expected listing) 2: Drag file across (I saw the file copying on the mbit)

Expected Outcome Expect to see an updated listing including the newly transferred file

Actual Outcome An error dialog "There was a problem getting the list of files on the micro:bit"

Why problematic Not a big deal for me, but unpleasant for inexperienced users.
As a workaround, from this state it seems fairly reliable that I can press Files button twice (to close and reopen) and get a refreshed listing showing the transferred file.

Platform, more context Mu-Editor 1.0.0.rc.1 on Mac OS 10.13.4

In general testing of Mu I very often get "ERROR: Could not enter raw REPL" in the logs, and a fallback to slow transfer. I haven't figured out a clear pattern yet, though making a new clean tab and flashing from there perhaps improves things temporarily. I'm not physically disconnecting the microbit at all, and I'm giving plenty time between operations.

2018-07-18 15:32:21,647 - root:112(run) INFO: 

-----------------

Starting Mu 1.0.0.rc.1
2018-07-18 15:32:21,647 - root:113(run) INFO: uname_result(system='Darwin', node='n-mbp', release='17.5.0', version='Darwin Kernel Version 17.5.0: Mon Mar  5 22:24:32 PST 2018; root:xnu-4570.51.1~1/RELEASE_X86_64', machine='x86_64', processor='i386')
2018-07-18 15:32:21,647 - root:114(run) INFO: Python path: ['/Applications/mu-editor.app/Contents/MacOS', '/Applications/mu-editor.app/Contents/Resources/python/lib/python36.zip', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/lib-dynload', '/Applications/mu-editor.app/Contents/Resources/python/lib/python3.6/site-packages', '/Applications/mu-editor.app/Contents/Resources/app', '/Applications/mu-editor.app/Contents/Resources/app_packages', '/Applications/mu-editor.app/Contents/Resources/app_packages/IPython/extensions']
2018-07-18 15:32:22,384 - mu.logic:542(__init__) INFO: Setting up editor.
2018-07-18 15:32:22,384 - mu.logic:560(__init__) INFO: Settings path: /Users/neill/Library/Application Support/mu/settings.json
2018-07-18 15:32:22,384 - mu.logic:561(__init__) INFO: Session path: /Users/neill/Library/Application Support/mu/session.json
2018-07-18 15:32:22,384 - mu.logic:562(__init__) INFO: Log directory: /Users/neill/Library/Logs/mu
2018-07-18 15:32:22,385 - mu.logic:563(__init__) INFO: Data directory: /Users/neill/Library/Application Support/mu
2018-07-18 15:32:22,399 - mu.logic:576(setup) INFO: Available modes: python, adafruit, microbit, debugger, pygamezero
2018-07-18 15:32:22,593 - mu.logic:1112(change_mode) INFO: Workspace directory: /Users/neill/mu_code
2018-07-18 15:32:22,598 - mu.logic:625(restore_session) INFO: Restoring session from: /Users/neill/Library/Application Support/mu/session.json
2018-07-18 15:32:22,598 - mu.logic:626(restore_session) DEBUG: {'theme': 'day', 'mode': 'microbit', 'paths': ['/Users/neill/projects/microbit/microbit-sample-player/src/play.py'], 'envars': [], 'minify': False, 'microbit_runtime': ''}
2018-07-18 15:32:22,598 - mu.logic:708(_load) INFO: Loading script from: /Users/neill/projects/microbit/microbit-sample-player/src/play.py
2018-07-18 15:32:22,599 - mu.logic:271(read_and_decode) DEBUG: Trying to decode with utf-8
2018-07-18 15:32:22,599 - mu.logic:274(read_and_decode) INFO: Decoded with utf-8
2018-07-18 15:32:22,599 - mu.logic:287(read_and_decode) DEBUG: Detected newline '\n'
2018-07-18 15:32:22,599 - mu.logic:782(_load) DEBUG: from microbit import display, sleep, button_a, button_b
import audio

def frames_from_file(sndfile, frame):
    while(sndfile.readinto(frame, 32) > 0):
        yield frame

def play_snd(fname):
    frame = audio.AudioFrame()
    with open(fname, 'rb') as sndfile:
        audio.play(frames_from_file(sndfile, frame),wait=True)
        audio.stop()
    del frame

display.show('r')
while True:
    if button_a.is_pressed():
        play_snd('clip.raw')
    if button_b.is_pressed():
        play_snd('clip.raw')
        play_snd('clip.raw')
        play_snd('clip.raw')
        play_snd('clip.raw')
    sleep(200)

2018-07-18 15:32:22,685 - mu.logic:647(restore_session) INFO: Loaded files.
2018-07-18 15:32:22,686 - mu.logic:651(restore_session) INFO: User defined environment variables: []
2018-07-18 15:32:22,686 - mu.logic:655(restore_session) INFO: Minify scripts on micro:bit? False
2018-07-18 15:32:22,699 - mu.logic:1112(change_mode) INFO: Workspace directory: /Users/neill/mu_code
2018-07-18 15:32:26,993 - mu.modes.microbit:239(flash) INFO: Preparing to flash script.
2018-07-18 15:32:26,994 - mu.modes.microbit:249(flash) DEBUG: Python script:
2018-07-18 15:32:26,994 - mu.modes.microbit:250(flash) DEBUG: b"from microbit import display, sleep, button_a, button_b\nimport audio\n\ndef frames_from_file(sndfile, frame):\n    while(sndfile.readinto(frame, 32) > 0):\n        yield frame\n\ndef play_snd(fname):\n    frame = audio.AudioFrame()\n    with open(fname, 'rb') as sndfile:\n        audio.play(frames_from_file(sndfile, frame),wait=True)\n        audio.stop()\n    del frame\n\ndisplay.show('r')\nwhile True:\n    if button_a.is_pressed():\n        play_snd('clip.raw')\n    if button_b.is_pressed():\n        play_snd('clip.raw')\n        play_snd('clip.raw')\n        play_snd('clip.raw')\n        play_snd('clip.raw')\n    sleep(200)\n    \n"
2018-07-18 15:32:27,117 - mu.modes.microbit:297(flash) INFO: Path to micro:bit: /Volumes/MICROBIT
2018-07-18 15:32:27,119 - mu.modes.base:217(find_device) INFO: Found device on port: cu.usbmodem73
2018-07-18 15:32:27,119 - mu.modes.base:218(find_device) INFO: Serial number: 9900023432044e45001180080000002900000000cfcf28bd
2018-07-18 15:32:27,119 - mu.modes.microbit:302(flash) INFO: Serial port: /dev/cu.usbmodem73
2018-07-18 15:32:27,119 - mu.modes.microbit:303(flash) INFO: Device serial number: 9900023432044e45001180080000002900000000cfcf28bd
2018-07-18 15:32:27,119 - mu.modes.microbit:328(flash) INFO: Checking target device.
2018-07-18 15:32:27,637 - mu.modes.microbit:332(flash) INFO: {'sysname': 'microbit', 'nodename': 'microbit', 'release': '1.0.0-rc.1', 'version': 'micro:bit v1.0.0-rc.1+5d3691a on 2018-07-16; MicroPython v1.9.2-34-gd64154c73 on 2017-09-01', 'machine': 'micro:bit with nRF51822'}
2018-07-18 15:32:27,637 - mu.modes.microbit:351(flash) INFO: Board MicroPython: 1.0.0-rc.1
2018-07-18 15:32:27,637 - mu.modes.microbit:353(flash) INFO: Mu MicroPython: 1.0.0-rc.1
2018-07-18 15:32:27,638 - mu.modes.microbit:505(copy_main) INFO: Copying main.py onto device
2018-07-18 15:32:27,639 - mu.modes.microbit:515(copy_main) INFO: ["fd = open('main.py', 'wb')", 'f = fd.write', "f(b'from microbit import display, sleep, button_a, button_b\\nimport a')", "f(b'udio\\n\\ndef frames_from_file(sndfile, frame):\\n    while(sndfile.re')", "f(b'adinto(frame, 32) > 0):\\n        yield frame\\n\\ndef play_snd(fname)')", 'f(b":\\n    frame = audio.AudioFrame()\\n    with open(fname, \'rb\') as s")', "f(b'ndfile:\\n        audio.play(frames_from_file(sndfile, frame),wait')", 'f(b"=True)\\n        audio.stop()\\n    del frame\\n\\ndisplay.show(\'r\')\\nwhi")', 'f(b"le True:\\n    if button_a.is_pressed():\\n        play_snd(\'clip.ra")', 'f(b"w\')\\n    if button_b.is_pressed():\\n        play_snd(\'clip.raw\')\\n ")', 'f(b"       play_snd(\'clip.raw\')\\n        play_snd(\'clip.raw\')\\n       ")', 'f(b" play_snd(\'clip.raw\')\\n    sleep(200)\\n    \\n")', 'fd.close()']
2018-07-18 15:32:28,679 - mu.modes.microbit:450(flash) WARNING: Could not copy file to device.
2018-07-18 15:32:28,679 - mu.modes.microbit:451(flash) ERROR: Could not enter raw REPL.
2018-07-18 15:32:28,679 - mu.modes.microbit:452(flash) INFO: Falling back to old-style flashing.
2018-07-18 15:32:35,185 - mu.logic:1039(show_admin) INFO: Showing logs from /Users/neill/Library/Logs/mu/mu.log
2018-07-18 15:33:07,884 - mu.logic:695(new) INFO: Added a new tab.
2018-07-18 15:33:09,508 - mu.modes.microbit:239(flash) INFO: Preparing to flash script.
2018-07-18 15:33:09,508 - mu.modes.microbit:249(flash) DEBUG: Python script:
2018-07-18 15:33:09,508 - mu.modes.microbit:250(flash) DEBUG: b''
2018-07-18 15:33:09,517 - mu.modes.microbit:297(flash) INFO: Path to micro:bit: /Volumes/MICROBIT
2018-07-18 15:33:09,519 - mu.modes.base:217(find_device) INFO: Found device on port: cu.usbmodem73
2018-07-18 15:33:09,519 - mu.modes.base:218(find_device) INFO: Serial number: 9900023432044e45001180080000002900000000cfcf28bd
2018-07-18 15:33:09,519 - mu.modes.microbit:302(flash) INFO: Serial port: /dev/cu.usbmodem73
2018-07-18 15:33:09,519 - mu.modes.microbit:303(flash) INFO: Device serial number: 9900023432044e45001180080000002900000000cfcf28bd
2018-07-18 15:33:09,520 - mu.modes.microbit:326(flash) INFO: Python script empty. Forcing flash.
2018-07-18 15:33:09,520 - mu.modes.microbit:328(flash) INFO: Checking target device.
2018-07-18 15:33:10,035 - mu.modes.microbit:332(flash) INFO: {'sysname': 'microbit', 'nodename': 'microbit', 'release': '1.0.0-rc.1', 'version': 'micro:bit v1.0.0-rc.1+5d3691a on 2018-07-16; MicroPython v1.9.2-34-gd64154c73 on 2017-09-01', 'machine': 'micro:bit with nRF51822'}
2018-07-18 15:33:10,036 - mu.modes.microbit:351(flash) INFO: Board MicroPython: 1.0.0-rc.1
2018-07-18 15:33:10,036 - mu.modes.microbit:353(flash) INFO: Mu MicroPython: 1.0.0-rc.1
2018-07-18 15:33:10,036 - mu.modes.microbit:381(flash) INFO: Flashing new MicroPython runtime onto device
2018-07-18 15:43:53,559 - mu.modes.base:217(find_device) INFO: Found device on port: cu.usbmodem73
2018-07-18 15:43:53,560 - mu.modes.base:218(find_device) INFO: Serial number: 9900023432044e45001180080000002900000000cfcf28bd
2018-07-18 15:43:53,576 - mu.modes.microbit:597(toggle_files) INFO: Toggle filesystem on.
2018-07-18 15:43:54,717 - mu.modes.microbit:122(ls) ERROR: Could not enter raw REPL.
Traceback (most recent call last):
File "/Applications/mu-editor.app/Contents/Resources/app/mu/modes/microbit.py", line 119, in ls
    result = tuple(microfs.ls())
File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 181, in ls
    ], serial)
File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 132, in execute
    raw_on(serial)
File "/Applications/mu-editor.app/Contents/Resources/app/mu/contrib/microfs.py", line 82, in raw_on
    raise IOError('Could not enter raw REPL.')
OSError: Could not enter raw REPL.
2018-07-18 15:43:54,724 - mu.interface.main:701(show_message) DEBUG: There was a problem getting the list of files on the micro:bit. Please check Mu's logs for technical information. Alternatively, try unplugging/plugging-in your micro:bit and/or restarting Mu.
2018-07-18 15:43:54,724 - mu.interface.main:702(show_message) DEBUG: None
ntoll commented 6 years ago

Thanks for the report. If you manage to find a pattern, please do let me know.