mirror of
https://github.com/sascha-hemi/pycom-documentation.git
synced 2026-03-21 10:05:56 +01:00
GitBook: [master] 334 pages and 4 assets modified
This commit is contained in:
committed by
gitbook-bot
parent
1694c83fcd
commit
260e81c8e8
24
getting-started/programming/repl/README.md
Normal file
24
getting-started/programming/repl/README.md
Normal file
@@ -0,0 +1,24 @@
|
||||
# REPL
|
||||
|
||||
REPL stands for Read Evaluate Print Loop, and is the name given to the interactive MicroPython prompt that is accessible on the Pycom devices. Using the REPL is by far the easiest way to test out Python code and run commands. You can use the REPL in addition to writing scripts in `main.py`.
|
||||
|
||||
The following pages will explain how to use the REPL with both Serial USB and Telnet connections.
|
||||
|
||||
The REPL includes the following features:
|
||||
|
||||
* Input history: use arrow up and arrow down to scroll through the history
|
||||
* Tab completion: press tab to auto-complete variables or module names
|
||||
* Halt any executing code: with `Ctrl-C`
|
||||
* Copy/paste code or output: `Ctrl-C` and `Ctrl-V`
|
||||
|
||||
{% hint style="info" %}
|
||||
There are a number of useful shortcuts for interacting with the MicroPython REPL. See below for the key combinations;
|
||||
|
||||
* `Ctrl-A` on a blank line will enter raw REPL mode. This is similar to permanent paste mode, except that characters are not echoed back.
|
||||
* `Ctrl-B` on a blank like goes to normal REPL mode.
|
||||
* `Ctrl-C` cancels any input, or interrupts the currently running code.
|
||||
* `Ctrl-D` on a blank line will do a soft reset.
|
||||
* `Ctrl-E` enters ‘paste mode’ that allows you to copy and paste chunks of text. Exit this mode using `Ctrl-D`.
|
||||
* `Ctrl-F` performs a "safe-boot" of the device that prevents `boot.py` and `main.py` from executing
|
||||
{% endhint %}
|
||||
|
||||
54
getting-started/programming/repl/serial.md
Normal file
54
getting-started/programming/repl/serial.md
Normal file
@@ -0,0 +1,54 @@
|
||||
# Serial USB \(UART\)
|
||||
|
||||
To use the REPL, a Pycom device must be connected to the host computer with a USB connection either to an Expansion Board or to serial converter \(a diagram of how to do this can be found the the [getting started](../../introduction.md) page for your module\).
|
||||
|
||||
In order to connect to the REPL over USB serial, there are multiple methods. Detailed below are the explanations of how to do it in MacOS, Linux and Windows.
|
||||
|
||||
## All platforms
|
||||
|
||||
By far the easiest way to access the USB UART REPL is via the our [Pymakr plug-in](../../../pymakr-plugin/installation/) for Atom and Visual Studio Code. This adds a pane to the bottom of the editors that allows you to directly access the REPL and any output from the device. Detailed instructions on how to setup Pymakr can be found [here](../../../pymakr-plugin/installation/).
|
||||
|
||||
## macOS and Linux
|
||||
|
||||
To open a serial USB connection from macOS, any serial tool may be used; in this example, the terminal tool `screen` will be used.
|
||||
|
||||
Open a terminal instance and run the following commands:
|
||||
|
||||
```bash
|
||||
$ screen /dev/tty.usbmodem* 115200
|
||||
```
|
||||
|
||||
Upon exiting `screen`, press `CTRL-A CTRL-\`. If the keyboard does not support the `\`-key \(i.e. an obscure combination for `\` like `ALT-SHIFT-7` is required\), the key combination can be remapped for the `quit` command:
|
||||
|
||||
* create `~/.screenrc`
|
||||
* add bind `q` to the `exit` command
|
||||
|
||||
This will allow screen to exited by pressing `CTRL-A Q`.
|
||||
|
||||
{% hint style="info" %}
|
||||
On Linux, `picocom` or `minicom` may be used instead of `screen`. The usb serial address might also be listed as `/dev/ttyUSB01` or a higher increment for `ttyUSB`. Additionally, the elevated permissions to access the device \(e.g. group uucp/dialout or use `sudo`\) may be required.
|
||||
{% endhint %}
|
||||
|
||||
## Windows
|
||||
|
||||
A terminal emulator is needed to open the connection from Windows; the easiest option is to download the free program, [PuTTY](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html).
|
||||
|
||||
### COM Port
|
||||
|
||||
To use PuTTY the serial port \(COM port\) in which the Pycom device is connected, must be located. In Windows, this information can be found from the 'Device Manager' program.
|
||||
|
||||
1. Open the Windows start menu and search for 'Device Manager'
|
||||
2. The COM port for the Pycom device will be listed as 'USB Serial Device' or a similar name
|
||||
3. Copy/Write down the associated COM port \(e.g. `COM4`\)
|
||||
|
||||
### Using Putty
|
||||
|
||||
1. With PuTTY open, click on `Session` in the left-hand panel
|
||||
2. Next click the `Serial` radio button on the right and enter the associated
|
||||
|
||||
COM port \(e.g. `COM4`\) in the `Serial Line` box
|
||||
|
||||
3. Finally, click the `Open` button
|
||||
|
||||

|
||||
|
||||
41
getting-started/programming/repl/telnet.md
Normal file
41
getting-started/programming/repl/telnet.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# Telnet REPL
|
||||
|
||||
Pycom devices also support a connection via `telnet`, using the device's on board WiFi/WLAN. Connect to the device's WiFi Access Point \(AP\) and using the following credentials to connect to the AP. The WiFi `SSID` will appear upon powering on a Pycom Device for the first time \(e.g. `lopy-`\). To re-enable this feature at a later date, please see [network.WLAN](../../../firmware-and-api-reference/pycom/network/wlan.md).
|
||||
|
||||
* password: `www.pycom.io`
|
||||
|
||||
## Telnet Server
|
||||
|
||||
Additionally, to use the MircoPython REPL over telnet, further authentication is required. The default credentials for the telnet server are:
|
||||
|
||||
* username: `micro`
|
||||
* password: `python`
|
||||
|
||||
See [network.server](../../../firmware-and-api-reference/pycom/network/server.md) for info on how to change the default authentication.
|
||||
|
||||
## All platforms
|
||||
|
||||
By far the easiest way to access the Telnet REPL is via the our [Pymakr plug-in](../../../pymakr-plugin/installation/) for Atom and Visual Studio Code. This adds a pane to the bottom of the editors that allows you to directly access the REPL and any output from the device. Detailed instructions on how to setup Pymakr can be found [here](../../../pymakr-plugin/installation/).
|
||||
|
||||
## macOS and Linux
|
||||
|
||||
Once the host machine is connected to the Pycom device's Access Point, a telnet connection may be opened from a terminal instance.
|
||||
|
||||
```bash
|
||||
$ telnet 192.168.4.1
|
||||
```
|
||||
|
||||
Upon connection, the telnet program will prompt for the `username` and `password` in the section above.
|
||||
|
||||
## Windows
|
||||
|
||||
A terminal emulator is needed to open a telnet connection from Windows; the easiest option is to download the free program, [PuTTY](http://www.putty.org/).
|
||||
|
||||
1. With PuTTY open, select telnet as connection type and leave the default port \(`23`\)
|
||||
2. Next enter the IP address of the Pycom device \(e.g. `192.168.4.1`\)
|
||||
3. Finally click `Open`
|
||||
|
||||
{% hint style="info" %}
|
||||
When using a Pycom device with a personal, home or office WiFi access point, the telnet connection may still be used. In this instance, the user will need to determine the Pycom device's local IP address and substitute this for `192.168.4.1`, referred to in the earlier sections.
|
||||
{% endhint %}
|
||||
|
||||
Reference in New Issue
Block a user