Raspberry Pi setup

Install Otii Server on a Raspberry Pi

Requirements

Hardware

  • Otii hardware: Otii Arc Pro or Otii Ace Pro

  • Raspberry Pi 4B rev 1.2 8 GB or Raspberry Pi 5 8GB

  • USB SSD disk

  • External DC power supply

  • Device under test (DUT)

  • Jumper wires

  • Otii server will run on a Raspberry Pi 4/5 with less than 8 GB RAM, but it is not recommended.

  • Running the system on an SD card will degrade performance, and the memory card will likely quickly wear out. Use the USB SSD disk instead, as recommended.

Software

  • Otii Automation Toolbox License

  • Raspberry Pi OS (64-bit)

Otii 3 Server is a 64-bit application. Therefore, the 64-bit version of the Raspberry Pi OS is a must.

Setting up Raspberry Pi

Installing Raspberry Pi OS on the SSD Disk

  1. Plug the SSD disk to the computer via USB.

  2. Download, install, and run Raspberry Pi Imager.

  3. Click on the different options listed in the Raspberry Pi Imager, and select the following options:

    • Raspberry Pi Device: Raspberry Pi 4 or 5

    • Operating System: Raspberry Pi OS (64-bit)

    • Storage: The one assigned to the SSD disk

    Once everything is selected, it should look like below:

  4. Click the "NEXT" button.

  5. In the following window, “Use OS customization”, click on “EDIT SETTINGS”.

    1. In the GENERAL tab, define the hostname, username, password, SSID, and password of the network you intend to connect to, the country of the Wireless LAN, and local settings such as time zone and keyboard layout.

    2. In the SERVICE tab, toggle the "Enable SSH" option to enable it, and click on "Use password authentication".

    3. Click the "SAVE" button to save the changes made.

    4. Once it takes you to the previous window, click on the “YES” option to apply the custom settings to the OS.

  6. As a final warning, a warning window will pop up to confirm if you are sure to continue, as it will overwrite the existing data on the disk. Click “YES", then the system will ask for the computer password to proceed – the system will take a few minutes to download the OS and write it into the SSD disk.

  7. Once completed, a message will be displayed indicating that the disk can now be removed from the reader. Now, it is time to connect it to the Raspberry Pi, turn it on, wait a couple of seconds, and access it via SSH.

Wiring up

To wire up the system, all the hardware requirements mentioned above must be on hand.

  1. Take the Raspberry Pi, without powering it up, connect the SSD Disk to the bottom USB 3 port of the Raspberry Pi.

  2. With the USB cable provided in the Otii hardware box, plug the USB output into the Otii hardware box and the USB type A output into the top USB 3 port of the Raspberry Pi.

  3. Supply power to the Otii hardware with an external DC power supply, fulfilling the essential requirements for proper operation. Read in more detail here. After powering up, the LED on the front of the Otii hardware must be turned on.

  4. Lastly, power the Raspberry Pi through the USB C power supply port, ensuring that it is powered with the optimal parameters: 5V and a current capacity of at least 3A (5A for Raspberry Pi 5).

Once the entire system is connected, it should look like the following:

You must also connect the desired DUT to be analyzed and optimized, which must be set up under the UART configuration, allowing to debug the incoming messages, to automate processes based on these received messages.

Access Raspberry Pi using SSH

Once the Raspberry Pi has been properly powered up, you can access it via SSH. To do so, use SSH clients such as Putty or Termius.

  1. If you do not have it installed, download, install, and open the SSH client of your preference.

  2. In the connection configuration, assign:

    1. Hostname: assigned in the Raspberry Pi Imager (in my case raspberry.local), or you could also assign the IP address allocated to the Raspberry Pi; to find out the IP address, use tools to scan the network you are connected to to identify the different devices connected, as Fing.

    2. Port: 22.

    3. Connection type: SSH

    Based on the SSH client used, proceed with the following steps to establish the connection.

  3. Once connected, the username and password previously assigned must be entered, in my case, pi.qoitech as the username.

Once accessed, observe you are now interacting from the Raspberry Pi.

Installing Otii Server

The Otii server will enable the automated test setup for the Otii Product suite tools through scripting, supporting popular languages like Python and Java.

  1. Visit the Qoitech User Management portal, and access your account. In case of not having one already, create it by simply clicking on "Create an account" – once created, the account must be verified with the associated email address to activate it.

  2. Within the User Management portal, navigate to the Download page.

  3. To download it, the EULA terms must be accepted by clicking the check box.

  4. Select the Raspberry Pi version.

  5. Once downloaded, the .deb file must be transferred to the Raspberry Pi. This can be done in two ways:

    • If you have access to the Raspberry Pi interface, you can surf in the browser and then repeat the previously mentioned steps to download the file directly on the Raspberry Pi.

    • Copy the file using scp, a command that manages the copy of files or directories between a local and remote system or between two remote systems. In this case, the local system would be the computer, and the remote system would be the Raspberry Pi. Note that this option will be explained below.

  6. To copy files from the computer to the Raspberry Pi, run the following command on the computer's terminal and assign the required information:

    scp <Path to File Copy> <username>@<IP Address of Raspberry Pi>:<Path that File will go>

    Once the information has been assigned, it should look like:

    scp Downloads/otii_server_3.4.3_arm64.deb pi.qoitech@192.168.1.64:/home/pi.qoitech/Downloads
  7. In remote access to the Raspberry Pi, we go to the directory where we copied/downloaded our .deb package.

    cd Downloads
  8. Then, execute the installation with:

    sudo dpkg -i otii_server_3.x.x_arm64.deb

Once installed, a scalable, low-power, functional testing of IoT and embedded systems can now be easily started.

Running Otii Server

For the purpose of the example below, two SSH connections must be established to run and interact with the Otii server: one to run the Otii server and another for user management and scripting. However, note that the Otii server can be activated directly from the scripting if required.

  1. On one of the connections, run the following command to run the Otii Server. The connection should stay established in the background:

    otii_server 
  2. On other connection, run the following command to enable the user management capability within the command line interface (CLI):

    python3 -m venv path/to/venv
    source path/to/venv/bin/activate
    pip install otii_tcp_client
  3. Now, you can either operate User Management (UM) using Python, or by scripting. See the Automation Toolbox documentation for full details.

Running Python script

For a practical use case, let's run a Python example that shows how to log in, list licenses, reserve and return a license, and log out.

  1. On the Raspberry Pi, create a Python file. You can use the nano command, assign the name and type of the file:

    nano user_management.py
  2. Copy and paste in the code below:

    user_management.py
    import json
    import os
    import time
    from otii_tcp_client import otii_connection, otii as otii_application
    
    # The default hostname and port of the Otii 3 application
    HOSTNAME = '127.0.0.1'
    PORT = 1905
    
    CREDENTIALS = './credentials.json'
    
    ABBREVATIONS = {
        "Automation": "AT",
        "Battery": "BT",
        "BatteryValidation": "BVT",
    }
    
    def list_and_reserve_licenses():
        '''
        This example shows you how to login,
        list licenses, reserve and return a license,
        and how to logout.
        '''
        if not os.path.isfile(CREDENTIALS):
            raise Exception('You need to create a credentials.json file')
    
        # Connect to the Otii 3 application
        connection = otii_connection.OtiiConnection(HOSTNAME, PORT)
        connect_response = connection.connect_to_server(try_for_seconds=10)
        if connect_response['type'] == 'error':
            raise Exception(f'Exit! Error code: {connect_response["errorcode"]}, '
                            f'Description: {connect_response["payload"]["message"]}')
        otii = otii_application.Otii(connection)
    
        # Read the credentials
        with open(CREDENTIALS, encoding='utf-8') as file:
            credentials = json.load(file)
    
        # Login to the Otii license server
        otii.login(credentials['username'], credentials['password'])
    
        # List all available licenses
        otii_licenses = otii.get_licenses()
        print('  Id Type         Available Reserved to     Hostname')
        for otii_license in otii_licenses:
            available = "Yes" if otii_license["available"] else "No "
            print(f'{otii_license["id"]:4d} {otii_license["type"]:12} {available}       '
                  f'{otii_license["reserved_to"]:15} {otii_license["hostname"]}')
            for addon in otii_license['addons']:
                print(f'     - {addon["id"]}')
    
        # Reserve a license that includes access to Automation Toolbox
        otii.reserve_license(credentials['license_id'])
    
        # Do your stuff
        time.sleep(3)
    
        # Return the license and logout
        otii.return_license(credentials['license_id'])
        otii.logout()
    
    if __name__ == '__main__':
        list_and_reserve_licenses()
  3. Create a file within the same folder as the script above with the name credentials.json

  4. Copy the JSON file below, assign the username and password of your Qoitech User Management account, as well as the Automation Toolbox license ID, which can be easily found in the UM either from the Otii 3 Desktop App or the web. Then, save it.

    {
            "username": "YOUR USERNAME",
            "password": "YOUR PASSWORD",
            "license_id": "YOUR LICENSE ID"
    }
  5. Run the user_management.py script, by running the following command:

    python user_management.py

    Upon running the code, the following logs will be shown:

      Id Type         Available Reserved to     Hostname
    4389 Pro          Yes                       None
    4723 All          Yes       {your_username}  raspberrypi
    Progress on otii_reserve_license is {}
    Progress on otii_return_license is {}

Remember you must have the Otii 3 Desktop App closed, no session logged in, and no license reserved to run the script above successfully.

The next step is to fully explore the Otii TCP Client's functionalities and create custom Python scripts to automate the tests required throughout your hardware development cycles. Refer to Qoitech's Github to explore TCP clients for Python or Java, which contain ready-to-use examples.

Last updated