Integrate se-scope to a new target

Do you want to get started with se-scope-target and learn how to integrate it in an existing codebase and ecosystem. This page provides a summary of actions that must be done in order to run se-scope-target on your microcontroller. It also serves as a reference for how to integrate se-scope into an existing codebase and ecosystem.

Your se-scope-target is already running? Jump to Getting started with se-scope-gui

1. Add se-scope-target as a Submodule

To use se-scope-target in your existing codebase, you can simply clone the se-scope-target repository or add it as a submodule to your existing git repository. Use the git documentation for submodules to get started with submodules.

2. UART driver

To transmit data between the gui and the target we use the UART protocol. In order for your target to communicate via UART, you must implement a driver.

Implement a UART driver

The UART driver should fulfill the basic functions of such a driver, these are: putting data interrupt based into an output buffer of the microcontroller and reading data back from an input buffer without losing any data.

Example

Below you can see a snippet of an example uart-driver for an STM32 Nucleo board, to find example implementations for other boards, check out our examples repository.

3. Run the stack

The ScopeFramedStack_run method is the heart of se-scope-target, it runs the whole scope stack, this includes processing the collected data from variables and loggers, changing parameters according to received data and putting sendable data packages into the output buffer.

Create the scope-stack

In order to be able to run se-scope, you have to create an instance of the ScopeFramedStack. The parameters of the constructor are structs, which define constants like the number of channels. For more information, see the code snippet below.

Call the run method

The ScopeFramedStack_run method should be called in the main loop of your program.

Run scope in a RTOS

If you are using a RTOS, the ScopeFramedStack_runThreadScope method should be called in one of the threads. Se-scope-target is designed to be used with a RTOS and provides a lot of features for thread-safety like built-in mutexes. Take a look at our examples repository to see implementations of se-scope-target running in a RTOS.

4. Send/Receive Data

To exchange data between the target and se-scope-gui, you use the UART driver implemented in step 2.

Transceiver setup

se-scope-target defines a transceiver from which you can get the processed data to send and to which you can forward the data that is received from the gui application. To use the transceiver you have to instantiate it in your UART driver (Step 2) by getting it from the scope stack as it is shown in the example code below.

Transceiver usage

Once the transceiver is correctly set up, you can simply use its get-method to copy data from the scope-stack into the output buffer of your UART driver resp. the put-method to copy data from the input-buffer into the scope-stack.

5. Announce variables

To plot variables that are defined in your codebase in se-scope-gui, you have to announce them to se-scope-target in order for the stack to keep track of the variables and send them regularly.

How to announce a variable

After you have configured the scope-stack (step 3), you can announce variables to the stack. To do this you get an AnnounceStorage object from the scope-stack to which you add the variables as well as their name and data-type.

How many variables can be announced?

Note that you can announce as many variables as you want, but you only have a limited amount of channels to stream the variables, so se-scope-gui can only display as many variables as the amount of channels at the same time.

6. Logger

The logger of se-scope allows you to display log-messages sent from the target in the se-scope-gui. You have already created the logger (step 3), this section describes how to use it.

How to log events

In order to run the se-scope-target (step 3) you have already created a logger instance, defined the message-priorities and passed both to the scope stack. With the write-method of this logger instance, you can easily transmit log-messages to se-scope-gui (see example).

Address

Source Engineers GmbH Mittelstrasse 10
CH-3012 Bern

Contact

Email: scope@sourceengineers.com
Phone: +41 32 511 40 83