exiting from the REPL

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
cappy2112
Posts: 8
Joined: Fri Apr 22, 2016 9:58 pm

exiting from the REPL

Post by cappy2112 » Tue May 03, 2016 12:40 am

After connecting with the REPL using screen on OSX Mavericks,
I'm not able to exit as I would typically do with the Python REPL.

What is the preferred way to exit the REPL?

Thanks

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

Re: exiting from the REPL

Post by dhylands » Tue May 03, 2016 3:48 am

Well, you don't exit the REPL, except by telling the pyboard to execute something.

You can exit from your terminal emulator (i.e. screen) using whatever technique that progam uses. But the REPL will continue to run on the pyboard until its powered off, or its told to run something else.

cappy2112
Posts: 8
Joined: Fri Apr 22, 2016 9:58 pm

Re: exiting from the REPL

Post by cappy2112 » Tue May 03, 2016 4:04 am

dhylands wrote:Well, you don't exit the REPL, except by telling the pyboard to execute something.

You can exit from your terminal emulator (i.e. screen) using whatever technique that progam uses. But the REPL will continue to run on the pyboard until its powered off, or its told to run something else.

Thanks.

Can I get commit rights to update the docs?
It sure would be good to know this up front

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

Re: exiting from the REPL

Post by dhylands » Tue May 03, 2016 4:39 am

The way that you go about getting something commited is that you fork the micropython repository, create a branch and put your changes on the branch and push them to your own repository (which you'll have fiull rights to) and then you can create a Pull Request.

Your PR will be reviewed by Damien (who is the owner of the official micropython repository) and he'll either merge your change in or tell you what he would like to see changed/improved.

https://guides.github.com/introduction/flow/

pfalcon
Posts: 1155
Joined: Fri Feb 28, 2014 2:05 pm

Re: exiting from the REPL

Post by pfalcon » Tue May 03, 2016 7:39 am

cappy2112 wrote:
dhylands wrote: You can exit from your terminal emulator (i.e. screen) using whatever technique that progam uses.
It sure would be good to know this up front
Indeed, you could, by: a) reading "screen" manual; b) by following MicroPython tutorial which gives you that hint: http://docs.micropython.org/en/latest/p ... l#mac-os-x

Also, please use better forum subsection for your posts - if your questions are about Pyboard, please post to the corresponding section. All your messages are moved there.
Awesome MicroPython list
Pycopy - A better MicroPython https://github.com/pfalcon/micropython
MicroPython standard library for all ports and forks - https://github.com/pfalcon/micropython-lib
More up to date docs - http://pycopy.readthedocs.io/

cappy2112
Posts: 8
Joined: Fri Apr 22, 2016 9:58 pm

Re: exiting from the REPL

Post by cappy2112 » Tue May 03, 2016 8:14 pm

pfalcon wrote: Indeed, you could, by: a) reading "screen" manual; b) by following MicroPython tutorial which gives you that hint: http://docs.micropython.org/en/latest/p ... l#mac-os-x
I'm sure I read that- some time ago. However, when you're used to exiting the REPL in the typical way ...
pfalcon wrote: Also, please use better forum subsection for your posts - if your questions are about Pyboard, please post to the corresponding section. All your messages are moved there.
Will do

Thanks

User avatar
hcet14
Posts: 34
Joined: Sat Dec 19, 2020 12:59 am

Re: exiting from the REPL

Post by hcet14 » Sun Dec 20, 2020 1:32 am

Reset ttyUSB0 on Xubuntu 20.04.

I'm a beginner with this stuff and no programmer at all. I was searching for a way to exit REPL, of course I didn't find one cause the REPL will continue to run on the pyboard until its powered off or disconnected from the USB port. So why not resetting the USB port where your board is connected?

* I'm not responsible for dead boards, dead USB devices, dead PCs
* thermonuclear war, Corona ,or you getting fired because you are
* as bad in programming as me. Please do some research if you have
* any concerns about features included in this proceeding before
* using it! YOU are choosing to make these modifications, and if
* you point the finger at me for messing up any of your devices, I
* will laugh at you.
(borrowed from XDA and adapted)

I use dmesg command to find where ttyUSB0 was enumerated by the host. The USB-TTL converter on my board is a CP2104.

Requirements:
R/w rights on ttyUSB0.
To get them, add yourself to the dialout group and you should have permission to that device all the time. sudo gpasswd -a <username> dialout. Log out/in to make this working.
sudo chmod 666 /dev/ttyUSB0

Open 2 shells. Connect to REPL in one shell and use the 2nd to run the scripts.

Run permission_to_reset_ttyUSB0.sh, it gives permission to reset. You have to do this before first resetting and of course when you connected your board to another USB port.
To reset ttyUSB0 run ttyUSB0_reset.sh. I don't need root rights to run the script, which I don't really understand cause dmesg needs those usually.

This was tested with a cheap USB stick in another port and than changing the ports around.

* I suggest, just use your pyboard, mouse, and keyboard for a 1st testing!!!!!

I didn't encounter any problems, but this is just a starter for those who might be interested.

You may change USB device enumeration!

permission_to_reset_ttyUSB0.sh
  • #!/bin/bash
    sudo chmod 666 /sys/bus/usb/devices/3-1.4/authorized
    sudo chmod 666 /sys/bus/usb/devices/3-1.3/authorized
    sudo chmod 666 /sys/bus/usb/devices/3-1.2/authorized
ttyUSB0_reset.sh
  • #!/bin/bash
    ttyUSB=$(dmesg | grep "cp210x converter now attached to ttyUSB0" | tail -1 | cut -c 20-24)
    echo $ttyUSB
    if [ $ttyUSB == "3-1.4" ]; then
    sh -c "echo 0 > /sys/bus/usb/devices/3-1.4/authorized"
    sh -c "echo 1 > /sys/bus/usb/devices/3-1.4/authorized"
    elif [ $ttyUSB == "3-1.3" ]; then
    sh -c "echo 0 > /sys/bus/usb/devices/3-1.3/authorized"
    sh -c "echo 1 > /sys/bus/usb/devices/3-1.3/authorized"
    elif [ $ttyUSB == "3-1.2" ]; then
    sh -c "echo 0 > /sys/bus/usb/devices/3-1.2/authorized"
    sh -c "echo 1 > /sys/bus/usb/devices/3-1.2/authorized"
    fi
Licensed under WTFPL (http://www.wtfpl.net)

Post Reply