Commit Graph

106 Commits

Author SHA1 Message Date
wbokslag 2fc625677c added support for fill bits and basic link defragmentation (also thanks to SQ5BPF)
The upper mac now maintains a defragmentation buffer for each timeslot. Resources with length -1 (fragmentation start) are added to the buf for that slot, further mac/frag frames are appended. When a mac/end is encountered, the reconstructed l2 message is passed to rx_tm_sdu. The tetra_llc_pdu struct now uses a uint32_t for tl_sdu_len in order to account for the possibly longer sdus. Fill bits processing was required in order to reliably determine the end of a MAC PDU.

Change-Id: I41c9438b0b12c2fac9dff1b226eec5b33f30fbb4
2022-09-22 11:27:29 +02:00
wbokslag 1b7ebde55d Keep timeslot number in range 1-4 instead of 0-3 in parsing of SYNC frame
According to the tetra_tdma_time struct definition, the tn should be in range 1-4. Also, tetra_burst_sync_in increments the timeslot number when in a synchronized state. The timeslot is then normalized with normalize_tn which also expects the tn to be within the 1-4 range.

Change-Id: Ib0967fdeef3bf37c612124626a74d240aa571a66
2022-09-18 15:16:51 +02:00
wbokslag 16713cab01 when traffic dump directory is specified, now prints error message and exits instead of crashing when traffic file cannot be written
Change-Id: I273e07aefd9faea13662f6699a6f3b074c8efe88
2022-08-09 17:28:31 +02:00
sq5bpf f258b1d7d7 Added basic AFC as implemented by SQ5BPF into float_to_bits.c
The AFC implementation by SQ5BPF as used in his fork of osmo-tetra significantly increases reception quality. A simple test yields 14545 valid CRCs as opposed to 11934 when AFC is not used.
I added the AFC to float_to_bits, the functionality can be activated with the -a flag.

Change-Id: I1c9343b83739108a1e423c4880e1dc7964656529
2022-08-04 09:32:06 +02:00
wbokslag d5bfc8e74a keep track of which block of a downlink burst is being processed
tp_sap_udata_ind now accepts a parameter designating from which block
(first or second) of the downlink burst the bits originate (not
applicable for all downlink burst types). In some cases, the upper mac
needs this information, see ETSI EN 300 392-7 clause 6.4.1

Change-Id: I5ff316a773906328e19c3530b09d7412f9c731ec
2022-08-02 13:22:30 +02:00
wbokslag 3fba49ead4 Added basic link FCS validation in LLC
tetra_llc_pdu.c now parses the FCS (Frame Check Sequence) for basic link pdus
that use it. Some changes were made to the tetra_resrc_decoded struct
definition. The have_fcs field designates the FCS was present, while the FCS
field holds the extracted FCS, and FCS_invalid designates an FCS was present
but differs from the computed value.

Change-Id: I81941110801d00ca06bdafdcc0a7afaf7b7617d3
2022-08-02 12:49:39 +02:00
wbokslag a5bc24792b Improved parsing in macpdu_decode_resource
fill_bits and grant_position bits are now parsed and stored in the tetra_resrc_decoded struct
A flag is_encrypted is set to to true if resource was not encrypted or if the calling function
states that the frame has been decrypted successfully before passing it to tetra_resrc_decoded.
Lastly, the channel_alloc element is only parsed if the frame is unencrypted.

Change-Id: I6c85c93b70a34e01fd1a96a863f0e113be6424d3
2022-08-02 12:32:55 +02:00
wbokslag 6dfb41681c moved variable declaration to prevent compiler warnings
Change-Id: If9a83589b220ae7d937ef75c79de57be11858cd1
2022-07-29 12:42:10 +02:00
wbokslag 1feba505bb fixed out of bounds write to pdu_sync buffer
Change-Id: I414bf2d61dc1cb37d30dc84b401a75b918116bbb
2022-07-29 12:42:06 +02:00
wbokslag f0c5f795af added missing switch statements to suppress compiler warnings
Change-Id: I02f7b1875e5501f6977638130c8c5b8c8634fe4e
2022-07-11 15:10:59 +02:00
wbokslag 22b190ef5f Added missing return value
Change-Id: I53d0e75c14933fae30257f8a4cc76df0f3bcd642
2022-07-11 14:40:10 +02:00
wbokslag 627959b4ba added brackets; fprintf was erroneously not guarded by if statement
Change-Id: I2e8c365ee261bde998a69f0f3531dfe6f3ec49c7
2022-07-11 14:29:43 +02:00
wbokslag 8ab1283296 Created tuntap.h to allow for proper use of tun_alloc in tetra_llc.c
Change-Id: If920c15e4dafb48d5df70ce20532ecb19bd01ee3
2022-07-11 14:26:51 +02:00
wbokslag bdc9b28693 ensure zero termination of tun device name
Change-Id: I4b783c6b98ddfb30a4ca4532ef8cffa8e5f3a12f
2022-07-11 14:22:27 +02:00
Harald Welte b94f26929f fix memory leak in tetra_gsmtap_sendmsg()
gsmtap_sendmsg() may return an error, and we need to free the msg.

Likewise, if we don't even call gsmtap_sendmsg, the msgb must be free'd.

Change-Id: I9b018165982996cafb2fd17e89646177462002c6
Depends: libosmocore I106b09f2a49bf24ce0e8d11fd4d4ee93e9cafdf5
Related: OS#5329
2021-11-25 15:58:29 +01:00
Martin Hauke d71027873e Fix typos
Change-Id: I1aae0a52fcf978900fa847a3f813beb2a5ad4a84
2019-07-17 22:50:49 +02:00
Jan Hrach 73e9e0e871 add traffic dumping patch, use getopt to parse arguments
Enable the user to specify a directory, where contents of traffic channel will
be saved. Together with this dump, a text file with SSIs of the engaged
stations is saved too.

Based on 0004-HACK-Quick-hack-to-save-the-speech-data-from-TCH.patch available at
https://build.opensuse.org/package/view_file/home:mnhauke:sdr/osmo-tetra/0004-HACK-Quick-hack-to-save-the-speech-data-from-TCH.patch

Change-Id: I94135753a76cadfa373167ffca18e89bee5bcff8
2018-09-28 23:27:20 +00:00
Jan Hrach 22bb16dfa4 phy/tetra_burst.c: use bitwise operations to speed up synchronization
Finding synchronization sequence eats several times more CPU time than the
actual decoding. This is especially pronounced on channels with lots of errors
(where synchronization is lost frequently) and channels that are most of the
time empty (such as uplink channels, support for which is coming in following
patches).

Profiling shows that all the time is spent in memcmp calls.

A complicated and efficient algorithm, e.g. Aho-Corasick, turned out to be
not necessary. Compilers can optimize even a simple bit filter into fast code.

This provides only a modest (~25 %) performance gain, more fixes are coming.

Fixes: OS#1897
Change-Id: I3b90cc70c2ec67253a0fd2f00c6957a80971c38b
2018-08-06 12:21:19 +00:00
Jan Hrach 013ef6e8a1 update scrambling only if we have good CRC
When a bad frame is received, the scrambling should not be updated,
because setting scrambling to wrong values will completely break further
decoding (until another SYNC frame is received).

Change-Id: I5e88b52fcbb98532d7ab6ca85e4f956589a595ab
2018-07-31 06:58:51 +00:00
Jenda 05fa2d54bb Makefile: -O3 and debug build
Build standard builds with -O3.
Add a "debug" target with -Og and asan.

Change-Id: Ie943babb808ffdb1d807bcd7ce4ace54723b49a9
2018-07-30 21:41:08 +02:00
Jenda 9514389ef5 add script for testing performance and number of correctly decoded frames
Change-Id: I6d8030969eed4519520745207591ce4731939201
2018-07-30 21:38:07 +02:00
Jan Hrach 2c19f9856a Make viterbi decoder deterministic in case of bit errors / too few symbols
Running tetra-rx on a capture with lots of bit errors is not
deterministic. Investigation with Valgrind shows various errors about
uninitialised values in libosmocore's viterbi decoder.

The cause appears to lie in @lower_mac/viterbi.c@. The only function
there allocates space for 864 symbols and then fills it with the symbols
received. However, sym_count is sometimes less than 864, leaving the
rest of the array uninitialized.

Initializing it with @int8_t vit_inp[864*4] = {0};@ fixes the problem.

Change-Id: Ib745c387e21fb81afef69efcf7e46d5d49331c8f
Fixes: OS#3410
2018-07-21 10:29:20 +02:00
Harald Welte 0ca867eda2 remove old gnuradio <= 3.6 demodulator code
keeps some of the device specific scripts in addition to the (supposedly
generic) osmosdr-tetra_demod_fft.py

Also, update the README file to corresponding changes.

Change-Id: Icae93bb9a6a7219e14931fb6e04a4c6fffa0779d
2016-12-18 17:10:10 +01:00
Harald Welte 409d2985cb demod: Import the new GR 3.7 code
This adds demodulator code compatible with gnuradio 3.7 series.

Change-Id: Ibaf7f9c552cc1625210a75f2e9ec142ab47ce8d6
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2016-12-18 17:06:32 +01:00
sq5bpf 871782e445 Add simdemod2.py, a simple demodulator without GUI
Change-Id: Ibad17350db1b00f87955684e4cc17e0a5e8ea6de
2016-12-18 15:37:33 +01:00
Dieter Spaar 158270f489 normalize_fn(): Fix computation of frame numbers
A copy+paste mistake resulted in the calculation of wrong frame numbers
in normalize_fn().
2016-11-27 17:50:08 +01:00
Petr Baudis a562b0e9a2 Merged useful extra features
osmosdr-tetra_demod_fft.py: Commandline switch -F for frequency offset
osmosdr-tetra_demod_fft.py: More verbose fine-tuning messages

Conflicts:
	src/demod/python/osmosdr-tetra_demod_fft.py
2015-08-21 01:52:40 +02:00
Petr Baudis 7d6f7287d7 osmosdr-tetra_demod_fft.py: More verbose fine-tuning messages 2015-08-21 01:52:27 +02:00
Jiří Pinkava 89f01f3501 fix debug build 2015-08-21 01:49:46 +02:00
Jiří Pinkava c065f9214c speed up float_to_bits
Reduce overhead caused by inefficient call of read
for each float. Increases speed about 50x.
2015-08-21 01:49:38 +02:00
luckyhacky 6f78d76052 removed hard coded values - exchanged it with enum for better readability 2015-08-21 01:49:02 +02:00
luckyhacky 83140af8d0 extended sysinfo as described in section 21.4.4.1
now every transmitted field in sysinfo is analyzed
2015-08-21 01:48:46 +02:00
luckyhacky 732d06d531 align for better readability 2015-08-21 01:48:30 +02:00
luckyhacky 165bf705a2 fixed typo 2015-08-21 01:47:00 +02:00
luckyhacky 6dcdb89454 set hyperframe number in struct tdma_time 2015-08-21 01:46:50 +02:00
luckyhacky 59e06e22ee added basic hyperframe support for output 2015-08-21 01:46:40 +02:00
Frank A. Stevenson 6430bdeb5f fix some global ugliness
This removes a static global variable which will only work if you only
have once instance of the tetra receiver.
2012-12-01 14:48:52 +01:00
Dimitri Stolnikov 1594e170bc fix first decimation value for FCD devices
thanks to Stefan Mandl for bringing up this issue.
2012-11-11 14:11:53 +01:00
Sylvain Munaut 2ee4b4ad4d float_to_bits: Remove offset
This is a symptom of frequency offset and it's the demodulator job to
correct this ...

Thanks to Frank A. Stevenson for noticing this legacy hack

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2012-11-11 12:48:33 +01:00
Gregor Gregoric 095e7bd8aa Add missing if braces in decode_chan_alloc 2012-10-04 18:31:51 +02:00
Ronny Kunze 2d9bf16066 Use correct bit offset to decode the ADDR_TYPE_SSI_USAGE 2012-07-14 13:02:07 +02:00
Dimitri Stolnikov 7bb6e34ad0 move graphical sinks to tabbed control 2012-06-07 21:39:09 +02:00
Dimitri Stolnikov 246b3d37e1 rename rtlsdr-tetra_demod_fft.py to osmosdr-tetra_demod_fft.py 2012-06-07 15:24:52 +02:00
Dimitri Stolnikov 74d40768ed add --args command line argument to pass to gr-osmosdr source 2012-06-07 15:22:37 +02:00
Steve Markgraf e55c014d9c rtlsdr-tetra: remove unneeded import
Signed-off-by: Steve Markgraf <steve@steve-m.de>
2012-06-07 15:06:20 +02:00
Dimitri Stolnikov 582acdf444 add frequency and gain controls to rtlsdr receiver 2012-06-07 14:29:26 +02:00
Dimitri Stolnikov 2037ebeac6 add rtlsdr based receiver with click & tune functionality
Call it with

 src$ ./demod/python/rtlsdr-tetra_demod_fft.py -s 1.8e6 -f 394.6e6 -g -1 -o /dev/stdout | ./float_to_bits /dev/stdin /dev/stdout | ./tetra-rx /dev/stdin

- Adjust the center frequency (-f) and gain (-g) according to your needs.
- Use left click in Full Spectrum window to roughly select a TETRA carrier.
- Use left click to fine tune the carrier by clicking on the left or right side of the spectrum.
2012-05-31 01:36:22 +02:00
Dimitri Stolnikov 617dacf7b9 demod: use current uhd arguments scheme in uhd-tetra_demod.py
also introduces --spec argument useful with usrp1
2011-12-27 12:14:03 +01:00
Dimitri Stolnikov 7226098a9c add tunctl to .gitignore 2011-12-27 12:09:53 +01:00
Sylvain Munaut d4948d3c29 gsmtap: Fix warnings
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-25 20:29:06 +01:00