# How to use

## Requirements

* Already flashed Jetson
* Carrierboard that supports UART
* UART cable to connect to the carrierboard

## Hardware setup

### Loopback

The loopback is mostly used for testing the TTY interface and is a good start to get used to it. Its only required to connect one cable from the UART TX to the UART RX signal.

<figure><img src="https://1033397434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRSjAC3s8Rqm0GcGHK6iv%2Fuploads%2FNukHm8l6VmURTSXgtxDF%2FUART_loopback.png?alt=media&#x26;token=9ce9f459-d608-4dcd-a07f-56fd638b31da" alt=""><figcaption></figcaption></figure>

### System to System

If you want to communicate between two system, then you have to connect the UART RX and TX signals crossed with the ones from the other signal.&#x20;

{% hint style="info" %}
Don't forget to connect the ground. The power connection is only required, if your device is not externally powered.&#x20;
{% endhint %}

<figure><img src="https://1033397434-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRSjAC3s8Rqm0GcGHK6iv%2Fuploads%2FjNSWDOmZnrfB1Zm0aYeN%2FUART_SYSTEM_TO_SYSTEM.png?alt=media&#x26;token=7e1546c9-00e1-4490-84d7-9e1f163d00ce" alt=""><figcaption></figcaption></figure>

## Software Setup

Minicom is a terminal tool to simplify the configuration and the usage of the UART port that you want to use.&#x20;

### Install minicom

In case you do not have Minicom already installed use the following command to install it on your Jetson:&#x20;

{% code title="install minicom" overflow="wrap" lineNumbers="true" %}

```bash
sudo apt-get install minicom 
```

{% endcode %}

### Check tty device

{% code title="check tty device" overflow="wrap" lineNumbers="true" %}

```bash
ls -l /dev/ttyS* /dev/ttyTHS*
```

{% endcode %}

{% hint style="info" %}
Each TTY device is mapped to a different hardware UART. This changes for each Jetson platform
{% endhint %}

### Open minicom

Now that everything is set up get the debug logs, you just have to start Minicom with the following parameters:&#x20;

{% code title="start minicom" overflow="wrap" lineNumbers="true" %}

```bash
sudo minicom -D /dev/ttyTHS0
```

{% endcode %}

Your terminal should now look like something like this

```log
Welcome to minicom 2.7.1

OPTIONS: I18n 
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyTHS0

Press CTRL-A Z for help on special keys

```

### Configure TTY Port

#### Start Stop Bits

There is always a Start bit which starts with a low bit pulse and a Stop bit which stops with a high bit pulse. Between the Start and Stop bit are the programmable numbers of data bits (typically between 5 to 8)

#### Hardware Flow Control

Requirements:

* RTS data line (Request to Send)
* CTS data line (Clear to Send)

These lines are cross-connected between two devices. The RTS line is used to output if it is ready to accept new data and the CTS is used to read if it is allowed to send data to the other device.

#### Software Flow Control

Requirements:

* RX (Receiver)
* TX (Transmitter)
* GND (Ground)

The Transmission in a Software Flow Control is started and stopped by sending special flow control characters. The flow control character are send from the Transmitter to the Reciever line.

Special flow control characters:

* XON (Allow transmission from device, control character: DC1 ^Q, ASCII dec 17)
* XOFF (Should halt transmission from device, control character: DC3 ^S, ASCII dec 19)

Example: Jetson 1 sending XOFF to Jetson 2 => Jetson 2 should halt transmitting to A until Jetson 1 sends XON to Jetson 2

#### Differences

| Hardware Flow Control                   | Software Flow Control                                  |
| --------------------------------------- | ------------------------------------------------------ |
| Extra wires for Start/Stop transmitting | Special Character which are send over normal data line |

#### Baud rate

The baud rate is the amount of bits that get transmitted per second.

Example: 1 bit per 200 millisecond is 5 baud

{spacer}

#### Change settings in minicom

Open you minicom terminal and press \[CTRL-A] O to open up the configuration window

{% code lineNumbers="true" %}

```log
Welcome to minicom 2.7.1

OPTIONS: I18n 
Compiled on Aug 13 2017, 15:25:34.
Port /dev/ttyTCU0, 09:43:54

Press CTRL-A Z for help on special keys

            +-------[configuration]--------+
            | Filenames and paths          |
            | File transfer protocols      |
            | Serial port setup            |
            | Modem and dialing            |
            | Screen and keyboard          |
            | Save setup as configuration  |
            | Save setup as..              |
            | Exit                         |
            +------------------------------+
```

{% endcode %}

Press "Serial port setup" to continue

{% code lineNumbers="true" %}

```log
Welcome to minicom 2.7.1

OPTI+-----------------------------------------------------------------------+
Comp| A -    Serial Device      : /dev/ttyTCU0                              |
Port| B - Lockfile Location     : /var/lock                                 |
    | C -   Callin Program      :                                           |
Pres| D -  Callout Program      :                                           |
    | E -    Bps/Par/Bits       : 115200 8N1                                |
    | F - Hardware Flow Control : Yes                                       |
    | G - Software Flow Control : No                                        |
    |                                                                       |
    |    Change which setting?                                              |
    +-----------------------------------------------------------------------+
            | Screen and keyboard          |
            | Save setup as configuration  |
            | Save setup as..              |
            | Exit                         |
            +------------------------------+
```

{% endcode %}

In this Panel you can configure:

Change Baudrate (E)

{% code overflow="wrap" lineNumbers="true" %}

```log
Bautrate  Start bit  Parity bit  Stop bit
 115200       8          N          1
```

{% endcode %}

Toggle Hardware Flow Control (F)

Toggle Software Flow Control (G)

After changing your settings press Enter to save changes and go to Exit to close the configuration
