diff --git a/.gitignore b/.gitignore index cc1f0be..14ffd8a 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /SP5WWP/m17-packet/m17-packet-encode /SP5WWP/m17-packet/m17-packet-decode /SP5WWP/.vscode +*.json diff --git a/SP5WWP/lib/Makefile b/SP5WWP/lib/Makefile index 3617bdd..396e9d0 100644 --- a/SP5WWP/lib/Makefile +++ b/SP5WWP/lib/Makefile @@ -15,6 +15,9 @@ clean: fclean: rm -f $(TARGET) +install: + sudo install $(TARGET) /usr/local/lib + $(TARGET): $(OBJS) $(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS) diff --git a/SP5WWP/lib/encode/symbols.c b/SP5WWP/lib/encode/symbols.c index f80c897..614574f 100644 --- a/SP5WWP/lib/encode/symbols.c +++ b/SP5WWP/lib/encode/symbols.c @@ -2,9 +2,12 @@ // M17 C library - encode/symbols.c // // Wojciech Kaczmarski, SP5WWP -// M17 Project, 29 December 2023 +// M17 Project, 5 January 2024 //-------------------------------------------------------------------- #include "symbols.h" -// dibits-symbols map (TX) +//dibits-symbols map (TX) const int8_t symbol_map[4]={+1, +3, -1, -3}; + +//End of Transmission symbol pattern +const float eot_symbols[8]={+3, +3, +3, +3, +3, +3, -3, +3}; diff --git a/SP5WWP/lib/encode/symbols.h b/SP5WWP/lib/encode/symbols.h index 9016d69..0ebdaa6 100644 --- a/SP5WWP/lib/encode/symbols.h +++ b/SP5WWP/lib/encode/symbols.h @@ -2,7 +2,7 @@ // M17 C library - encode/symbols.h // // Wojciech Kaczmarski, SP5WWP -// M17 Project, 28 December 2023 +// M17 Project, 5 January 2024 //------------------------------- #pragma once @@ -11,9 +11,12 @@ extern "C" { #endif #include -// dibits-symbols map (TX) +//dibits-symbols map (TX) extern const int8_t symbol_map[4]; +//End of Transmission symbol pattern +extern const float eot_symbols[8]; + #ifdef __cplusplus } #endif diff --git a/SP5WWP/lib/lib.c b/SP5WWP/lib/lib.c index 92a5694..f886783 100644 --- a/SP5WWP/lib/lib.c +++ b/SP5WWP/lib/lib.c @@ -2,66 +2,80 @@ // M17 C library - lib.c // // Wojciech Kaczmarski, SP5WWP -// M17 Project, 29 December 2023 +// M17 Project, 5 January 2024 //-------------------------------------------------------------------- -#include #include #include "lib.h" -//misc -void send_preamble(const uint8_t type) +/** + * @brief Generate symbol stream for a preamble. + * + * @param out Frame buffer (192 floats) + * @param cnt Pointer to a variable holding the number of written symbols. + * @param type Preamble type (pre-BERT or pre-LSF). + */ +void send_preamble(float out[SYM_PER_FRA], uint32_t *cnt, const uint8_t type) { - float symb; - if(type) //pre-BERT { - for(uint16_t i=0; i<192/2; i++) //40ms * 4800 = 192 + for(uint16_t i=0; i>(14-i))&3]; - fwrite((uint8_t*)&symb, sizeof(float), 1, stdout); + out[(*cnt)++]=symbol_map[(syncword>>(14-i))&3]; } } //send the data (can be used for both LSF and frames) -void send_data(const uint8_t* in) +/** + * @brief Generate symbol stream for frame contents (without syncword). + * Can be used for both LSF and data frames. + * + * @param out Output buffer (184 floats). + * @param cnt Pointer to a variable holding the number of written symbols. + * @param in Data input. + */ +void send_data(float out[SYM_PER_PLD], uint32_t *cnt, const uint8_t* in) { - float s=0.0; for(uint16_t i=0; i