kopia lustrzana https://github.com/M17-Project/M17_Implementations
Porównaj commity
8 Commity
48c3d8ce14
...
a0c0df5c49
Autor | SHA1 | Data |
---|---|---|
Wojciech Kaczmarski | a0c0df5c49 | |
Wojciech Kaczmarski | 974d31db11 | |
Wojciech Kaczmarski | c2d1adb154 | |
Wojciech Kaczmarski | 3d165dff89 | |
Wojciech Kaczmarski | f47717503f | |
Wojciech Kaczmarski | a3ef25ace4 | |
Wojciech Kaczmarski | 6388bd43d6 | |
Wojciech Kaczmarski | 19eb0beb60 |
41
README.md
41
README.md
|
@ -27,9 +27,10 @@ syncword is detected, decoding process starts. The program expects a stream of s
|
|||
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 798.
|
||||
with the `-n` parameter, range 1 to 800.
|
||||
|
||||
### Testing
|
||||
#### Stream mode
|
||||
Both the encoder and the decoder can be tested simultaneously. The test setup should look as follows:<br>
|
||||
`GRC flowgraph -> fifo1 -> m17-coder-sym -> fifo2 -> m17-decoder-sym -> stdout`<br>
|
||||
To perform a simple test, GNURadio 3.10 is required.
|
||||
|
@ -46,17 +47,45 @@ Start gnuradio-companion, open the .grc file included in this repo (`/grc/m17_st
|
|||
the name of the named pipe to `fifo1` (at the *File Sink* block - the rightmost one). Change the location of it
|
||||
if needed.
|
||||
|
||||
Open up 2 consoles and run:<br>
|
||||
Console 1:
|
||||
Open up 2 terminals and run:<br>
|
||||
Terminal 1:
|
||||
```
|
||||
cat fifo1 | ./m17-coder-sym > fifo2
|
||||
```
|
||||
Console 2:
|
||||
Terminal 2:
|
||||
```
|
||||
cat fifo2 | ./m17-decoder-sym
|
||||
```
|
||||
|
||||
Hit the *Execte the flow graph* button in GNURadio and watch it roll.
|
||||
Hit the *Execute the flow graph* button in GNURadio and watch it roll.
|
||||
|
||||
Console 2 should show similar results, with the Frame Number advancing each frame:
|
||||
Terminal 2 should show similar results, with the Frame Number advancing each frame:
|
||||
![image](https://user-images.githubusercontent.com/44336093/209792966-44a7813e-13b3-45d7-92f1-02bb1bdc219f.png)
|
||||
|
||||
#### Packet mode
|
||||
Packet encoding is available with `m17-packet-encoder`. Its input parameters are shown below.
|
||||
```
|
||||
-S - source callsign (uppercase alphanumeric string) max. 9 characters
|
||||
-D - destination callsign (uppercase alphanumeric string) or ALL for boradcast
|
||||
-C - Channel Access Number (0..15, default - 0)
|
||||
-n - number of bytes (1 to 800)
|
||||
-o - output file path/name
|
||||
-x - binary output (M17 baseband as a packed bitstream)
|
||||
-r - raw audio output (single channel, signed 16-bit LE, +7168 for the +1.0 symbol, 10 samples per symbol)
|
||||
-s - signed 16-bit LE symbols output
|
||||
```
|
||||
|
||||
Input data is passed over stdin. Example command:
|
||||
|
||||
`echo -en "\x05Testing M17 packet mode." | ./m17-packet-encode -S N0CALL -D ALL -C 0 -n 25 -o baseband.rrc`
|
||||
|
||||
`-en` parameter for `echo` suppresses the trailing newline character and enables the use of `\` within the message.
|
||||
`\x05` sets the packet data content and stands for text message (as per M17 Specification document, chapter 3.2 - Packet Application).
|
||||
If a WAVE file format is required for the baseband, sox can be used:
|
||||
|
||||
`sox -t raw -r 48000 -b 16 -c 1 -L -e signed-integer baseband.rrc baseband.wav`
|
||||
|
||||
This line converts .rrc to .wav. SDRangel successfully decoding a packet:
|
||||
![SDRangel screen dump](https://github.com/M17-Project/M17_Implementations/assets/44336093/d2cd195c-6126-4b48-b516-36d20dced9ce)
|
||||
|
||||
The two characters at the end of the message are probably CRC bytes erroneously decoded by SDRangel as a part of the text message.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
m17-packet-encode: m17-packet-encode.c crc.c
|
||||
gcc -O2 -w m17-packet-encode.c crc.c -o m17-packet-encode -lm
|
||||
gcc -O2 -Wall m17-packet-encode.c crc.c -o m17-packet-encode -lm
|
||||
|
||||
clean:
|
||||
rm m17-packet-encode
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#include "../inc/m17.h"
|
||||
|
@ -22,7 +22,7 @@ uint8_t rf_bits[SYM_PER_PLD*2]; //type-4 bits, unpac
|
|||
uint8_t dst_raw[10]={'A', 'L', 'L', '\0'}; //raw, unencoded destination address
|
||||
uint8_t src_raw[10]={'N', '0', 'C', 'A', 'L', 'L', '\0'}; //raw, unencoded source address
|
||||
uint8_t can=0; //Channel Access Number, default: 0
|
||||
uint16_t num_bytes=0; //number of bytes in packet, max 800-2=798
|
||||
uint16_t num_bytes=0; //number of bytes in packet, max 800
|
||||
//uint8_t data[25]; //raw payload, packed bits
|
||||
uint8_t fname[128]={'\0'}; //output file
|
||||
|
||||
|
@ -42,8 +42,6 @@ uint8_t out_type=0; //output file type -
|
|||
//type - 1 - preamble before BERT transmission
|
||||
void fill_Preamble(float* out, const uint8_t type)
|
||||
{
|
||||
float symb;
|
||||
|
||||
if(type) //pre-BERT
|
||||
{
|
||||
for(uint16_t i=0; i<SYM_PER_FRA/2; i++) //40ms * 4800 = 192
|
||||
|
@ -250,7 +248,7 @@ uint16_t LSF_CRC(struct LSF *in)
|
|||
uint8_t encode_callsign(uint64_t* out, const uint8_t* inp)
|
||||
{
|
||||
//assert inp length
|
||||
if(strlen(inp)>9)
|
||||
if(strlen((const char*)inp)>9)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
@ -259,13 +257,13 @@ uint8_t encode_callsign(uint64_t* out, const uint8_t* inp)
|
|||
|
||||
uint64_t tmp=0;
|
||||
|
||||
if(strcmp(inp, "ALL")==0)
|
||||
if(strcmp((const char*)inp, "ALL")==0)
|
||||
{
|
||||
*out=0xFFFFFFFFFFFF;
|
||||
return 0;
|
||||
}
|
||||
|
||||
for(int8_t i=strlen(inp)-1; i>=0; i--)
|
||||
for(int8_t i=strlen((const char*)inp)-1; i>=0; i--)
|
||||
{
|
||||
for(uint8_t j=0; j<40; j++)
|
||||
{
|
||||
|
@ -315,8 +313,8 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else if(argv[i][1]=='C') //-C - CAN
|
||||
{
|
||||
if(atoi(argv[i+1])<=15)
|
||||
can=atoi(&argv[i+1]);
|
||||
if(atoi(&argv[i+1][0])<=15)
|
||||
can=atoi(&argv[i+1][0]);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "CAN out of range: 0..15.\n");
|
||||
|
@ -325,17 +323,17 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
else if(argv[i][1]=='n') //-n - number of bytes in packet
|
||||
{
|
||||
if(atoi(argv[i+1])>0 && atoi(argv[i+1])<=798)
|
||||
num_bytes=atoi(argv[i+1]);
|
||||
if(atoi(argv[i+1])>0 && atoi(argv[i+1])<=800)
|
||||
num_bytes=atoi(&argv[i+1][0]);
|
||||
else
|
||||
{
|
||||
fprintf(stderr, "Number of bytes 0 or exceeding the maximum of 798. Exiting...\n");
|
||||
fprintf(stderr, "Number of bytes 0 or exceeding the maximum of 800. Exiting...\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
else if(argv[i][1]=='o') //-o - output filename
|
||||
{
|
||||
if(strlen(argv[i+1])>0)
|
||||
if(strlen(&argv[i+1][0])>0)
|
||||
memcpy(fname, &argv[i+1][0], strlen(argv[i+1]));
|
||||
else
|
||||
{
|
||||
|
@ -366,14 +364,14 @@ int main(int argc, char* argv[])
|
|||
else
|
||||
{
|
||||
fprintf(stderr, "Not enough params. Usage:\n");
|
||||
fprintf(stderr, "-S - source callsign (uppercase alphanumeric string) max. 9 characters,");
|
||||
fprintf(stderr, "-D - destination callsign (uppercase alphanumeric string) or ALL for boradcast,");
|
||||
fprintf(stderr, "-C - Channel Access Number (0..15, default - 10),");
|
||||
fprintf(stderr, "-n - number of bytes (1 to 798),");
|
||||
fprintf(stderr, "-o - output file path/name,");
|
||||
fprintf(stderr, "-S - source callsign (uppercase alphanumeric string) max. 9 characters,\n");
|
||||
fprintf(stderr, "-D - destination callsign (uppercase alphanumeric string) or ALL for boradcast,\n");
|
||||
fprintf(stderr, "-C - Channel Access Number (0..15, default - 0),\n");
|
||||
fprintf(stderr, "-n - number of bytes (1 to 800),\n");
|
||||
fprintf(stderr, "-o - output file path/name,\n");
|
||||
fprintf(stderr, "Output formats:\n");
|
||||
//fprintf(stderr, "-x - binary output (M17 baseband as a packed bitstream),");
|
||||
fprintf(stderr, "-r - raw audio output (single channel, signed 16-bit LE, +7168 for the +1.0 symbol, 10 samples per symbol),");
|
||||
//fprintf(stderr, "-x - binary output (M17 baseband as a packed bitstream),\n");
|
||||
fprintf(stderr, "-r - raw audio output (single channel, signed 16-bit LE, +7168 for the +1.0 symbol, 10 samples per symbol),\n");
|
||||
fprintf(stderr, "-s - signed 16-bit LE symbols output\n");
|
||||
return -1;
|
||||
}
|
||||
|
@ -384,7 +382,7 @@ int main(int argc, char* argv[])
|
|||
fprintf(stderr, "Number of bytes not set. Exiting...\n");
|
||||
return -1;
|
||||
}
|
||||
else if(strlen(fname)==0)
|
||||
else if(strlen((const char*)fname)==0)
|
||||
{
|
||||
fprintf(stderr, "Filename not specified. Exiting...\n");
|
||||
return -1;
|
||||
|
@ -405,7 +403,11 @@ int main(int argc, char* argv[])
|
|||
lsf.dst[5-i]=(dst_encoded>>(i*8))&0xFF;
|
||||
lsf.src[5-i]=(src_encoded>>(i*8))&0xFF;
|
||||
}
|
||||
#ifdef __ARM_ARCH_6__
|
||||
fprintf(stderr, "DST: %s\t%012llX\nSRC: %s\t%012llX\n", dst_raw, dst_encoded, src_raw, src_encoded);
|
||||
#else
|
||||
fprintf(stderr, "DST: %s\t%012lX\nSRC: %s\t%012lX\n", dst_raw, dst_encoded, src_raw, src_encoded);
|
||||
#endif
|
||||
//fprintf(stderr, "DST: %02X %02X %02X %02X %02X %02X\n", lsf.dst[0], lsf.dst[1], lsf.dst[2], lsf.dst[3], lsf.dst[4], lsf.dst[5]);
|
||||
//fprintf(stderr, "SRC: %02X %02X %02X %02X %02X %02X\n", lsf.src[0], lsf.src[1], lsf.src[2], lsf.src[3], lsf.src[4], lsf.src[5]);
|
||||
type=((uint16_t)0b01<<1)|((uint16_t)can<<7); //packet mode, content: data
|
||||
|
@ -539,7 +541,7 @@ int main(int argc, char* argv[])
|
|||
pkt_chunk[25]=(((num_bytes%25==0)?25:num_bytes%25)<<3)|(1<<2); //counter set to the amount of bytes in the previous frame, EOT bit set to 1
|
||||
|
||||
//encode the last packet frame
|
||||
fprintf(stderr, "FN:-- (ending frame)\n", pkt_cnt);
|
||||
fprintf(stderr, "FN:-- (ending frame)\n");
|
||||
fprintf(stderr, "CRC: %04X\n", crc);
|
||||
conv_Encode_Frame(enc_bits, pkt_chunk);
|
||||
|
||||
|
@ -567,7 +569,7 @@ int main(int argc, char* argv[])
|
|||
fill_Syncword(full_packet, &pkt_sym_cnt, EOT_MRKR);
|
||||
|
||||
//dump baseband to a file
|
||||
fp=fopen(fname, "wb");
|
||||
fp=fopen((const char*)fname, "wb");
|
||||
|
||||
//debug mode - symbols multiplied by 7168 scaling factor
|
||||
/*for(uint16_t i=0; i<pkt_sym_cnt; i++)
|
||||
|
@ -581,7 +583,6 @@ int main(int argc, char* argv[])
|
|||
{
|
||||
float mem[FLT_LEN];
|
||||
float mac=0.0f;
|
||||
uint8_t int_cnt=0;
|
||||
memset((uint8_t*)mem, 0, FLT_LEN*sizeof(float));
|
||||
for(uint16_t i=0; i<pkt_sym_cnt; i++)
|
||||
{
|
||||
|
|
Ładowanie…
Reference in New Issue