.. _shell:

Debugging Shell
===============

The system provides a serial debugging shell on the RX/TX pins in the debugging connector. The serial configuration is 8N1 at 115200 baud, and the console requires an ``Enter`` key press to be activated.

For Linux systems, Satlab recommends the ``tio`` serial terminal application (https://tio.github.io/) but other applications such as ``minicom`` should also work. When using the Satlab JTAG/serial adapter, the debug shell is typically available on ``/dev/serial/by-id/usb-FTDI_Dual_RS232-if01-port0``.

A number of timestamped log messages are printed during boot from various logging groups. Additional logging can be enabled at runtime using the ``trace`` commands. The ``help`` command can be used to list available commands and their usage. The installed software version and build information is also printed in the debugging shell during boot.

.. code-block:: none

    satlab@satlab:~$ tio -b 115200 /dev/serial/by-id/usb-FTDI_Dual_RS232-if01-port0
    [tio 09:49:45] tio v1.32
    [tio 09:49:45] Press ctrl-t q to quit
    [tio 09:49:45] Connected
    [srs-4] reboot

    [    0.010020] system: Copyright (c) 2020 Satlab A/S <satlab@satlab.com>
    [    0.010128] system: boot: 1 reset cause: power-on reset
    [    0.010241] system: board serial #31123456
    [    0.017846] prop: using stored cal properties

    Satlab SRS-4 v1.3.0

    [srs-4] help
    Available commands:
    boot            Bootloader commands
    csp             CSP commands
    help            Show available commands
    history         Show previous commands
    prop            System configuration properties
    reboot          Reboot system
    time            Time command execution
    tm              Telemetry commands
    trace           Trace subcommands
    uptime          Show system uptime
    watch           Run command periodically

To show current telemetry values, run the ``tm show`` command. The ``watch`` command can be used to periodically run a command, with the ``-b`` switch enabling screen blanking between updates. Press any key to stop the loop:

.. code-block:: none

    [srs-4] watch -b tm show
    Running command 'tm show' every 1000 ms
    Power Rails
    VIN            5977 mV    252 mA   1510 mW
    3V3            3370 mV    422 mA   1422 mW
    1V8            1807 mV    283 mA    513 mW
    1V0             966 mV    335 mA    324 mW
    PA                0 mV      0 mA      0 mW

    Temperature Sensors
    PSU           26.68 C
    MCU           29.31 C
    FPGA          33.93 C
    XCVR          28.93 C
    LNA           28.93 C
    PA            27.12 C
    Interrupted

Dynamic debugging messages can be enabled through the ``trace`` command group. This can for example be used to log all received and transmitted CSP messages. To do so, run ``trace mask csp all``:

.. code-block:: none

    [srs-4] trace mask csp all
    [  288.254384] csp: INP: S 1, D 24, Dp 1, Sp 61, Pr 2, Fl 0x00, Sz 1 VIA: KISS
    [  288.254507] csp: SERVICE: Ping received
    [  288.254587] csp: OUT: S 24, D 1, Dp 61, Sp 1, Pr 2, Fl 0x00, Sz 1 VIA: KISS
