kopia lustrzana https://github.com/M17-Project/M17_Implementations
Porównaj commity
11 Commity
f11eb14ba9
...
d582dbd14a
Autor | SHA1 | Data |
---|---|---|
Wojciech Kaczmarski | d582dbd14a | |
Wojciech Kaczmarski | 81060d11fc | |
Wojciech Kaczmarski | c7bad8d71e | |
Wojciech Kaczmarski | 870aa36387 | |
Wojciech Kaczmarski | 72f01c6321 | |
Wojciech Kaczmarski | 663fab8e9d | |
Wojciech Kaczmarski | 4d005a7a73 | |
redpfire | febbaf8d06 | |
redpfire | 78d2243f6b | |
redpfire | dabcd135cd | |
redpfire | b4a5a23ae9 |
19
README.md
19
README.md
|
@ -3,23 +3,25 @@ Various implementations
|
|||
|
||||
## Woj's implementation (/SP5WWP)
|
||||
### Overview
|
||||
Written in C, it has all the components described by the protocol's specification of the stream mode:
|
||||
Written in C, it has all the components described by the protocol's specification of the stream and packet modes:
|
||||
- convolutional encoder with soft Viterbi decoder (utilizing fixed point arithmetic),
|
||||
- Golay encoder with soft decoder (fixed point),
|
||||
- bit interleaver and randomizer,
|
||||
- cyclic redundancy check (CRC) validation,
|
||||
- callsign decoder
|
||||
|
||||
It also supports packet mode (TX only for now).
|
||||
- cyclic redundancy check (CRC) calculation (both LSF and arbitrary input),
|
||||
- callsign encoder and decoder
|
||||
|
||||
There's no support for **any** encryption yet.
|
||||
|
||||
### Building
|
||||
Simply `cd` to the directory of interest and
|
||||
```make```
|
||||
First, build the shared object `libm17.so`:
|
||||
```
|
||||
cd M17_Implementations/SP5WWP/lib
|
||||
make
|
||||
```
|
||||
Then, `cd` to the directory of interest and ```make``` again.
|
||||
|
||||
### Capabilities
|
||||
Two executables are available:
|
||||
Four executables are available:
|
||||
- `m17-coder-sym` is used to convert a raw binary data bitstream to symbols. Symbol stream has to be
|
||||
filtered with an appropriate filter before transmission, see the specification document for details.
|
||||
- `m17-decoder-sym` decodes a stream of floats at `stdin`, one sample per symbol. After a valid
|
||||
|
@ -28,6 +30,7 @@ at the input. See the `/grc/symbol_recovery.grc` file for details.
|
|||
- `m17-packet-encode` is a handy tool for generating baseband (or a symbol stream, if needed) for
|
||||
M17 packets. The program expects a limited stream of raw data at the stdin. The number of bytes is set
|
||||
with the `-n` parameter, range 1 to 800.
|
||||
- `m17-packet-decode` decodes incoming packets.
|
||||
|
||||
### Testing
|
||||
#### Stream mode
|
||||
|
|
|
@ -5,7 +5,7 @@ options:
|
|||
category: '[GRC Hier Blocks]'
|
||||
cmake_opt: ''
|
||||
comment: ''
|
||||
copyright: M17 Project, Dec 2022
|
||||
copyright: M17 Project, Jan 2024
|
||||
description: ''
|
||||
gen_cmake: 'On'
|
||||
gen_linking: dynamic
|
||||
|
@ -33,6 +33,30 @@ options:
|
|||
state: enabled
|
||||
|
||||
blocks:
|
||||
- name: decim
|
||||
id: variable
|
||||
parameters:
|
||||
comment: ''
|
||||
value: '40'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [360, 12.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: sps
|
||||
id: variable
|
||||
parameters:
|
||||
comment: ''
|
||||
value: '10'
|
||||
states:
|
||||
bus_sink: false
|
||||
bus_source: false
|
||||
bus_structure: null
|
||||
coordinate: [288, 12.0]
|
||||
rotation: 0
|
||||
state: enabled
|
||||
- name: symbol_rate
|
||||
id: variable
|
||||
parameters:
|
||||
|
@ -51,7 +75,7 @@ blocks:
|
|||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
gain: 24000/(2*math.pi*800)
|
||||
gain: (symbol_rate*sps)/(2*math.pi*800)
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
states:
|
||||
|
@ -188,15 +212,15 @@ blocks:
|
|||
comment: ''
|
||||
constellation: digital.constellation_bpsk().base()
|
||||
damping: '1.0'
|
||||
loop_bw: '0.05'
|
||||
max_dev: '1.5'
|
||||
loop_bw: 2.0*math.pi*0.0015
|
||||
max_dev: '0.05'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
nfilters: '128'
|
||||
osps: '1'
|
||||
pfb_mf_taps: '[]'
|
||||
resamp_type: digital.IR_MMSE_8TAP
|
||||
sps: '5'
|
||||
sps: sps
|
||||
ted_gain: '1.0'
|
||||
ted_type: digital.TED_GARDNER
|
||||
type: ff
|
||||
|
@ -406,7 +430,7 @@ blocks:
|
|||
affinity: ''
|
||||
alias: ''
|
||||
comment: ''
|
||||
decim: '80'
|
||||
decim: decim
|
||||
fbw: '0'
|
||||
interp: '1'
|
||||
maxoutbuf: '0'
|
||||
|
@ -432,8 +456,8 @@ blocks:
|
|||
interp: '1'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
ntaps: 8*5+1
|
||||
samp_rate: '5'
|
||||
ntaps: 8*sps+1
|
||||
samp_rate: sps
|
||||
sym_rate: '1'
|
||||
type: fir_filter_fff
|
||||
states:
|
||||
|
@ -472,6 +496,7 @@ blocks:
|
|||
affinity: ''
|
||||
agc: 'True'
|
||||
alias: ''
|
||||
bias: 'False'
|
||||
center_freq: '439950000'
|
||||
comment: ''
|
||||
dev_args: ''
|
||||
|
@ -479,7 +504,7 @@ blocks:
|
|||
gain: '20'
|
||||
maxoutbuf: '0'
|
||||
minoutbuf: '0'
|
||||
samp_rate: 24000*80
|
||||
samp_rate: symbol_rate*sps*decim
|
||||
type: fc32
|
||||
states:
|
||||
bus_sink: false
|
||||
|
@ -508,4 +533,4 @@ connections:
|
|||
|
||||
metadata:
|
||||
file_format: 1
|
||||
grc_version: 3.10.4.0
|
||||
grc_version: 3.10.7.0
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
*.o
|
||||
*.so
|
||||
*.a
|
|
@ -0,0 +1,21 @@
|
|||
INC = -I .
|
||||
|
||||
TARGET = libm17.so
|
||||
|
||||
CFLAGS = $(INC) -fPIC -Wall
|
||||
LDFLAGS = -shared -lm
|
||||
SRCS = $(wildcard *.c) $(wildcard */*.c)
|
||||
OBJS = $(SRCS:.c=.o)
|
||||
|
||||
all: $(TARGET) clean
|
||||
|
||||
clean:
|
||||
rm -f $(OBJS)
|
||||
|
||||
fclean:
|
||||
rm -f $(TARGET)
|
||||
|
||||
$(TARGET): $(OBJS)
|
||||
$(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)
|
||||
|
||||
.PHONY: all clean fclean
|
|
@ -0,0 +1,5 @@
|
|||
# libm17
|
||||
|
||||
### Compiling
|
||||
|
||||
To compile simply run `make`. This will generate a shared library `libm17.so`.
|
|
@ -0,0 +1,16 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - decode/symbols.c
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include "symbols.h"
|
||||
|
||||
// syncword patterns (RX)
|
||||
// TODO: Compute those at runtime from the consts below
|
||||
const int8_t lsf_sync_symbols[8]={+3, +3, +3, +3, -3, -3, +3, -3};
|
||||
const int8_t str_sync_symbols[8]={-3, -3, -3, -3, +3, +3, -3, +3};
|
||||
const int8_t pkt_sync_symbols[8]={+3, -3, +3, +3, -3, -3, -3, -3};
|
||||
|
||||
// symbol levels (RX)
|
||||
const float symbol_levels[4]={-3.0, -1.0, +1.0, +3.0};
|
|
@ -0,0 +1,25 @@
|
|||
//-------------------------------
|
||||
// M17 C library - decode/symbols.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
// syncword patterns (RX)
|
||||
// TODO: Compute those at runtime from the consts below
|
||||
extern const int8_t lsf_sync_symbols[8];
|
||||
extern const int8_t str_sync_symbols[8];
|
||||
extern const int8_t pkt_sync_symbols[8];
|
||||
|
||||
// symbol levels (RX)
|
||||
extern const float symbol_levels[4];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,17 +1,17 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17viterbi.c
|
||||
// M17 C library - decode/viterbi.c
|
||||
//
|
||||
// This file contains:
|
||||
// - all the Viterbi decoder stuff
|
||||
// - the Viterbi decoder
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "m17consts.h"
|
||||
#include "m17math.h"
|
||||
#include "m17viterbi.h"
|
||||
|
||||
#include <math/math.h>
|
||||
#include "viterbi.h"
|
||||
|
||||
static uint32_t prevMetrics[NUM_STATES];
|
||||
static uint32_t currMetrics[NUM_STATES];
|
||||
|
@ -200,4 +200,4 @@ void viterbi_reset(void)
|
|||
memset((uint8_t*)prevMetrics, 0, 4*NUM_STATES);
|
||||
memset((uint8_t*)currMetricsData, 0, 4*NUM_STATES);
|
||||
memset((uint8_t*)prevMetricsData, 0, 4*NUM_STATES);
|
||||
}
|
||||
}
|
|
@ -1,21 +1,19 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17viterbi.h
|
||||
// M17 C library - decode/viterbi.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#ifndef M17_VITERBI_LIB
|
||||
#define M17_VITERBI_LIB
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//vars
|
||||
;
|
||||
#define K 5 //constraint length
|
||||
#define NUM_STATES (1 << (K - 1)) //number of states
|
||||
|
||||
//functions
|
||||
uint32_t viterbi_decode(uint8_t* out, const uint16_t* in, const uint16_t len);
|
||||
uint32_t viterbi_decode_punctured(uint8_t* out, const uint16_t* in, const uint8_t* punct, const uint16_t in_len, const uint16_t p_len);
|
||||
void viterbi_decode_bit(uint16_t s0, uint16_t s1, size_t pos);
|
||||
|
@ -25,4 +23,3 @@ void viterbi_reset(void);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17convol.c
|
||||
// M17 C library - encode/convol.c
|
||||
//
|
||||
// This file contains:
|
||||
// - convolutional encoders for the LSF, stream, and packet frames
|
||||
|
@ -8,18 +8,28 @@
|
|||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include "m17convol.h"
|
||||
#include "convol.h"
|
||||
|
||||
const uint8_t puncture_pattern_1[61] = {
|
||||
1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,
|
||||
1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,
|
||||
1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,
|
||||
1,0,1,1,1,0,1,1,1,0,1,1
|
||||
};
|
||||
|
||||
const uint8_t puncture_pattern_2[12]={1,1,1,1,1,1,1,1,1,1,1,0};
|
||||
const uint8_t puncture_pattern_3[8]={1,1,1,1,1,1,1,0};
|
||||
|
||||
/**
|
||||
* @brief Encode M17 stream frame using convolutional encoder with puncturing.
|
||||
*
|
||||
*
|
||||
* @param out Output array, unpacked.
|
||||
* @param in Input - packed array of uint8_t, 144 type-1 bits.
|
||||
* @param fn Input - 16-bit frame number.
|
||||
*/
|
||||
void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn)
|
||||
{
|
||||
uint8_t pp_len = sizeof(P_2);
|
||||
uint8_t pp_len = sizeof(puncture_pattern_2);
|
||||
uint8_t p=0; //puncturing pattern index
|
||||
uint16_t pb=0; //pushed punctured bits
|
||||
uint8_t ud[144+4+4]; //unpacked data
|
||||
|
@ -49,7 +59,7 @@ void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn
|
|||
|
||||
//printf("%d%d", G1, G2);
|
||||
|
||||
if(P_2[p])
|
||||
if(puncture_pattern_2[p])
|
||||
{
|
||||
out[pb]=G1;
|
||||
pb++;
|
||||
|
@ -58,7 +68,7 @@ void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn
|
|||
p++;
|
||||
p%=pp_len;
|
||||
|
||||
if(P_2[p])
|
||||
if(puncture_pattern_2[p])
|
||||
{
|
||||
out[pb]=G2;
|
||||
pb++;
|
||||
|
@ -73,13 +83,13 @@ void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn
|
|||
|
||||
/**
|
||||
* @brief Encode M17 packet frame using convolutional encoder with puncturing.
|
||||
*
|
||||
*
|
||||
* @param out Output array, unpacked.
|
||||
* @param in Input - packed array of uint8_t, 206 type-1 bits.
|
||||
*/
|
||||
void conv_encode_packet_frame(uint8_t* out, const uint8_t* in)
|
||||
{
|
||||
uint8_t pp_len = sizeof(P_3);
|
||||
uint8_t pp_len = sizeof(puncture_pattern_3);
|
||||
uint8_t p=0; //puncturing pattern index
|
||||
uint16_t pb=0; //pushed punctured bits
|
||||
uint8_t ud[206+4+4]; //unpacked data
|
||||
|
@ -104,7 +114,7 @@ void conv_encode_packet_frame(uint8_t* out, const uint8_t* in)
|
|||
|
||||
//fprintf(stderr, "%d%d", G1, G2);
|
||||
|
||||
if(P_3[p])
|
||||
if(puncture_pattern_3[p])
|
||||
{
|
||||
out[pb]=G1;
|
||||
pb++;
|
||||
|
@ -113,7 +123,7 @@ void conv_encode_packet_frame(uint8_t* out, const uint8_t* in)
|
|||
p++;
|
||||
p%=pp_len;
|
||||
|
||||
if(P_3[p])
|
||||
if(puncture_pattern_3[p])
|
||||
{
|
||||
out[pb]=G2;
|
||||
pb++;
|
||||
|
@ -128,13 +138,13 @@ void conv_encode_packet_frame(uint8_t* out, const uint8_t* in)
|
|||
|
||||
/**
|
||||
* @brief Encode M17 stream frame using convolutional encoder with puncturing.
|
||||
*
|
||||
*
|
||||
* @param out Output array, unpacked.
|
||||
* @param in Input - pointer to a struct holding the Link Setup Frame.
|
||||
*/
|
||||
void conv_encode_LSF(uint8_t* out, const struct LSF *in)
|
||||
{
|
||||
uint8_t pp_len = sizeof(P_1);
|
||||
uint8_t pp_len = sizeof(puncture_pattern_1);
|
||||
uint8_t p=0; //puncturing pattern index
|
||||
uint16_t pb=0; //pushed punctured bits
|
||||
uint8_t ud[240+4+4]; //unpacked data
|
||||
|
@ -204,7 +214,7 @@ void conv_encode_LSF(uint8_t* out, const struct LSF *in)
|
|||
|
||||
//printf("%d%d", G1, G2);
|
||||
|
||||
if(P_1[p])
|
||||
if(puncture_pattern_1[p])
|
||||
{
|
||||
out[pb]=G1;
|
||||
pb++;
|
||||
|
@ -213,7 +223,7 @@ void conv_encode_LSF(uint8_t* out, const struct LSF *in)
|
|||
p++;
|
||||
p%=pp_len;
|
||||
|
||||
if(P_1[p])
|
||||
if(puncture_pattern_1[p])
|
||||
{
|
||||
out[pb]=G2;
|
||||
pb++;
|
|
@ -1,22 +1,21 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17convol.h
|
||||
// M17 C library - encode/convol.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#ifndef M17_CONVOL_LIB
|
||||
#define M17_CONVOL_LIB
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include "m17consts.h"
|
||||
#include <payload/lsf.h>
|
||||
|
||||
//vars
|
||||
;
|
||||
extern const uint8_t puncture_pattern_1[61];
|
||||
extern const uint8_t puncture_pattern_2[12];
|
||||
extern const uint8_t puncture_pattern_3[8];
|
||||
|
||||
//functions
|
||||
void conv_encode_stream_frame(uint8_t* out, const uint8_t* in, const uint16_t fn);
|
||||
void conv_encode_packet_frame(uint8_t* out, const uint8_t* in);
|
||||
void conv_encode_LSF(uint8_t* out, const struct LSF *in);
|
||||
|
@ -24,4 +23,3 @@ void conv_encode_LSF(uint8_t* out, const struct LSF *in);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,10 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - encode/symbols.c
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include "symbols.h"
|
||||
|
||||
// dibits-symbols map (TX)
|
||||
const int8_t symbol_map[4]={+1, +3, -1, -3};
|
|
@ -1,24 +1,19 @@
|
|||
//-------------------------------
|
||||
// M17 C library - m17lib.h
|
||||
// M17 C library - encode/symbols.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#ifndef M17_LIB
|
||||
#define M17_LIB
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//functions
|
||||
void send_preamble(const uint8_t type);
|
||||
void send_syncword(const uint16_t syncword);
|
||||
void send_data(const uint8_t* in);
|
||||
void send_eot(void);
|
||||
// dibits-symbols map (TX)
|
||||
extern const int8_t symbol_map[4];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,12 +1,12 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17lib.c
|
||||
// M17 C library - lib.c
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include "m17consts.h"
|
||||
#include "m17lib.h"
|
||||
#include <encode/symbols.h>
|
||||
#include "lib.h"
|
||||
|
||||
//misc
|
||||
void send_preamble(const uint8_t type)
|
|
@ -0,0 +1,32 @@
|
|||
//-------------------------------
|
||||
// M17 C library - lib.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
#define BSB_SPS 10 //samples per symbol
|
||||
#define FLT_SPAN 8 //baseband RRC filter span in symbols
|
||||
#define SYM_PER_SWD 8 //symbols per syncword
|
||||
#define SW_LEN (BSB_SPS*SYM_PER_SWD) //syncword detector length
|
||||
#define SYM_PER_PLD 184 //symbols per payload in a frame
|
||||
#define SYM_PER_FRA 192 //symbols per whole 40 ms frame
|
||||
#define RRC_DEV 7168.0f //.rrc file deviation for +1.0 symbol
|
||||
|
||||
//L2 metric threshold
|
||||
#define DIST_THRESH 2.0f //threshold for distance (syncword detection)
|
||||
|
||||
void send_preamble(const uint8_t type);
|
||||
void send_syncword(const uint16_t syncword);
|
||||
void send_data(const uint8_t* in);
|
||||
void send_eot(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,135 +0,0 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17consts.c
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include "m17consts.h"
|
||||
|
||||
//syncword patterns (RX) TODO:Compute those at runtime from the consts below
|
||||
const int8_t lsf_sync[8]={+3, +3, +3, +3, -3, -3, +3, -3};
|
||||
const int8_t str_sync[8]={-3, -3, -3, -3, +3, +3, -3, +3};
|
||||
const int8_t pkt_sync[8]={+3, -3, +3, +3, -3, -3, -3, -3};
|
||||
|
||||
//symbol levels (RX)
|
||||
const float symbs[4]={-3.0, -1.0, +1.0, +3.0};
|
||||
|
||||
//dibits-symbols map (TX)
|
||||
const int8_t symbol_map[4]={+1, +3, -1, -3};
|
||||
|
||||
//syncwords
|
||||
const uint16_t SYNC_LSF = 0x55F7;
|
||||
const uint16_t SYNC_STR = 0xFF5D;
|
||||
const uint16_t SYNC_PKT = 0x75FF;
|
||||
const uint16_t SYNC_BER = 0xDF55;
|
||||
const uint16_t EOT_MRKR = 0x555D;
|
||||
|
||||
//puncturing pattern P_1
|
||||
const uint8_t P_1[61]={1,1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,
|
||||
1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,
|
||||
1,0,1,1,1,0,1,1,1,0,1,1,1,0,1,1,
|
||||
1,0,1,1,1,0,1,1,1,0,1,1};
|
||||
|
||||
//puncturing pattern P_2
|
||||
const uint8_t P_2[12]={1,1,1,1,1,1,1,1,1,1,1,0};
|
||||
|
||||
//puncturing pattern P_3
|
||||
const uint8_t P_3[8]={1,1,1,1,1,1,1,0};
|
||||
|
||||
//M17 CRC polynomial
|
||||
const uint16_t M17_CRC_POLY = 0x5935;
|
||||
|
||||
//sample RRC filter for 48kHz sample rate
|
||||
//alpha=0.5, span=8, sps=10, gain=sqrt(sps)
|
||||
const float taps_10[8*10+1]=
|
||||
{
|
||||
-0.003195702904062073f, -0.002930279157647190f, -0.001940667871554463f,
|
||||
-0.000356087678023658f, 0.001547011339077758f, 0.003389554791179751f,
|
||||
0.004761898604225673f, 0.005310860846138910f, 0.004824746306020221f,
|
||||
0.003297923526848786f, 0.000958710871218619f, -0.001749908029791816f,
|
||||
-0.004238694106631223f, -0.005881783042101693f, -0.006150256456781309f,
|
||||
-0.004745376707651645f, -0.001704189656473565f, 0.002547854551539951f,
|
||||
0.007215575568844704f, 0.011231038205363532f, 0.013421952197060707f,
|
||||
0.012730475385624438f, 0.008449554307303753f, 0.000436744366018287f,
|
||||
-0.010735380379191660f, -0.023726883538258272f, -0.036498030780605324f,
|
||||
-0.046500883189991064f, -0.050979050575999614f, -0.047340680079891187f,
|
||||
-0.033554880492651755f, -0.008513823955725943f, 0.027696543159614194f,
|
||||
0.073664520037517042f, 0.126689053778116234f, 0.182990955139333916f,
|
||||
0.238080025892859704f, 0.287235637987091563f, 0.326040247765297220f,
|
||||
0.350895727088112619f, 0.359452932027607974f, 0.350895727088112619f,
|
||||
0.326040247765297220f, 0.287235637987091563f, 0.238080025892859704f,
|
||||
0.182990955139333916f, 0.126689053778116234f, 0.073664520037517042f,
|
||||
0.027696543159614194f, -0.008513823955725943f, -0.033554880492651755f,
|
||||
-0.047340680079891187f, -0.050979050575999614f, -0.046500883189991064f,
|
||||
-0.036498030780605324f, -0.023726883538258272f, -0.010735380379191660f,
|
||||
0.000436744366018287f, 0.008449554307303753f, 0.012730475385624438f,
|
||||
0.013421952197060707f, 0.011231038205363532f, 0.007215575568844704f,
|
||||
0.002547854551539951f, -0.001704189656473565f, -0.004745376707651645f,
|
||||
-0.006150256456781309f, -0.005881783042101693f, -0.004238694106631223f,
|
||||
-0.001749908029791816f, 0.000958710871218619f, 0.003297923526848786f,
|
||||
0.004824746306020221f, 0.005310860846138910f, 0.004761898604225673f,
|
||||
0.003389554791179751f, 0.001547011339077758f, -0.000356087678023658f,
|
||||
-0.001940667871554463f, -0.002930279157647190f, -0.003195702904062073f
|
||||
};
|
||||
|
||||
//sample RRC filter for 24kHz sample rate
|
||||
//alpha=0.5, span=8, sps=5, gain=sqrt(sps)
|
||||
const float taps_5[8*5+1]=
|
||||
{
|
||||
-0.004519384154389f, -0.002744505321971f,
|
||||
0.002187793653660f, 0.006734308458208f,
|
||||
0.006823188093192f, 0.001355815246317f,
|
||||
-0.005994389201970f, -0.008697733303330f,
|
||||
-0.002410076268276f, 0.010204314627992f,
|
||||
0.018981413448435f, 0.011949415510291f,
|
||||
-0.015182045838927f, -0.051615756197679f,
|
||||
-0.072094910038768f, -0.047453533621088f,
|
||||
0.039168634270669f, 0.179164496628150f,
|
||||
0.336694345124862f, 0.461088271869920f,
|
||||
0.508340710642860f, 0.461088271869920f,
|
||||
0.336694345124862f, 0.179164496628150f,
|
||||
0.039168634270669f, -0.047453533621088f,
|
||||
-0.072094910038768f, -0.051615756197679f,
|
||||
-0.015182045838927f, 0.011949415510291f,
|
||||
0.018981413448435f, 0.010204314627992f,
|
||||
-0.002410076268276f, -0.008697733303330f,
|
||||
-0.005994389201970f, 0.001355815246317f,
|
||||
0.006823188093192f, 0.006734308458208f,
|
||||
0.002187793653660f, -0.002744505321971f,
|
||||
-0.004519384154389f
|
||||
};
|
||||
|
||||
//randomizing pattern
|
||||
const uint8_t rand_seq[46]=
|
||||
{
|
||||
0xD6, 0xB5, 0xE2, 0x30, 0x82, 0xFF, 0x84, 0x62, 0xBA, 0x4E, 0x96, 0x90, 0xD8, 0x98, 0xDD, 0x5D, 0x0C, 0xC8, 0x52, 0x43, 0x91, 0x1D, 0xF8,
|
||||
0x6E, 0x68, 0x2F, 0x35, 0xDA, 0x14, 0xEA, 0xCD, 0x76, 0x19, 0x8D, 0xD5, 0x80, 0xD1, 0x33, 0x87, 0x13, 0x57, 0x18, 0x2D, 0x29, 0x78, 0xC3
|
||||
};
|
||||
|
||||
//interleaver pattern
|
||||
const uint16_t intrl_seq[368]=
|
||||
{
|
||||
0, 137, 90, 227, 180, 317, 270, 39, 360, 129, 82, 219, 172, 309, 262, 31,
|
||||
352, 121, 74, 211, 164, 301, 254, 23, 344, 113, 66, 203, 156, 293, 246, 15,
|
||||
336, 105, 58, 195, 148, 285, 238, 7, 328, 97, 50, 187, 140, 277, 230, 367,
|
||||
320, 89, 42, 179, 132, 269, 222, 359, 312, 81, 34, 171, 124, 261, 214, 351,
|
||||
304, 73, 26, 163, 116, 253, 206, 343, 296, 65, 18, 155, 108, 245, 198, 335,
|
||||
288, 57, 10, 147, 100, 237, 190, 327, 280, 49, 2, 139, 92, 229, 182, 319,
|
||||
272, 41, 362, 131, 84, 221, 174, 311, 264, 33, 354, 123, 76, 213, 166, 303,
|
||||
256, 25, 346, 115, 68, 205, 158, 295, 248, 17, 338, 107, 60, 197, 150, 287,
|
||||
240, 9, 330, 99, 52, 189, 142, 279, 232, 1, 322, 91, 44, 181, 134, 271,
|
||||
224, 361, 314, 83, 36, 173, 126, 263, 216, 353, 306, 75, 28, 165, 118, 255,
|
||||
208, 345, 298, 67, 20, 157, 110, 247, 200, 337, 290, 59, 12, 149, 102, 239,
|
||||
192, 329, 282, 51, 4, 141, 94, 231, 184, 321, 274, 43, 364, 133, 86, 223,
|
||||
176, 313, 266, 35, 356, 125, 78, 215, 168, 305, 258, 27, 348, 117, 70, 207,
|
||||
160, 297, 250, 19, 340, 109, 62, 199, 152, 289, 242, 11, 332, 101, 54, 191,
|
||||
144, 281, 234, 3, 324, 93, 46, 183, 136, 273, 226, 363, 316, 85, 38, 175,
|
||||
128, 265, 218, 355, 308, 77, 30, 167, 120, 257, 210, 347, 300, 69, 22, 159,
|
||||
112, 249, 202, 339, 292, 61, 14, 151, 104, 241, 194, 331, 284, 53, 6, 143,
|
||||
96, 233, 186, 323, 276, 45, 366, 135, 88, 225, 178, 315, 268, 37, 358, 127,
|
||||
80, 217, 170, 307, 260, 29, 350, 119, 72, 209, 162, 299, 252, 21, 342, 111,
|
||||
64, 201, 154, 291, 244, 13, 334, 103, 56, 193, 146, 283, 236, 5, 326, 95,
|
||||
48, 185, 138, 275, 228, 365, 318, 87, 40, 177, 130, 267, 220, 357, 310, 79,
|
||||
32, 169, 122, 259, 212, 349, 302, 71, 24, 161, 114, 251, 204, 341, 294, 63,
|
||||
16, 153, 106, 243, 196, 333, 286, 55, 8, 145, 98, 235, 188, 325, 278, 47
|
||||
};
|
|
@ -1,90 +0,0 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17consts.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#ifndef M17_CONSTS
|
||||
#define M17_CONSTS
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
#define BSB_SPS 10 //samples per symbol
|
||||
#define FLT_SPAN 8 //baseband RRC filter span in symbols
|
||||
#define SYM_PER_SWD 8 //symbols per syncword
|
||||
#define SW_LEN (BSB_SPS*SYM_PER_SWD) //syncword detector length
|
||||
#define SYM_PER_PLD 184 //symbols per payload in a frame
|
||||
#define SYM_PER_FRA 192 //symbols per whole 40 ms frame
|
||||
#define RRC_DEV 7168.0f //.rrc file deviation for +1.0 symbol
|
||||
|
||||
//L2 metric threshold
|
||||
#define DIST_THRESH 2.0f //threshold for distance (syncword detection)
|
||||
|
||||
//Viterbi
|
||||
#define K 5 //constraint length
|
||||
#define NUM_STATES (1 << (K - 1)) //number of states
|
||||
|
||||
//syncword patterns (RX) TODO:Compute those at runtime from the consts below
|
||||
extern const int8_t lsf_sync[8];
|
||||
extern const int8_t str_sync[8];
|
||||
extern const int8_t pkt_sync[8];
|
||||
|
||||
//symbol levels (RX)
|
||||
extern const float symbs[4];
|
||||
|
||||
//dibits-symbols map (TX)
|
||||
extern const int8_t symbol_map[4];
|
||||
|
||||
//syncwords
|
||||
extern const uint16_t SYNC_LSF;
|
||||
extern const uint16_t SYNC_STR;
|
||||
extern const uint16_t SYNC_PKT;
|
||||
extern const uint16_t SYNC_BER;
|
||||
extern const uint16_t EOT_MRKR;
|
||||
|
||||
//puncturing pattern P_1
|
||||
extern const uint8_t P_1[61];
|
||||
|
||||
//puncturing pattern P_2
|
||||
extern const uint8_t P_2[12];
|
||||
|
||||
//puncturing pattern P_3
|
||||
extern const uint8_t P_3[8];
|
||||
|
||||
//M17 CRC polynomial
|
||||
extern const uint16_t M17_CRC_POLY;
|
||||
|
||||
//sample RRC filter for 48kHz sample rate
|
||||
//alpha=0.5, span=8, sps=10, gain=sqrt(sps)
|
||||
extern const float taps_10[8*10+1];
|
||||
|
||||
//sample RRC filter for 24kHz sample rate
|
||||
//alpha=0.5, span=8, sps=5, gain=sqrt(sps)
|
||||
extern const float taps_5[8*5+1];
|
||||
|
||||
//randomizing pattern
|
||||
extern const uint8_t rand_seq[46];
|
||||
|
||||
//interleaver pattern
|
||||
extern const uint16_t intrl_seq[368];
|
||||
|
||||
/**
|
||||
* @brief Structure holding Link Setup Frame data.
|
||||
*
|
||||
*/
|
||||
struct LSF
|
||||
{
|
||||
uint8_t dst[6];
|
||||
uint8_t src[6];
|
||||
uint8_t type[2];
|
||||
uint8_t meta[112/8];
|
||||
uint8_t crc[2];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17golay.c
|
||||
// M17 C library - math/golay.c
|
||||
//
|
||||
// This file contains:
|
||||
// - Golay(24, 12) encoder
|
||||
|
@ -10,12 +10,13 @@
|
|||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include "m17math.h"
|
||||
#include "m17golay.h"
|
||||
|
||||
#include <math/math.h>
|
||||
#include "golay.h"
|
||||
|
||||
/**
|
||||
* @brief Precomputed encoding matrix for Golay(24, 12).
|
||||
*
|
||||
*
|
||||
*/
|
||||
const uint16_t encode_matrix[12]=
|
||||
{
|
||||
|
@ -25,7 +26,7 @@ const uint16_t encode_matrix[12]=
|
|||
|
||||
/**
|
||||
* @brief Precomputed decoding matrix for Golay(24, 12).
|
||||
*
|
||||
*
|
||||
*/
|
||||
const uint16_t decode_matrix[12]=
|
||||
{
|
||||
|
@ -35,7 +36,7 @@ const uint16_t decode_matrix[12]=
|
|||
|
||||
/**
|
||||
* @brief Encode a 12-bit value with Golay(24, 12).
|
||||
*
|
||||
*
|
||||
* @param data 12-bit input value (right justified).
|
||||
* @return uint32_t 24-bit Golay codeword.
|
||||
*/
|
||||
|
@ -56,7 +57,7 @@ uint32_t golay24_encode(const uint16_t data)
|
|||
|
||||
/**
|
||||
* @brief Soft-valued equivalent of `popcount()`
|
||||
*
|
||||
*
|
||||
* @param in Pointer to an array holding soft logic vector.
|
||||
* @param siz Vector's size.
|
||||
* @return uint32_t Sum of all values.
|
||||
|
@ -72,10 +73,10 @@ uint32_t s_popcount(const uint16_t* in, uint8_t siz)
|
|||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param out
|
||||
* @param value
|
||||
* @brief
|
||||
*
|
||||
* @param out
|
||||
* @param value
|
||||
*/
|
||||
void s_calc_checksum(uint16_t* out, const uint16_t* value)
|
||||
{
|
||||
|
@ -100,7 +101,7 @@ void s_calc_checksum(uint16_t* out, const uint16_t* value)
|
|||
|
||||
/**
|
||||
* @brief Detect errors in a soft-valued Golay(24, 12) codeword.
|
||||
*
|
||||
*
|
||||
* @param codeword Input 24-bit soft codeword.
|
||||
* @return uint32_t Detected errors vector.
|
||||
*/
|
||||
|
@ -216,7 +217,7 @@ uint32_t s_detect_errors(const uint16_t* codeword)
|
|||
|
||||
/**
|
||||
* @brief Soft decode Golay(24, 12) codeword.
|
||||
*
|
||||
*
|
||||
* @param codeword Pointer to a 24-element soft-valued (fixed-point) bit codeword.
|
||||
* @return uint16_t Decoded data.
|
||||
*/
|
||||
|
@ -237,7 +238,7 @@ uint16_t golay24_sdecode(const uint16_t codeword[24])
|
|||
|
||||
/**
|
||||
* @brief Soft decode LICH into a 6-byte array.
|
||||
*
|
||||
*
|
||||
* @param outp An array of packed, decoded bits.
|
||||
* @param inp Pointer to an array of 96 soft bits.
|
||||
*/
|
|
@ -1,22 +1,19 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17golay.h
|
||||
// M17 C library - math/golay.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#ifndef M17_GOLAY_LIB
|
||||
#define M17_GOLAY_LIB
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//consts
|
||||
extern const uint16_t encode_matrix[12];
|
||||
extern const uint16_t decode_matrix[12];
|
||||
|
||||
//functions
|
||||
uint32_t golay24_encode(const uint16_t data);
|
||||
uint16_t golay24_sdecode(const uint16_t codeword[24]);
|
||||
void decode_LICH(uint8_t* outp, const uint16_t* inp);
|
||||
|
@ -24,4 +21,3 @@ void decode_LICH(uint8_t* outp, const uint16_t* inp);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17math.c
|
||||
// M17 C library - math/math.c
|
||||
//
|
||||
// This file contains:
|
||||
// - absolute difference value
|
||||
|
@ -11,7 +11,7 @@
|
|||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include <math.h>
|
||||
#include "m17math.h"
|
||||
#include "math.h"
|
||||
|
||||
/**
|
||||
* @brief Utility function returning the absolute value of a difference between
|
||||
|
@ -29,7 +29,7 @@ uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2)
|
|||
|
||||
/**
|
||||
* @brief Calculate L2 norm between two n-dimensional vectors of floats.
|
||||
*
|
||||
*
|
||||
* @param in1 Vector 1.
|
||||
* @param in2 Vector 2.
|
||||
* @param n Vectors' size.
|
||||
|
@ -44,7 +44,7 @@ float eucl_norm(const float* in1, const int8_t* in2, const uint8_t n)
|
|||
tmp += powf(in1[i]-(float)in2[i], 2.0f);
|
||||
}
|
||||
|
||||
return sqrt(tmp);
|
||||
return sqrtf(tmp);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -82,9 +82,35 @@ uint16_t soft_to_int(const uint16_t* in, const uint8_t len)
|
|||
return tmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 1st quadrant fixed point addition with saturation.
|
||||
*
|
||||
* @param a Addend 1.
|
||||
* @param b Addend 2.
|
||||
* @return uint16_t Sum = a+b.
|
||||
*/
|
||||
uint16_t add16(const uint16_t a, const uint16_t b)
|
||||
{
|
||||
uint32_t r=(uint32_t)a+b;
|
||||
|
||||
return r<=0xFFFFU ? r : 0xFFFFU;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 1st quadrant fixed point subtraction with saturation.
|
||||
*
|
||||
* @param a Minuend.
|
||||
* @param b Subtrahent.
|
||||
* @return uint16_t Difference = a-b.
|
||||
*/
|
||||
uint16_t sub16(const uint16_t a, const uint16_t b)
|
||||
{
|
||||
return a>=b ? a-b : 0x0000U;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 1st quadrant fixed point division with saturation.
|
||||
*
|
||||
*
|
||||
* @param a Dividend.
|
||||
* @param b Divisor.
|
||||
* @return uint16_t Quotient = a/b.
|
||||
|
@ -99,7 +125,7 @@ uint16_t div16(const uint16_t a, const uint16_t b)
|
|||
|
||||
/**
|
||||
* @brief 1st quadrant fixed point multiplication.
|
||||
*
|
||||
*
|
||||
* @param a Multiplicand.
|
||||
* @param b Multiplier.
|
||||
* @return uint16_t Product = a*b.
|
||||
|
@ -111,19 +137,22 @@ uint16_t mul16(const uint16_t a, const uint16_t b)
|
|||
|
||||
/**
|
||||
* @brief Bilinear interpolation (soft-valued expansion) for XOR.
|
||||
*
|
||||
* This approach retains XOR(0.5, 0.5)=0.5
|
||||
* https://math.stackexchange.com/questions/3505934/evaluation-of-not-and-xor-in-fuzzy-logic-rules
|
||||
* @param a Input A.
|
||||
* @param b Input B.
|
||||
* @return uint16_t Output = A xor B.
|
||||
*/
|
||||
uint16_t soft_bit_XOR(const uint16_t a, const uint16_t b)
|
||||
{
|
||||
return mul16(div16(0xFFFF-b, 0xFFFF), div16(a, 0xFFFF)) + mul16(div16(b, 0xFFFF), div16(0xFFFF-a, 0xFFFF));
|
||||
//a(1-b)+b(1-a)
|
||||
//return mul16(div16(0xFFFF-b, 0xFFFF), div16(a, 0xFFFF)) + mul16(div16(b, 0xFFFF), div16(0xFFFF-a, 0xFFFF));
|
||||
return add16(mul16(a, sub16(0xFFFF, b)), mul16(b, sub16(0xFFFF, a)));
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief XOR for vectors of soft-valued logic.
|
||||
* Max length is 16.
|
||||
* Max length is 255.
|
||||
* @param out Output vector = A xor B.
|
||||
* @param a Input vector A.
|
||||
* @param b Input vector B.
|
||||
|
@ -133,4 +162,4 @@ void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t
|
|||
{
|
||||
for(uint8_t i=0; i<len; i++)
|
||||
out[i]=soft_bit_XOR(a[i], b[i]);
|
||||
}
|
||||
}
|
|
@ -1,21 +1,16 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17math.h
|
||||
// M17 C library - math/math.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#ifndef M17_MATH_LIB
|
||||
#define M17_MATH_LIB
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//vars
|
||||
;
|
||||
|
||||
//functions
|
||||
uint16_t q_abs_diff(const uint16_t v1, const uint16_t v2);
|
||||
float eucl_norm(const float* in1, const int8_t* in2, const uint8_t n);
|
||||
void int_to_soft(uint16_t* out, const uint16_t in, const uint8_t len);
|
||||
|
@ -28,4 +23,3 @@ void soft_XOR(uint16_t* out, const uint16_t* a, const uint16_t* b, const uint8_t
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -0,0 +1,67 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - math/rrc.c
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include "rrc.h"
|
||||
|
||||
//sample RRC filter for 48kHz sample rate
|
||||
//alpha=0.5, span=8, sps=10, gain=sqrt(sps)
|
||||
const float rrc_taps_10[8*10+1]=
|
||||
{
|
||||
-0.003195702904062073f, -0.002930279157647190f, -0.001940667871554463f,
|
||||
-0.000356087678023658f, 0.001547011339077758f, 0.003389554791179751f,
|
||||
0.004761898604225673f, 0.005310860846138910f, 0.004824746306020221f,
|
||||
0.003297923526848786f, 0.000958710871218619f, -0.001749908029791816f,
|
||||
-0.004238694106631223f, -0.005881783042101693f, -0.006150256456781309f,
|
||||
-0.004745376707651645f, -0.001704189656473565f, 0.002547854551539951f,
|
||||
0.007215575568844704f, 0.011231038205363532f, 0.013421952197060707f,
|
||||
0.012730475385624438f, 0.008449554307303753f, 0.000436744366018287f,
|
||||
-0.010735380379191660f, -0.023726883538258272f, -0.036498030780605324f,
|
||||
-0.046500883189991064f, -0.050979050575999614f, -0.047340680079891187f,
|
||||
-0.033554880492651755f, -0.008513823955725943f, 0.027696543159614194f,
|
||||
0.073664520037517042f, 0.126689053778116234f, 0.182990955139333916f,
|
||||
0.238080025892859704f, 0.287235637987091563f, 0.326040247765297220f,
|
||||
0.350895727088112619f, 0.359452932027607974f, 0.350895727088112619f,
|
||||
0.326040247765297220f, 0.287235637987091563f, 0.238080025892859704f,
|
||||
0.182990955139333916f, 0.126689053778116234f, 0.073664520037517042f,
|
||||
0.027696543159614194f, -0.008513823955725943f, -0.033554880492651755f,
|
||||
-0.047340680079891187f, -0.050979050575999614f, -0.046500883189991064f,
|
||||
-0.036498030780605324f, -0.023726883538258272f, -0.010735380379191660f,
|
||||
0.000436744366018287f, 0.008449554307303753f, 0.012730475385624438f,
|
||||
0.013421952197060707f, 0.011231038205363532f, 0.007215575568844704f,
|
||||
0.002547854551539951f, -0.001704189656473565f, -0.004745376707651645f,
|
||||
-0.006150256456781309f, -0.005881783042101693f, -0.004238694106631223f,
|
||||
-0.001749908029791816f, 0.000958710871218619f, 0.003297923526848786f,
|
||||
0.004824746306020221f, 0.005310860846138910f, 0.004761898604225673f,
|
||||
0.003389554791179751f, 0.001547011339077758f, -0.000356087678023658f,
|
||||
-0.001940667871554463f, -0.002930279157647190f, -0.003195702904062073f
|
||||
};
|
||||
|
||||
//sample RRC filter for 24kHz sample rate
|
||||
//alpha=0.5, span=8, sps=5, gain=sqrt(sps)
|
||||
const float rrc_taps_5[8*5+1]=
|
||||
{
|
||||
-0.004519384154389f, -0.002744505321971f,
|
||||
0.002187793653660f, 0.006734308458208f,
|
||||
0.006823188093192f, 0.001355815246317f,
|
||||
-0.005994389201970f, -0.008697733303330f,
|
||||
-0.002410076268276f, 0.010204314627992f,
|
||||
0.018981413448435f, 0.011949415510291f,
|
||||
-0.015182045838927f, -0.051615756197679f,
|
||||
-0.072094910038768f, -0.047453533621088f,
|
||||
0.039168634270669f, 0.179164496628150f,
|
||||
0.336694345124862f, 0.461088271869920f,
|
||||
0.508340710642860f, 0.461088271869920f,
|
||||
0.336694345124862f, 0.179164496628150f,
|
||||
0.039168634270669f, -0.047453533621088f,
|
||||
-0.072094910038768f, -0.051615756197679f,
|
||||
-0.015182045838927f, 0.011949415510291f,
|
||||
0.018981413448435f, 0.010204314627992f,
|
||||
-0.002410076268276f, -0.008697733303330f,
|
||||
-0.005994389201970f, 0.001355815246317f,
|
||||
0.006823188093192f, 0.006734308458208f,
|
||||
0.002187793653660f, -0.002744505321971f,
|
||||
-0.004519384154389f
|
||||
};
|
|
@ -0,0 +1,23 @@
|
|||
//-------------------------------
|
||||
// M17 C library - math/rrc.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//sample RRC filter for 48kHz sample rate
|
||||
//alpha=0.5, span=8, sps=10, gain=sqrt(sps)
|
||||
extern const float rrc_taps_10[8*10+1];
|
||||
|
||||
//sample RRC filter for 24kHz sample rate
|
||||
//alpha=0.5, span=8, sps=5, gain=sqrt(sps)
|
||||
extern const float rrc_taps_5[8*5+1];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17call.c
|
||||
// M17 C library - payload/call.c
|
||||
//
|
||||
// This file contains:
|
||||
// - callsign encoder and decoders
|
||||
|
@ -9,7 +9,7 @@
|
|||
//--------------------------------------------------------------------
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "m17call.h"
|
||||
#include "call.h"
|
||||
|
||||
//decodes a 6-byte long array to a callsign
|
||||
void decode_callsign_bytes(uint8_t *outp, const uint8_t *inp)
|
|
@ -1,21 +1,16 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17call.h
|
||||
// M17 C library - payload/call.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#ifndef M17_CALL_LIB
|
||||
#define M17_CALL_LIB
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//vars
|
||||
;
|
||||
|
||||
//functions
|
||||
void decode_callsign_bytes(uint8_t *outp, const uint8_t *inp);
|
||||
void decode_callsign_value(uint8_t *outp, const uint64_t inp);
|
||||
uint8_t encode_callsign(uint64_t* out, const uint8_t* inp);
|
||||
|
@ -23,4 +18,3 @@ uint8_t encode_callsign(uint64_t* out, const uint8_t* inp);
|
|||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17crc.c
|
||||
// M17 C library - payload/crc.c
|
||||
//
|
||||
// This file contains:
|
||||
// - CRC calculating functions (arbitrary length)
|
||||
|
@ -8,11 +8,14 @@
|
|||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include <string.h>
|
||||
#include "m17crc.h"
|
||||
#include "crc.h"
|
||||
|
||||
//M17 CRC polynomial
|
||||
const uint16_t M17_CRC_POLY = 0x5935;
|
||||
|
||||
/**
|
||||
* @brief Calculate CRC value.
|
||||
*
|
||||
*
|
||||
* @param in Pointer to the input byte array.
|
||||
* @param len Input's length.
|
||||
* @return uint16_t CRC value.
|
||||
|
@ -37,7 +40,7 @@ uint16_t CRC_M17(const uint8_t *in, const uint16_t len)
|
|||
|
||||
/**
|
||||
* @brief Calculate CRC value for the Link Setup Frame.
|
||||
*
|
||||
*
|
||||
* @param in Pointer to an LSF struct.
|
||||
* @return uint16_t CRC value.
|
||||
*/
|
|
@ -1,27 +1,23 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - m17crc.h
|
||||
// M17 C library - payload/crc.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#ifndef M17_CRC_LIB
|
||||
#define M17_CRC_LIB
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
#include "m17consts.h"
|
||||
#include "lsf.h"
|
||||
|
||||
//vars
|
||||
;
|
||||
//M17 CRC polynomial
|
||||
extern const uint16_t M17_CRC_POLY;
|
||||
|
||||
//functions
|
||||
uint16_t CRC_M17(const uint8_t *in, const uint16_t len);
|
||||
uint16_t LSF_CRC(const struct LSF *in);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
//-------------------------------
|
||||
// M17 C library - payload/lsf.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Structure holding Link Setup Frame data.
|
||||
*
|
||||
*/
|
||||
struct LSF
|
||||
{
|
||||
uint8_t dst[6];
|
||||
uint8_t src[6];
|
||||
uint8_t type[2];
|
||||
uint8_t meta[112/8];
|
||||
uint8_t crc[2];
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,36 @@
|
|||
//-------------------------------
|
||||
// M17 C library - phy/interleave.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
|
||||
#include "interleave.h"
|
||||
|
||||
//interleaver pattern
|
||||
const uint16_t intrl_seq[368]=
|
||||
{
|
||||
0, 137, 90, 227, 180, 317, 270, 39, 360, 129, 82, 219, 172, 309, 262, 31,
|
||||
352, 121, 74, 211, 164, 301, 254, 23, 344, 113, 66, 203, 156, 293, 246, 15,
|
||||
336, 105, 58, 195, 148, 285, 238, 7, 328, 97, 50, 187, 140, 277, 230, 367,
|
||||
320, 89, 42, 179, 132, 269, 222, 359, 312, 81, 34, 171, 124, 261, 214, 351,
|
||||
304, 73, 26, 163, 116, 253, 206, 343, 296, 65, 18, 155, 108, 245, 198, 335,
|
||||
288, 57, 10, 147, 100, 237, 190, 327, 280, 49, 2, 139, 92, 229, 182, 319,
|
||||
272, 41, 362, 131, 84, 221, 174, 311, 264, 33, 354, 123, 76, 213, 166, 303,
|
||||
256, 25, 346, 115, 68, 205, 158, 295, 248, 17, 338, 107, 60, 197, 150, 287,
|
||||
240, 9, 330, 99, 52, 189, 142, 279, 232, 1, 322, 91, 44, 181, 134, 271,
|
||||
224, 361, 314, 83, 36, 173, 126, 263, 216, 353, 306, 75, 28, 165, 118, 255,
|
||||
208, 345, 298, 67, 20, 157, 110, 247, 200, 337, 290, 59, 12, 149, 102, 239,
|
||||
192, 329, 282, 51, 4, 141, 94, 231, 184, 321, 274, 43, 364, 133, 86, 223,
|
||||
176, 313, 266, 35, 356, 125, 78, 215, 168, 305, 258, 27, 348, 117, 70, 207,
|
||||
160, 297, 250, 19, 340, 109, 62, 199, 152, 289, 242, 11, 332, 101, 54, 191,
|
||||
144, 281, 234, 3, 324, 93, 46, 183, 136, 273, 226, 363, 316, 85, 38, 175,
|
||||
128, 265, 218, 355, 308, 77, 30, 167, 120, 257, 210, 347, 300, 69, 22, 159,
|
||||
112, 249, 202, 339, 292, 61, 14, 151, 104, 241, 194, 331, 284, 53, 6, 143,
|
||||
96, 233, 186, 323, 276, 45, 366, 135, 88, 225, 178, 315, 268, 37, 358, 127,
|
||||
80, 217, 170, 307, 260, 29, 350, 119, 72, 209, 162, 299, 252, 21, 342, 111,
|
||||
64, 201, 154, 291, 244, 13, 334, 103, 56, 193, 146, 283, 236, 5, 326, 95,
|
||||
48, 185, 138, 275, 228, 365, 318, 87, 40, 177, 130, 267, 220, 357, 310, 79,
|
||||
32, 169, 122, 259, 212, 349, 302, 71, 24, 161, 114, 251, 204, 341, 294, 63,
|
||||
16, 153, 106, 243, 196, 333, 286, 55, 8, 145, 98, 235, 188, 325, 278, 47
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
//-------------------------------
|
||||
// M17 C library - phy/interleave.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//interleaver pattern
|
||||
extern const uint16_t intrl_seq[368];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - phy/randomize.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include "randomize.h"
|
||||
|
||||
//randomizing pattern
|
||||
const uint8_t rand_seq[46]=
|
||||
{
|
||||
0xD6, 0xB5, 0xE2, 0x30, 0x82, 0xFF, 0x84, 0x62, 0xBA, 0x4E, 0x96, 0x90, 0xD8, 0x98, 0xDD, 0x5D, 0x0C, 0xC8, 0x52, 0x43, 0x91, 0x1D, 0xF8,
|
||||
0x6E, 0x68, 0x2F, 0x35, 0xDA, 0x14, 0xEA, 0xCD, 0x76, 0x19, 0x8D, 0xD5, 0x80, 0xD1, 0x33, 0x87, 0x13, 0x57, 0x18, 0x2D, 0x29, 0x78, 0xC3
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
//-------------------------------
|
||||
// M17 C library - phy/randomize.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//randomizing pattern
|
||||
extern const uint8_t rand_seq[46];
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -0,0 +1,14 @@
|
|||
//--------------------------------------------------------------------
|
||||
// M17 C library - phy/sync.c
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 29 December 2023
|
||||
//--------------------------------------------------------------------
|
||||
#include "sync.h"
|
||||
|
||||
//syncwords
|
||||
const uint16_t SYNC_LSF = 0x55F7;
|
||||
const uint16_t SYNC_STR = 0xFF5D;
|
||||
const uint16_t SYNC_PKT = 0x75FF;
|
||||
const uint16_t SYNC_BER = 0xDF55;
|
||||
const uint16_t EOT_MRKR = 0x555D;
|
|
@ -0,0 +1,23 @@
|
|||
//-------------------------------
|
||||
// M17 C library - phy/sync.h
|
||||
//
|
||||
// Wojciech Kaczmarski, SP5WWP
|
||||
// M17 Project, 28 December 2023
|
||||
//-------------------------------
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#include <stdint.h>
|
||||
|
||||
//syncwords
|
||||
extern const uint16_t SYNC_LSF;
|
||||
extern const uint16_t SYNC_STR;
|
||||
extern const uint16_t SYNC_PKT;
|
||||
extern const uint16_t SYNC_BER;
|
||||
extern const uint16_t EOT_MRKR;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
|
@ -1,5 +1,5 @@
|
|||
m17-coder-sym: m17-coder-sym.c ../lib/*.c ../lib/*.h
|
||||
gcc -O2 -Wall m17-coder-sym.c ../lib/*.c -o m17-coder-sym -lm
|
||||
m17-coder-sym: m17-coder-sym.c
|
||||
gcc -I ../lib -L ../lib -O2 -Wall m17-coder-sym.c -o m17-coder-sym -lm -lm17
|
||||
|
||||
clean:
|
||||
rm -f m17-coder-sym
|
||||
|
|
|
@ -3,14 +3,15 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../lib/m17lib.h"
|
||||
#include "../lib/m17call.h"
|
||||
#include "../lib/m17consts.h"
|
||||
#include "../lib/m17convol.h"
|
||||
#include "../lib/m17crc.h"
|
||||
#include "../lib/m17golay.h"
|
||||
#include "../lib/m17math.h"
|
||||
#include "../lib/m17viterbi.h"
|
||||
//libm17
|
||||
#include <lib.h>
|
||||
#include <encode/convol.h>
|
||||
#include <math/golay.h>
|
||||
#include <payload/crc.h>
|
||||
#include <payload/lsf.h>
|
||||
#include <phy/interleave.h>
|
||||
#include <phy/randomize.h>
|
||||
#include <phy/sync.h>
|
||||
|
||||
//#define FN60_DEBUG
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
m17-decoder-sym: m17-decoder-sym.c ../lib/*.c ../lib/*.h
|
||||
gcc -Wall -O2 m17-decoder-sym.c ../lib/*.c -o m17-decoder-sym -lm
|
||||
m17-decoder-sym: m17-decoder-sym.c
|
||||
gcc -I ../lib -L ../lib -Wall -O2 m17-decoder-sym.c -o m17-decoder-sym -lm -lm17
|
||||
|
||||
clean:
|
||||
rm -f m17-decoder-sym
|
||||
|
|
|
@ -3,14 +3,19 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../lib/m17lib.h"
|
||||
#include "../lib/m17call.h"
|
||||
#include "../lib/m17consts.h"
|
||||
#include "../lib/m17convol.h"
|
||||
#include "../lib/m17crc.h"
|
||||
#include "../lib/m17golay.h"
|
||||
#include "../lib/m17math.h"
|
||||
#include "../lib/m17viterbi.h"
|
||||
//libm17
|
||||
#include <lib.h>
|
||||
#include <decode/symbols.h>
|
||||
#include <decode/viterbi.h>
|
||||
#include <encode/convol.h>
|
||||
#include <encode/symbols.h>
|
||||
#include <math/golay.h>
|
||||
#include <math/math.h>
|
||||
#include <payload/call.h>
|
||||
#include <payload/crc.h>
|
||||
#include <phy/interleave.h>
|
||||
#include <phy/sync.h>
|
||||
#include <phy/randomize.h>
|
||||
|
||||
#define DECODE_CALLSIGNS
|
||||
#define SHOW_VITERBI_ERRS
|
||||
|
@ -54,7 +59,7 @@ int main(void)
|
|||
last[7]=sample;
|
||||
|
||||
//calculate euclidean norm
|
||||
dist = eucl_norm(last, str_sync, 8);
|
||||
dist = eucl_norm(last, str_sync_symbols, 8);
|
||||
|
||||
if(dist<DIST_THRESH) //frame syncword detected
|
||||
{
|
||||
|
@ -66,7 +71,7 @@ int main(void)
|
|||
else
|
||||
{
|
||||
//calculate euclidean norm again, this time against LSF syncword
|
||||
dist = eucl_norm(last, lsf_sync, 8);
|
||||
dist = eucl_norm(last, lsf_sync_symbols, 8);
|
||||
|
||||
if(dist<DIST_THRESH) //LSF syncword
|
||||
{
|
||||
|
@ -88,21 +93,21 @@ int main(void)
|
|||
for(uint8_t i=0; i<SYM_PER_PLD; i++)
|
||||
{
|
||||
//bit 0
|
||||
if(pld[i]>=symbs[3])
|
||||
if(pld[i]>=symbol_map[3])
|
||||
{
|
||||
soft_bit[i*2+1]=0xFFFF;
|
||||
}
|
||||
else if(pld[i]>=symbs[2])
|
||||
else if(pld[i]>=symbol_map[2])
|
||||
{
|
||||
soft_bit[i*2+1]=-(float)0xFFFF/(symbs[3]-symbs[2])*symbs[2]+pld[i]*(float)0xFFFF/(symbs[3]-symbs[2]);
|
||||
soft_bit[i*2+1]=-(float)0xFFFF/(symbol_map[3]-symbol_map[2])*symbol_map[2]+pld[i]*(float)0xFFFF/(symbol_map[3]-symbol_map[2]);
|
||||
}
|
||||
else if(pld[i]>=symbs[1])
|
||||
else if(pld[i]>=symbol_map[1])
|
||||
{
|
||||
soft_bit[i*2+1]=0x0000;
|
||||
}
|
||||
else if(pld[i]>=symbs[0])
|
||||
else if(pld[i]>=symbol_map[0])
|
||||
{
|
||||
soft_bit[i*2+1]=(float)0xFFFF/(symbs[1]-symbs[0])*symbs[1]-pld[i]*(float)0xFFFF/(symbs[1]-symbs[0]);
|
||||
soft_bit[i*2+1]=(float)0xFFFF/(symbol_map[1]-symbol_map[0])*symbol_map[1]-pld[i]*(float)0xFFFF/(symbol_map[1]-symbol_map[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -110,13 +115,13 @@ int main(void)
|
|||
}
|
||||
|
||||
//bit 1
|
||||
if(pld[i]>=symbs[2])
|
||||
if(pld[i]>=symbol_map[2])
|
||||
{
|
||||
soft_bit[i*2]=0x0000;
|
||||
}
|
||||
else if(pld[i]>=symbs[1])
|
||||
else if(pld[i]>=symbol_map[1])
|
||||
{
|
||||
soft_bit[i*2]=0x7FFF-pld[i]*(float)0xFFFF/(symbs[2]-symbs[1]);
|
||||
soft_bit[i*2]=0x7FFF-pld[i]*(float)0xFFFF/(symbol_map[2]-symbol_map[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -147,7 +152,7 @@ int main(void)
|
|||
}
|
||||
|
||||
//decode
|
||||
uint32_t e=viterbi_decode_punctured(frame_data, enc_data, P_2, 272, 12);
|
||||
uint32_t e=viterbi_decode_punctured(frame_data, enc_data, puncture_pattern_2, 272, 12);
|
||||
|
||||
uint16_t fn = (frame_data[1] << 8) | frame_data[2];
|
||||
|
||||
|
@ -241,7 +246,7 @@ int main(void)
|
|||
printf("LSF\n");
|
||||
|
||||
//decode
|
||||
uint32_t e=viterbi_decode_punctured(lsf, d_soft_bit, P_1, 2*SYM_PER_PLD, 61);
|
||||
uint32_t e=viterbi_decode_punctured(lsf, d_soft_bit, puncture_pattern_1, 2*SYM_PER_PLD, 61);
|
||||
|
||||
//shift the buffer 1 position left - get rid of the encoded flushing bits
|
||||
for(uint8_t i=0; i<30; i++)
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
all: m17-packet-encode m17-packet-decode
|
||||
|
||||
m17-packet-encode: m17-packet-encode.c ../lib/*.c ../lib/*.h
|
||||
gcc -O2 -Wall m17-packet-encode.c ../lib/*.c -o m17-packet-encode -lm
|
||||
m17-packet-encode: m17-packet-encode.c
|
||||
gcc -I ../lib -L ../lib -O2 -Wall m17-packet-encode.c -o m17-packet-encode -lm -lm17
|
||||
|
||||
m17-packet-decode: m17-packet-decode.c ../lib/*.c ../lib/*.h
|
||||
gcc -O2 -Wall m17-packet-decode.c ../lib/*.c -o m17-packet-decode -lm
|
||||
m17-packet-decode: m17-packet-decode.c
|
||||
gcc -I ../lib -L ../lib -O2 -Wall m17-packet-decode.c -o m17-packet-decode -lm -lm17
|
||||
|
||||
install: all
|
||||
sudo install m17-packet-encode /usr/local/bin
|
||||
|
|
|
@ -3,14 +3,19 @@
|
|||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "../lib/m17lib.h"
|
||||
#include "../lib/m17call.h"
|
||||
#include "../lib/m17consts.h"
|
||||
#include "../lib/m17convol.h"
|
||||
#include "../lib/m17crc.h"
|
||||
#include "../lib/m17golay.h"
|
||||
#include "../lib/m17math.h"
|
||||
#include "../lib/m17viterbi.h"
|
||||
//libm17
|
||||
#include <lib.h>
|
||||
#include <decode/symbols.h>
|
||||
#include <decode/viterbi.h>
|
||||
#include <encode/convol.h>
|
||||
#include <encode/symbols.h>
|
||||
#include <math/golay.h>
|
||||
#include <math/math.h>
|
||||
#include <payload/call.h>
|
||||
#include <payload/crc.h>
|
||||
#include <phy/interleave.h>
|
||||
#include <phy/sync.h>
|
||||
#include <phy/randomize.h>
|
||||
|
||||
float sample; //last raw sample from the stdin
|
||||
float last[8]; //look-back buffer for finding syncwords
|
||||
|
@ -94,7 +99,7 @@ int main(int argc, char* argv[])
|
|||
last[7]=sample;
|
||||
|
||||
//calculate euclidean norm
|
||||
dist = eucl_norm(last, pkt_sync, 8);
|
||||
dist = eucl_norm(last, pkt_sync_symbols, 8);
|
||||
|
||||
//fprintf(stderr, "pkt_sync dist: %3.5f\n", dist);
|
||||
if(dist<DIST_THRESH) //frame syncword detected
|
||||
|
@ -107,7 +112,7 @@ int main(int argc, char* argv[])
|
|||
else
|
||||
{
|
||||
//calculate euclidean norm again, this time against LSF syncword
|
||||
dist = eucl_norm(last, lsf_sync, 8);
|
||||
dist = eucl_norm(last, lsf_sync_symbols, 8);
|
||||
|
||||
//fprintf(stderr, "lsf_sync dist: %3.5f\n", dist);
|
||||
if(dist<DIST_THRESH) //LSF syncword
|
||||
|
@ -130,21 +135,21 @@ int main(int argc, char* argv[])
|
|||
for(uint8_t i=0; i<SYM_PER_PLD; i++)
|
||||
{
|
||||
//bit 0
|
||||
if(pld[i]>=symbs[3])
|
||||
if(pld[i]>=symbol_map[3])
|
||||
{
|
||||
soft_bit[i*2+1]=0xFFFF;
|
||||
}
|
||||
else if(pld[i]>=symbs[2])
|
||||
else if(pld[i]>=symbol_map[2])
|
||||
{
|
||||
soft_bit[i*2+1]=-(float)0xFFFF/(symbs[3]-symbs[2])*symbs[2]+pld[i]*(float)0xFFFF/(symbs[3]-symbs[2]);
|
||||
soft_bit[i*2+1]=-(float)0xFFFF/(symbol_map[3]-symbol_map[2])*symbol_map[2]+pld[i]*(float)0xFFFF/(symbol_map[3]-symbol_map[2]);
|
||||
}
|
||||
else if(pld[i]>=symbs[1])
|
||||
else if(pld[i]>=symbol_map[1])
|
||||
{
|
||||
soft_bit[i*2+1]=0x0000;
|
||||
}
|
||||
else if(pld[i]>=symbs[0])
|
||||
else if(pld[i]>=symbol_map[0])
|
||||
{
|
||||
soft_bit[i*2+1]=(float)0xFFFF/(symbs[1]-symbs[0])*symbs[1]-pld[i]*(float)0xFFFF/(symbs[1]-symbs[0]);
|
||||
soft_bit[i*2+1]=(float)0xFFFF/(symbol_map[1]-symbol_map[0])*symbol_map[1]-pld[i]*(float)0xFFFF/(symbol_map[1]-symbol_map[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -152,13 +157,13 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
|
||||
//bit 1
|
||||
if(pld[i]>=symbs[2])
|
||||
if(pld[i]>=symbol_map[2])
|
||||
{
|
||||
soft_bit[i*2]=0x0000;
|
||||
}
|
||||
else if(pld[i]>=symbs[1])
|
||||
else if(pld[i]>=symbol_map[1])
|
||||
{
|
||||
soft_bit[i*2]=0x7FFF-pld[i]*(float)0xFFFF/(symbs[2]-symbs[1]);
|
||||
soft_bit[i*2]=0x7FFF-pld[i]*(float)0xFFFF/(symbol_map[2]-symbol_map[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -183,7 +188,7 @@ int main(int argc, char* argv[])
|
|||
if(!fl)
|
||||
{
|
||||
//decode
|
||||
uint32_t e=viterbi_decode_punctured(frame_data, d_soft_bit, P_3, SYM_PER_PLD*2, 8);
|
||||
uint32_t e=viterbi_decode_punctured(frame_data, d_soft_bit, puncture_pattern_3, SYM_PER_PLD*2, 8);
|
||||
|
||||
//dump FN
|
||||
uint8_t rx_fn=(frame_data[26]>>2)&0x1F;
|
||||
|
@ -246,7 +251,7 @@ int main(int argc, char* argv[])
|
|||
//fprintf(stderr, "LSF\n");
|
||||
|
||||
//decode
|
||||
uint32_t e=viterbi_decode_punctured(lsf, d_soft_bit, P_1, 2*SYM_PER_PLD, 61);
|
||||
uint32_t e=viterbi_decode_punctured(lsf, d_soft_bit, puncture_pattern_1, 2*SYM_PER_PLD, 61);
|
||||
|
||||
//shift the buffer 1 position left - get rid of the encoded flushing bits
|
||||
for(uint8_t i=0; i<30; i++)
|
||||
|
|
|
@ -4,14 +4,18 @@
|
|||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../lib/m17lib.h"
|
||||
#include "../lib/m17call.h"
|
||||
#include "../lib/m17consts.h"
|
||||
#include "../lib/m17convol.h"
|
||||
#include "../lib/m17crc.h"
|
||||
#include "../lib/m17golay.h"
|
||||
#include "../lib/m17math.h"
|
||||
#include "../lib/m17viterbi.h"
|
||||
//libm17
|
||||
#include <lib.h>
|
||||
#include <encode/convol.h>
|
||||
#include <encode/symbols.h>
|
||||
#include <math/golay.h>
|
||||
#include <math/rrc.h>
|
||||
#include <payload/call.h>
|
||||
#include <payload/crc.h>
|
||||
#include <payload/lsf.h>
|
||||
#include <phy/interleave.h>
|
||||
#include <phy/randomize.h>
|
||||
#include <phy/sync.h>
|
||||
|
||||
#define FLT_LEN (BSB_SPS*FLT_SPAN+1) //for 48kHz sample rate this is 81
|
||||
|
||||
|
@ -383,7 +387,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
//calc the sum of products
|
||||
for(uint16_t k=0; k<FLT_LEN; k++)
|
||||
mac+=mem[k]*taps_10[k]*sqrtf(10.0); //temporary fix for the interpolation gain error
|
||||
mac+=mem[k]*rrc_taps_10[k]*sqrtf(10.0); //temporary fix for the interpolation gain error
|
||||
|
||||
//shift the delay line right by 1
|
||||
for(int16_t k=FLT_LEN-1; k>0; k--)
|
||||
|
|
Ładowanie…
Reference in New Issue