Subsections
Once a new module has been written, or if something new should be
tried, a new testing-module should be written. A testing-module usually
consists of a simple chain with some output that tells the user whether
the test has succeeded or not. It is the first step towards writing
a Radio and using a new or modified module in real-time.
Files
If you want to start a new test, create a new directory under Test/
and add the name to the line
-
- DIRS = FirstChain Memory ...
of the file Test/Makefile. Like this your test will be automatically
built when using make whole. Next cd in your new directory
and copy some files:
-
- cp ../../Conventions/test_template.c \
../../Conventions/Makefile.module .
The test_template.c should be renamed to something fitting
the pattern test_*.c, and this name should be appended to
the line
-
- MODULE_NAME =
of the Makefile (which has been renamed from Makefile.module).
Now you are ready to modify your test_*.c file and test
it out, using
-
- make
make user
You can also have a look into different files that you find in the
directory Testing/* to see different techniques on how to
do strange things.
Main
The main-part of the module is in the function start_it. It
is called once when the module is loaded. For a small testing-module
you want to make perhaps only a small chain, something like
-
- swr_chain_create( NEW_SPC_VAR( ''random'', rnd ),
NEW_SPC( ''modulator'' ),
NEW_SPC( ''demodulator'' ),
NEW_SPC_VAR( ''sink'', sink ),
CHAIN_END );
This leads to an empty chain, because all modules (with the exception
of the STFA and the block module) have an input- and
output-size of 0. So we need to set one module to a given size:
-
- swr_sdb_set_config_int( sink, ''size'', 128 );
And while we're at it, we can tell the sink module, that it
should count the occurences of the different values:
-
- swr_sdb_set_config_int( sink, ''flag'', 2 );
For further explanation, you can turn to the explanation of the sink
module.
Now that the chain has been created and configured, it still needs
to be activated at least once, so that something happens:
-
- swr_sdb_seng_msg( rnd, SUBS_MSG_USER, NULL, -1 );
Which sends a user-defined message to the random module. It
will now traverse the whole chain and the sink module will
output the occurances of the different values. To compile and start
it, type the following commands:
-
- make
make user
As the size of the sink-input is only 128, this will not be very representativ
for the random-number generator. You may increase the size of the
sink-input to something like 65536 or even more, to see how the random-number
generator works.
Linus Gasser
2004-04-14