Skip to main content

Using pshell

The pshell interface is a Python command-line shell that uses commands defined in Popoto.py to provide a scriptable command interface. It includes commonly used Popoto commands, help output, and tab completion. Command responses are echoed to the shell along with asynchronous alerts from Popoto.

Modes of Operation

There are two fundamental pshell operating modes:

  • Run pshell on the user PC using the PC's local Python installation.
  • Run pshell on the Python installation that exists on the Popoto embedded Linux platform.

Because pshell communicates with Popoto through IP sockets, it can run locally on the target or remotely on any PC connected to the network.

Requirements

The pshell interface requires the following:

  • Python 3.0+, which is already installed on Popoto hardware.
  • The CMD2 command shell, which is already installed on Popoto hardware.

Invoking pshell

As delivered, Popoto starts pshell automatically and presents a command prompt to the user on the RS-422 port.

The pshell.init File

The pshell.init file is located in the root directory, /. This file contains pshell commands that are executed when Popoto powers up.

Users can customize this file to set bootable parameters such as localID and carrier frequency. The syntax is normal pshell syntax. Whitespace is ignored, and lines with # in the first position are treated as comments.

Invoking pshell From a Linux Prompt

Although pshell runs automatically at boot, it is possible to terminate the local pshell process and run pshell from any Python environment with an IP connection to Popoto.

From the Linux command prompt, run:

python pshell

This starts pshell and makes it ready to accept commands.

Invoking Commands

Help

To display a complete list of commands, type:

help

To get help for a specific command, enter:

help <command>

Tab Completion

The pshell interface supports tab completion. Tab completion can also show available options for a particular command.

Commands

The pshell command set includes currently implemented Popoto commands. Each command can be invoked from the prompt, and command-specific help is available through help <command>.

Extending pshell

The pshell interface can be extended with simple Python. For example, to add a command that performs five ranges spaced by 30 seconds, add the following function:

def do_nranges(self, line):
for x in range(1, 5):
self.dol.range(.1)
time.sleep(30.)

The command name in pshell would be nranges. The pshell interface gives users the power of Python to create complex commands, specific syntax, mappings, command checking, and other custom behaviors quickly.