The program tab of the RED Brick tab of the Brick Viewer is the most important piece of user interface for the RED Brick. It can help you to upload, modify and monitor your programs.
If you start the RED Brick for the first time you will be presented with an empty program list and three buttons:
After you have uploaded your first program you can select the program and information about the program will be displayed on the right. You can edit the configuration and also view and download logs.
Uploading a program to the RED Brick consists of 8 easy steps that you are guided through by a wizard:
Please note that the hierarchical structure that you create here will be used on the RED Brick exactly as specified. For example, if you want to upload a small web page that is written in Python/Flask with the following structure
and you want the index.py
as well as the two folders to be in the root
directory of your program on the RED Brick, you need to first
select the index.py
with Add Files and then independently select the
two folders with Add Directory.
Every "Add" will add the thing you are selecting to the root directory of the RED Brick program.
Depending on the chosen language you have to upload different types of files:
.js
, .pl
, .php
, .py
, .rb
).jar
, .class
, .exe
)In step 3 you have to configure the compiler/interpreter of the language that you selected in step 1. This step is documented for each language individually.
The Tinkerforge C/C++ Bindings are preinstalled on the RED Brick
(compiled as a library libtinkerforge.so
, available in /usr/lib/
).
The headers are available in /usr/include/tinkerforge
. You can
directly link against this library (see example below).
Start Mode: Currently only Executable is available as start mode.
Executable: Name of the executable that should be called. This is either the name of the cross compiled executable that you are uploading or it is the name of the executable that is created during compilation
Compile From Source: If you check this checkbox, your code will be
compiled upon upload. If you use this option your project must
contain a Makefile
. An example Makefile for a small
project that uses the Tinkerforge Bindings and consists otherwise
of the file example.c
looks as follows:
Download (Makefile), Download (example.c)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | # Defines
CC=g++
CFLAGS=-c -Wall -I/usr/include/tinkerforge
LIBS=-ltinkerforge -lpthread
EXE=example
SOURCES=example.c
OBJECTS=$(SOURCES:.c=.o)
# Build Rules
all: $(SOURCES) $(EXE)
.c.o:
$(CC) $(CFLAGS) $< -o $@
$(EXE): $(OBJECTS)
$(CC) $(OBJECTS) -o $(EXE) $(LIBS)
clean:
rm -f *.o $(EXE)
|
Working Directory: Specify the
working directory
of your program. You can use a path that is relative to the
root directory of your program. Usually you will leave this as .
.
Make Options: If you compile from source you can also add make parameters.
For C# the Tinkerforge.dll
is available in /usr/lib/
and can
thus be found by mono. That means, if you compile your C# program
and you use the Tinkerforge.dll
as reference, it will be
automatically found on the RED Brick. You don't have to add
the Tinkerforge.dll
in step 2.
Mono Version: Currently there is only one mono version installed.
Start Mode: Currently only Executable is available as start mode.
Executable: Choose the .NET executable from the files that you added
in step 2. A .NET executable usually has the file ending .exe
.
Your executable will be executed with mono, but you can compile on Windows with Visual Studio, that works without problem. Make sure that you don't use any Windows specific libraries that are not available on the RED Brick.
Working Directory: Specify the
working directory
of your program. You can use a path that is relative to the
root directory of your program. Usually you will leave this as .
.
Mono Options: Here you can add options that will be given to the mono JIT compiler.
Start Mode: Currently only Executable is available as start mode.
Executable: Name of the executable that should be called. This is either the name of the cross compiled executable that you are uploading or it is the name of the executable that is created during compilation
Compile From Source: If you check this checkbox, your code will be compiled upon upload. As build system fpcmake or lazbuild (requires Image >= 1.7 and Brick Viewer >= 2.2.6) can be used:
For fpcmake your project must contain a Makefile.fpc
. An example
Makefile for a small project that uses the Tinkerforge Bindings and has
the file Example.pas
as main unit looks as follows:
[target]
programs=Example
[require]
packages=tinkerforge
For lazbuild your project must contain a Lazarus project file (*.lpi
).
Working Directory: Specify the
working directory
of your program. You can use a path that is relative to the
root directory of your program. Usually you will leave this as .
.
Make/Lazbuild Options: If you compile from source you can also add make/lazbuild parameters.
The Tinkerforge.jar
Java Bindings are available in
/usr/tinkerforge/bindings/java/
. The file is already added
to the class path by default, so you can just import the Tinkerforge
classes by the usual means, e.g. import com.tinkerforge.IPConnection;
.
.
.Client-Side (Browser): If you use client-side JavaScript, there is
nothing to configure. You can add your .html
files in step 2,
which are then available through the
RED Brick web interface. The
Tinkerforge.js
can be used via:
<script src="/Tinkerforge.js" type='text/javascript'></script>
Server-Side (Node.js): If you use Node.js, you can configure the
start mode and other options. The Tinkerforge Bindings are available,
you can use require('tinkerforge')
to import them.
.
.For Octave the Java path to the Tinkerforge.jar
is already added
in the .octaverc
file. This means that in your program you can assume
that javaaddpath("Tinkerforge.jar")
was already called with
the correct directory.
.
.The Tinkerforge Bindings are available. You can use the use
directive to import them, e.g.: use Tinkerforge::IPConnection;
.
.
.The Tinkerforge Bindings are installed through PEAR
and thus available. You can import them with the require_once
function, e.g.: require_once('Tinkerforge/IPConnection.php');
.
.
.The Tinkerforge Bindings are installed through
pip and thus
available. You can import them with the normal import
statement, e.g.: from tinkerforge.ip_connection import IPConnection
.
.
.The Tinkerforge Bindings are installed through gem
and thus available. You can use the require
statement to import them,
e.g.: require 'tinkerforge/ip_connection'
.
.
.The Shell Bindings are available in /usr/local/bin
, which is
in the PATH. In your shell script you can just call tinkerforge
without any prefix.
.
.For Visual Basic .NET the Tinkerforge.dll
is available in /usr/lib/
and can thus be found by mono. That means, if you compile your VB.NET
program and you use the Tinkerforge.dll
as reference, it will be
automatically found on the RED Brick. You don't have to add
the Tinkerforge.dll
in step 2.
Mono Version: Currently there is only one mono version installed.
Start Mode: Currently only Executable is available as start mode.
Executable: Choose the .NET executable from the files that you added
in step 2. A .NET executable usually has the file ending .exe
.
Your executable will be executed with mono, but you can compile on Windows with Visual Studio, that works without problem. Make sure that you don't use any Windows specific libraries that are not available on the RED Brick.
Working Directory: Specify the
working directory
of your program. You can use a path that is relative to the
root directory of your program. Usually you will leave this as .
.
Mono Options: Here you can add options that will be given to the mono JIT compiler.
Arguments: Your program will be called with the given arguments.
Please note that you don't have to escape your arguments. If you would call your program on the terminal with:
./my_program --setting value1 value2
You have to add the three arguments --settings, value1 and value2 individually to the argument list.
If you only add the one argument --settings value1 value2 it will be equivalent to the following call in the terminal:
./my_program --settings\ value1\ value2
Environment: Your program will have the environment variables that you set here available. Environment variables that are necessary to start a program in the chosen programming language will already be there by default.
If your program has a GUI then you need to add the environment variable DISPLAY with a value of :0, otherwise your program cannot show a window on the desktop.
If you don't know what this means you very likely don't have to touch this setting.
In many cases the default values can just leaved as they are. If you don't know what the standard input and output is you can likely just click Next.
Mode Never: The scheduler of the RED Brick will not be used. You can start your program manually in the program tab of the Brick Viewer.
Mode Always: The scheduler will try to always keep your program running. If your program ends it will be restarted immediately. If you have a controlling program that uses some input to control some output that should just always do its thing, this mode is the right one for you.
Mode Interval: Define an interval (in seconds) in which your program should be executed.
Mode Cron: Use cron to schedule your program. Cron is a time-based job scheduler. You can specify things like
00 20 * * *
00 09-18 * * 1-5
* 12 16 * Mon
As you can see, you can specify quite complex tasks with cron. There is a big number of cron tutorials available on the Internet.
Please note that your RED Brick needs to have the current time available for cron to work. The RED Brick is not equipped with a clock, which is also active when the RED Brick is powered down. Such that the time is lost after power down. The time will be automatically set if your RED Brick is connected to the Internet (through NTP). You can set it in the Date/Time section of the settings tab and you can use the GPS Bricklet to sync the Linux system time with the GPS time.
Mode Once After Upload: The scheduler will execute the program only once directly after it is uploaded.
Continue After Error: If this checkbox is unchecked, the scheduler will stop after your program exits with an error. If it is checked errors are ignored.
The summary page shows a summary of the previous made configuration. If you want to ask for help regarding the configuration of a program it probably makes sense to append the content of this summary to your inquiry.
In the last step you can press Start Upload to start the upload of your program files and configuration. Your program will either start directly after upload or later, depending on the scheduling configurations in step 6.