WOWCube Docs logo
WOWCube Docs
Mission Control
Section Shortcuts
APIExamplesSourceWOWConnectChangelog
Filters
SDK and language defaults persist in cookies.
SDK version
Navigation Tree
Collapsed by default, focused on the active path.
Made byMcKay Seamons
GitHub
  1. Home
  2. Docs
  3. Examples
  4. Working with Emulator
Mission NodeSDK 6.1C++basicsProject Included

Working with Emulator

WOWCube device emulation An emulator is software application that enables one computer system (called the host) to act like another computer system (called t...

Examples / SDK 6.1 / C++ / basics

WOWCube device emulation

An emulator is software application that enables one computer system (called the host) to act like another computer system (called the guest).

Emulation refers to the ability of a computer program to imitate another program or device.

WOWCube emulator is an essential part of WOWCube Development Kit.

Along with WOWCube SDK, this application allows to create and run cubeapps right on your development computer without the need of uploading them each time to a physical WOWCube device.

It also provides a set of useful features for controlling emulated device parameters and seeing how fast your application runs.

But the most useful feature of the emilator is a console.

WOWCube emulator provides eight independent output consoles for each module of the device. The cubeapp that runs on module can print to the output console at practically any moment of its runtime.

The console

Printing to the console is done via void log(uint8_t logLvl, const char *format, ...) function with different verbosity levels. There are also several pre-defined functions for prinding with particular level too:

Function nameVerbosity level
LOG_a(...)Assertion
LOG_e(...)Error
LOG_w(...)Warning
LOG_i(...)Information
LOG_d(...)Debug

The following placeholder codes are supported:

PlaceholderDescription
%cprint a charater
%d,iprint an integer value (in decimal radix)
%uprint decimal unsigned integer
%f,Fprint a floating-point value in normal (fixed-point) notation
%e,Eprint a double value
%xprint an integer value (in hexadecimal radix)
%oprint an unsigned integer value (in octal radix)
%sprint a null-terminating string buffer
%pprint a value of a pointer to void (void*)

You may optionally put a number between the % and the letter of the placeholder code. This number indicates the field width; if the size of the parameter to print at the position of the placeholder is smaller than the field width, the field is expanded with spaces.

Current version of WOWCube emulator does not support coloured output to console

The example

To demonstrate how the console may come in handy, we will take the Time and Timers example and change it slightly.

As in the previous example, the cubeapp will be counting ticks and seconds. This time, however, the values will be seen in the console, and not on the screen.

Why would we want to do that?

Well, the answer is simple: not everything that you may have in your cubeapp app can be rendered on screens. Surely, there will be some variable that you may want to make visible on the screen during the whole time of gameplay.

But what about others, tens of others variables that you may have as well?

How do you know what variable gets what value in a given moment of time? (remember there is no debugger)

Of course, you can print them out to a console! Print them as much as you want, with or without any texts, everything that you need to see.

So let's do some printing...

OnInit() callback is modified the way we can see when it is started and when it is finished.

The Module variable provided by an application class Cubios::Application is used to read the number of a module and print it out too. You will see different module numbers printed by cubeapps that run on different modules.

Working with Emulator
CPP
1void OnInit(Cubios::AppManager& appMgr)
2{
3 WorkingWithEmulator* theApp = new WorkingWithEmulator();
4
5 appMgr.SetApplication(theApp,"AAbbCCddEE");
6
7 theApp->InitializeResources();
8
9}
10
11void WorkingWithEmulator::InitializeResources()
12{
13 LOG_i("\n");
14 LOG_i("*** WOWCube SDK Example \"Working with Emulator\" ***\n");
15
16 LOG_i("Cubeapp is initializing...");
17 LOG_i("Cubeapp is started on module %d",this->Module);
18
19 //Set a timer that ticks once a second
20 this->SetTimer(Timers::myTimer,1000);
21
22 LOG_i("Done.");
23}
24
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.

Now, as we know, the logic of any cubeapp is processed in on_Tick() callback. So let's change it too:

Working with Emulator
CPP
1void WorkingWithEmulator::on_Tick(uint32_t currentTime, uint32_t deltaTime)
2{
3 ...
4
5 LOG_i(" Seconds passed: %d (integer value)",this->seconds);
6 LOG_i(" Current FPS: %.2f (float value)",this->fps);
7
8 std::string str = "Delta time: "+std::to_string(this->deltaTime)+" ms (string value)";
9 LOG_i(" %s",str.c_str());
10
11 LOG_i(" Delta time in HEX: 0x%x (hex value)\n",this->deltaTime);
12
13
14}
15
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.

This will make the cubeapp printing a block of text and values on timer. Pay attention each value has different type: we print out an integer value, a floating point value, a string and a hex.

As a result, you should see the following output to all eight consoles in the WOWCube emulator:

Working with Emulator
CPP
1I/WorkingWithEmulator.cub[1790ms] *** WOWCube SDK Example "Working with Emulator" ***
2
3I/WorkingWithEmulator.cub[1790ms] Cubeapp is initializing...
4I/WorkingWithEmulator.cub[1790ms] Cubeapp is started on module 0
5I/WorkingWithEmulator.cub[1790ms] Done.
6I/WorkingWithEmulator.cub[1790ms] Seconds passed: 0 (integer value)
7I/WorkingWithEmulator.cub[1790ms] Current FPS: 0.00 (float value)
8I/WorkingWithEmulator.cub[1791ms] Delta time: 0 ms (string value)
9I/WorkingWithEmulator.cub[1791ms] Delta time in HEX: 0x0 (hex value)
10
11I/WorkingWithEmulator.cub[1834ms] Seconds passed: 1 (integer value)
12I/WorkingWithEmulator.cub[1834ms] Current FPS: 22.73 (float value)
13I/WorkingWithEmulator.cub[1834ms] Delta time: 44 ms (string value)
14I/WorkingWithEmulator.cub[1834ms] Delta time in HEX: 0x2c (hex value)
15
16I/WorkingWithEmulator.cub[1905ms] Seconds passed: 1 (integer value)
17I/WorkingWithEmulator.cub[1905ms] Current FPS: 14.08 (float value)
18I/WorkingWithEmulator.cub[1905ms] Delta time: 71 ms (string value)
19I/WorkingWithEmulator.cub[1905ms] Delta time in HEX: 0x47 (hex value)
20
Wrapped for easier reading. Turn wrap off to inspect exact line lengths.

Getting logs from WOWCube device

Getting application logs from a real device is a rather interesting and complex topic in itself.

The fact is that, since the WOWCube is not one, but eight devices interacting through an internal network connection, there is no such thing as a common application log at all. At any particular moment in time, each module of the WOWCube device runs its own separate copy of the cubeapp application, and therefore has its own version of the log.

In this regard, before requesting the log, you must specify the number of the module to which the request is made.

As a rule, obtaining a log only from the zero module (or the master module) is sufficient to analyze the behavior of the application as a whole. However, in some cases it may make sense to receive and analyze logs from other modules as well.

Setting up log reading can be done through the WOWCube Device Details panel.

If Receive application logs from module X is selected from the logging option drop-down menu, reading logs via bluetooth will be enabled automatically when you start the cubapp application on WOWCube device with Visual Studio Code.

But the logs will be printed to the OUTPUT console of Visual Studio Code.

Context Rail

Project files

WorkingWithEmulator.cpp
project/src/WorkingWithEmulator.cpp
WorkingWithEmulator.h
project/src/WorkingWithEmulator.h
wowcubeapp-build.json
project/wowcubeapp-build.json
Jump Grid

On This Page

WOWCube device emulationThe consoleThe exampleGetting logs from WOWCube device
Context Rail

Related nodes

info.json
Examples / SDK 6.1 / C++ / basics / Working with Emulator
WorkingWithEmulator.cpp
Examples / SDK 6.1 / C++ / basics / Working with Emulator / project / src
WorkingWithEmulator.h
Examples / SDK 6.1 / C++ / basics / Working with Emulator / project / src
wowcubeapp-build.json
Examples / SDK 6.1 / C++ / basics / Working with Emulator / project
Previous Node
wowcubeapp-build.json
Examples / SDK 6.1 / C++ / basics / Time and Timers / project
Next Node
info.json
Examples / SDK 6.1 / C++ / basics / Working with Emulator