Search by Tags

Visual Studio Code Extension for Torizon

 
Applicable for

Article updated at 06 May 2020
Compare with Revision

Subscribe for this article updates

Introduction

The purpose of the extension is to help users develop, deploy and debug applications on TorizonCore, using Visual Studio Code as the IDE. The following programming languages are currently supported:

  • Python
  • .NET Core

This article will help you set up the recommended configuration.

Prerequisites

Note: Make sure that the board and development computers are on the same network.

Required Software

Here you will install:

  • Visual Studio Extension for Torizon
  • .NET Code SDK (Required for .NET Core Applications Only)
  • Windows Subsystem for Linux (Windows Development OS Only)
  • ARM emulation mode (Linux Development OS Only)

Install the Visual Studio Code Extension for Torizon

The latest version of the Toradex Torizon Support extension can be found on the Visual Studio Code marketplace:


  • Toradex Torizon Support - Visual Studio Code Marketplace

    Toradex Torizon Support - Visual Studio Code Marketplace

Click on the extensions button in Visual Studio Code as shown in the image below and search for Toradex Torizon Support:


  • Toradex Torizon Support Extension for Visual Studio Code

    Toradex Torizon Support Extension for Visual Studio Code

Verify that the extension has been enabled:


  • Torizon extension

    Torizon extension

Choose your development PC OS from the tabs below:

Install the .Net Core SDK on Windows

Warning: Required for .NET Core applications only

Download the latest .NET Core SDK on Microsoft Official Website and follow the setup installation. In order to check if everything went well, open up a command prompt and run the following command

$ dotnet

If the installation was successful, you should see the .NET options on the command prompt

Expected result

Install the Windows Subsystem for Linux

In order to obtain the Linux subsystem, please refer to the Microsoft instructions. After all the steps were followed, reboot your machine and go through the steps below.

Open the Microsoft Store and install a distro, Ubuntu 18.04 LTS is recommended. When the process ends, open CMD and run the following command:

$ wsl

It will ask for your username and password, write it, and run the command again to see the following output:


  • Wsl output

    Wsl output

After evaluating the Windows Subsystem for Linux really works, install rsync and ssh from the Linux prompt:

$ sudo apt-get update && sudo apt-get install rsync ssh

Install the .Net Core SDK on Linux

Warning: Required for .NET Core applications only

Follow the .NET Microsoft Documentation in order to install it on Linux, and make sure you select the correct distribution on the left.

You cant test if everything went well by running the following command

$ dotnet --info
Expected result

Enable ARM Emulation Mode

The VS Code extension needs ARM emulation mode enabled through binfmt. To enable it press F1 and then type "Torizon: Enable ARM emulation for Docker containers":


  • Torizon Enable ARM Emulation

    Torizon Enable ARM Emulation

Click on continue in the following window:


  • Continue arm emulation

    Continue arm emulation

If everything goes well, you should see the ARM emulation enabled message in your Visual Studio Code.

Add Target Device Connection In Visual Studio Code

To debug and test our application we need a device to deploy it. Open Visual Studio Code and press F1 to open the command bar, then you can run one of two commands below to add a device connected over the network or over serial.


  • Adding a Torizon device

    Adding a Torizon device

The command torizon.detectSerialDevice will add a serial connection to a Torizon device, you will be prompted to specify which port on your development PC the device is connected to over serial.

The command torizon.detectNetworkDevice will add a network connection to your Torizon device, you will be prompted to specify the IP address of your Torizon device. Just make sure that your device is on the same network as your development PC and can actually be reached.

Either way, you will then be prompted to enter a valid username and password that is on your Torizon device, this will make it briefly reboot. You should see some dialog in the Terminal output of the VS code that shows whether the connection was a success or not. Also if you’ve already created a Torizon Project then the device will be listed via the Torizon extension sidebar menu.

Expected Result:


  • Adding a device - expected result

    Adding a device - expected result

Visual Studio Code Extension Commands

On Visual Studio Code, executing command is easy: you just need to press F1 to open the command bar then type the command you want. Here is a list with every command and its respective action and category

Command Action Category
torizon.createPythonApp Create Python Application Torizon/Python
torizon.createDotNetCoreApp Create .NET Core Application Torizon/.NET
torizon.createAspDotNetCoreApp Create ASP.NET Application Torizon/.NET
torizon.detectSerialDevice Detect device via serial port connection Torizon
torizon.detectNetworkDevice Detect device via network connection Torizon
torizon.deleteDevice Remove device from device list Torizon
torizon.selectDevice Select default deployment device Torizon
torizon.buildPythonReleaseContainer Build release container for Python application Torizon/Python
torizon.enableARMEmulation Enable ARM emulation for docker containers Torizon
torizon.deployReleaseContainer Deploy release container Torizon
torizon.runReleaseContainer Run/restart release container Torizon
torizon.updateContainers Download/update base containers Torizon
torizon.buildDotNetReleaseContainer Build release container for .NET application Torizon/.NET

Known Issues

  • The extension will start the back-end server which takes around 30 seconds. If you try to run commands during that time you’ll get an error.
  • Toradex provides templates for 32 and 64 bits containers, at the moment 32bit version is the one used for the test during development. Feel free to test on the 64bit version.
  • There is no UI to configure projects, monitor devices, etc. (will come soon). At the moment, you can edit config.yaml in the appconfig_0 folder. See Moses IDE Backend for reference.