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 name | Verbosity level |
|---|---|
| LOG_a(...) | Assertion |
| LOG_e(...) | Error |
| LOG_w(...) | Warning |
| LOG_i(...) | Information |
| LOG_d(...) | Debug |
The following placeholder codes are supported:
| Placeholder | Description |
|---|---|
| %c | print a charater |
| %d,i | print an integer value (in decimal radix) |
| %u | print decimal unsigned integer |
| %f,F | print a floating-point value in normal (fixed-point) notation |
| %e,E | print a double value |
| %x | print an integer value (in hexadecimal radix) |
| %o | print an unsigned integer value (in octal radix) |
| %s | print a null-terminating string buffer |
| %p | print 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.
Now, as we know, the logic of any cubeapp is processed in on_Tick() callback. So let's change it too:
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:
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.