Can't get REPL prompt

General discussions and questions abound development of code with MicroPython that is not hardware specific.
Target audience: MicroPython Users.
BillG
Posts: 9
Joined: Fri Feb 05, 2016 4:12 pm

Can't get REPL prompt

Post by BillG » Mon Apr 25, 2016 6:14 pm

Simply put, when I press Ctrl-C in puTTY, my program stops but I don't get a REPL prompt. Where is the REPL data going?

boot.py:

Code: Select all

import pyb
pyb.usb_mode('CDC+MSC') # act as a serial and a storage device
pyb.main('main.py') # main script to run after this one
main.py:

Code: Select all

import pyb
switch = pyb.Switch()
leds = [pyb.LED(i+1) for i in range(4)]
accel = pyb.Accel()
i = 0
while True:
    y = accel.y()
    i = (i + (1 if y > 0 else -1)) % len(leds)
    leds[i].toggle()
    pyb.delay(5 * max(1, 30 - abs(y)))
I'm running Windows - device manager shows COM14 as Pyboard USB comm port (I have pyBoard v1.1). I run puTTY on COM14 at 9600 baud. On RST, program runs and LEDs toggle as expected, with rate dependent on Y axis tilt. I press Ctrl-C once and the LEDs stop toggling, so I assume the program has stopped and I should get REPL prompt, but I get nothing in puTTY. The puTTY screen remains blank with the cursor at the top left position.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Can't get REPL prompt

Post by dhylands » Tue Apr 26, 2016 3:50 pm

Make sure that its still on COM14.

I'm not sure of the exact sequence you're using, but when the pyboard restarts USB, if the serial port is still open on the host side, then the host will wind up assigning the next higher COM port (so it might have moved to COM15).

BillG
Posts: 9
Joined: Fri Feb 05, 2016 4:12 pm

Re: Can't get REPL prompt

Post by BillG » Mon May 02, 2016 7:06 pm

I think my difficulty is due to a problem in my computer, perhaps conflicting USB drivers. I cranked up an old laptop running Windows XP, removed all old USB drivers, installed pybcdc.inf, and the program works properly there.

JJW
Posts: 17
Joined: Mon Nov 16, 2015 1:43 pm

Re: Can't get REPL prompt

Post by JJW » Fri Aug 05, 2016 7:04 pm

Maybe my difficulties are related? I just received 3 PybLite V1.0 (v1.5.2); had putty - REPL working yesterday on 2 different computers. But, cannot get >>> prompt anymore using either Putty or Tera Term on both Windows7 computers today. Uninstall and reinstall pybcdc driver does not help. Pyboard is programmable with main.py; spirit program LEDs flash but no more REPL prompt. Must have ejected Pyb more than 10 times without change.

In desperation, I inserted Pyboard #2. 2nd Pyboard has working REPL today (instead of COM4, 2nd board is COM5). But, how do I get Pyboard #1 to work with putty again? Has Pyb #1 corrupted COM4? How to switch Pyb #1 to COM6?

Read online documentations but I need more basic help...

JJW
Posts: 17
Joined: Mon Nov 16, 2015 1:43 pm

Re: Can't get REPL prompt

Post by JJW » Sat Aug 06, 2016 8:12 am

I am learning PYBLite is different. One must change PYBv1.0 codes to run on PYBLite v1.0.

Since I have 2015 PYBv1.0 and the July 2016 PYBv1.1 boards, I plugged in 3 flavors of PYB boards to compare. Each board takes on a different COM. I can download main.py and run program on PYB OK. Putty worked briefly. Then, no more >>> prompt for REPL. Tried uninstall, reinstall pybcdc, restarted computers, reset PYB; I simply don't know how to resurrect REPL.

Maybe Windows 7 changed by 2016 updates. Tera Term and putty are mis-communicating with two Windows 7 laptops?

Need more help how to employ either putty or Tera Term + Windows7 with PYBv1.1?

BillG
Posts: 9
Joined: Fri Feb 05, 2016 4:12 pm

Re: Can't get REPL prompt

Post by BillG » Mon Aug 08, 2016 12:03 am

What fixed the problem for me was running Dell diagnostics on the USB system. I know the specifics of what I'm offering are only applicable to Dells, but maybe others can find similar diagnostic programs. In dell.com/support, once you let it identify your computer, you are offered an array of tests. There is a Quick diagnostic then there is a list of specific tests you can run. I ran the USB test. It didn't say anything specific was wrong, but afterwards puTTY worked properly again. I can ctrl-C out of running programs and get the REPL prompt.

I am using Windows 7. I install lots of different USB devices and drivers. I assume something subtle was wrong with the way the Pyboard USB driver was being handled, and running the diagnostic fixed it.

JJW
Posts: 17
Joined: Mon Nov 16, 2015 1:43 pm

Re: Can't get REPL prompt

Post by JJW » Wed Aug 10, 2016 6:50 pm

Tried USB Dell Diagnostics on Dell laptop per recommendation from BillG. Diagnosis did not detect problem. Dell provided additional diagnosis from iolo Technologies which corrected miss-placed links, security, etc. Unfortunately, Windows 7 Professional still cannot get REPL prompt with putty.

There are different versions of putty, should I be using earlier versions?

JJW
Posts: 17
Joined: Mon Nov 16, 2015 1:43 pm

Re: Can't get REPL prompt

Post by JJW » Fri Aug 12, 2016 4:02 pm

Lacking REPL prompt has become show stopper prototyping with Pyboards.

After saved main.py and pressed RST, alternatively flashing green and yellow LEDs error message occurred although the simple script had worked before. Documentation states use REPL to debug but REPL >>> prompt disappeared from both putty and Tera term after the first day using 3 new Pyboards.

Rebooting Pyboard plus reload the same script is how I use Pyb. No way to debug complex programs.

What is DFU? No warning of missing STM32 Bootloader so I assume it had loaded automatically. But, I do not see STM device in DFU mode within my list of Universal Serial Bus controllers. Should I short Boot pin to 3.3V and then upgrade firmware? Recommended site to download up to date SMT32 bootloader program for Windows 7?

Desperately needing to use REPL...

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Can't get REPL prompt

Post by dhylands » Fri Aug 12, 2016 8:54 pm

Follow the filesystem reset procedure here:
http://docs.micropython.org/en/latest/p ... boot-modes

This will wipe all of the files on the pyboard. Now you should get to your REPL prompt.

For developing, I normally don't use main.py and instead call if something else. Lets suppose I called it foo.py.

Then when you boot the pyboard you get to a REPL. I'd then type:

Code: Select all

import foo
and this way I'll see any errors on the REPL. When I've fully debugged things and I'm happy with it, then I'll create a main.py with the line:

Code: Select all

import foo

JJW
Posts: 17
Joined: Mon Nov 16, 2015 1:43 pm

Re: Can't get REPL prompt

Post by JJW » Sat Aug 13, 2016 3:24 am

Thanks dhylands for reply.

I had rebooted Pyboards many times. Am able to save main.py and RST to run script afterwards but no REPL prompt for debug. Any other suggestion?

No idea what else to try other than to reload DFU?

Post Reply