modified project structure and added logic to main function
parent
55f51c263b
commit
22d9eb2c75
|
@ -0,0 +1,51 @@
|
||||||
|
CC := gcc
|
||||||
|
CCFLAG := -Wall -O2 -std=c99
|
||||||
|
DBGFLAG := -g
|
||||||
|
CCOBJFLAG := $(CCFLAG) -c
|
||||||
|
|
||||||
|
BIN_PATH := bin
|
||||||
|
OBJ_PATH := obj
|
||||||
|
SRC_PATH := src
|
||||||
|
DBG_PATH := debug
|
||||||
|
|
||||||
|
TARGET_NAME := m17enc
|
||||||
|
TARGET := $(BIN_PATH)/$(TARGET_NAME)
|
||||||
|
TARGET_DEBUG := $(DBG_PATH)/$(TARGET_NAME)
|
||||||
|
MAIN_SRC := src/M17_RF_streamgen.c
|
||||||
|
|
||||||
|
SRC := $(foreach x, $(SRC_PATH), $(wildcard $(addprefix $(x)/*,.c*)))
|
||||||
|
OBJ := $(addprefix $(OBJ_PATH)/, $(addsuffix .o, $(notdir $(basename $(SRC)))))
|
||||||
|
OBJ_DEBUG := $(addprefix $(DBG_PATH)/, $(addsuffix .o, $(notdir $(basename $(SRC)))))
|
||||||
|
|
||||||
|
DISTCLEAN_LIST := $(OBJ) $(OBJ_DEBUG)
|
||||||
|
CLEAN_LIST := $(TARGET) $(TARGET_DEBUG) $(DISTCLEAN_LIST)
|
||||||
|
|
||||||
|
default: all
|
||||||
|
|
||||||
|
$(TARGET): $(OBJ)
|
||||||
|
$(CC) $(CCFLAG) -o $@ $?
|
||||||
|
|
||||||
|
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c*
|
||||||
|
$(CC) $(CCOBJFLAG) -o $@ $<
|
||||||
|
|
||||||
|
$(DBG_PATH)/%.o: $(SRC_PATH)/%.c*
|
||||||
|
$(CC) $(CCOBJFLAG) $(DBGFLAG) -o $@ $<
|
||||||
|
|
||||||
|
$(TARGET_DEBUG): $(OBJ_DEBUG)
|
||||||
|
$(CC) $(CCFLAG) $(DBGFLAG) $? -o $@
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: $(TARGET)
|
||||||
|
|
||||||
|
.PHONY: debug
|
||||||
|
debug: $(TARGET_DEBUG)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
@echo CLEAN $(CLEAN_LIST)
|
||||||
|
@rm -f $(CLEAN_LIST)
|
||||||
|
|
||||||
|
.PHONY: distclean
|
||||||
|
distclean:
|
||||||
|
@echo CLEAN $(DISTCLEAN_LIST)
|
||||||
|
@rm -f $(DISTCLEAN_LIST)
|
17
README.md
17
README.md
|
@ -4,3 +4,20 @@ Generates an M17 RF stream for Codec2-encoded speech files ('c2enc' output).
|
||||||
**M17_RF_streamgen.c** - main program. Just a sketch right now.
|
**M17_RF_streamgen.c** - main program. Just a sketch right now.
|
||||||
|
|
||||||
**dummy.c** - can generate a pseudorandom bitstream with legitimate sync patterns. This can be used to check receivers.
|
**dummy.c** - can generate a pseudorandom bitstream with legitimate sync patterns. This can be used to check receivers.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
```
|
||||||
|
make
|
||||||
|
```
|
||||||
|
|
||||||
|
# Nomenclature
|
||||||
|
|
||||||
|
# Example
|
||||||
|
This example records local audio and generates a M17-compliant RF stream into
|
||||||
|
a file. Codec2 and SoX need to be installed.
|
||||||
|
|
||||||
|
```
|
||||||
|
rec -t raw -r 8000 --buffer 2048 -e signed-integer -b 16 -c 1 - | \
|
||||||
|
c2enc 3200 - - | m17enc DL1FROM DL1TO - out.raw
|
||||||
|
```
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -2,6 +2,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
#define LEAD_PREAM 40 //first (lead) preamble length in ms
|
#define LEAD_PREAM 40 //first (lead) preamble length in ms
|
||||||
|
|
||||||
|
@ -39,6 +40,7 @@ uint8_t type_2[500]; //type-2 unpacked bits
|
||||||
uint8_t type_3[384];
|
uint8_t type_3[384];
|
||||||
uint8_t type_4[384];
|
uint8_t type_4[384];
|
||||||
FILE *f_out;
|
FILE *f_out;
|
||||||
|
FILE *f_in;
|
||||||
|
|
||||||
//Takes an ASCII callsign in a null terminated char* and encodes it using base 40.
|
//Takes an ASCII callsign in a null terminated char* and encodes it using base 40.
|
||||||
//Returns -1 (all Fs) if the provided callsign is longer than 9 characters, which
|
//Returns -1 (all Fs) if the provided callsign is longer than 9 characters, which
|
||||||
|
@ -165,15 +167,16 @@ int main(int argc, char *argv[])
|
||||||
uint16_t type=(1<<0)|(0b10<<1); //type indicator - stream, voice, codec2 3200bps, no encryption
|
uint16_t type=(1<<0)|(0b10<<1); //type indicator - stream, voice, codec2 3200bps, no encryption
|
||||||
uint8_t nonce[16]={0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
uint8_t nonce[16]={0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0};
|
||||||
|
|
||||||
if(argc==4)
|
if(argc==5)
|
||||||
{
|
{
|
||||||
dest_addr.val=encode_callsign_base40(argv[2]);
|
// link setup
|
||||||
src_addr.val=encode_callsign_base40(argv[3]);
|
dest_addr.val=encode_callsign_base40(argv[1]);
|
||||||
|
src_addr.val=encode_callsign_base40(argv[2]);
|
||||||
|
|
||||||
printf("DEST\t0x%012llX\n", dest_addr.val);
|
printf("DEST\t0x%012llX\n", dest_addr.val);
|
||||||
printf("SRC \t0x%012llX\n", src_addr.val);
|
printf("SRC \t0x%012llX\n", src_addr.val);
|
||||||
|
|
||||||
f_out=fopen(argv[1], "wb");
|
f_out=fopen(argv[4], "wb");
|
||||||
|
|
||||||
//preamble
|
//preamble
|
||||||
for(uint16_t i=0; i<(LEAD_PREAM*9600)/1000; i++)
|
for(uint16_t i=0; i<(LEAD_PREAM*9600)/1000; i++)
|
||||||
|
@ -207,13 +210,41 @@ int main(int argc, char *argv[])
|
||||||
//convolutionally encode type-1 to type-2
|
//convolutionally encode type-1 to type-2
|
||||||
;
|
;
|
||||||
|
|
||||||
|
// frames
|
||||||
|
if(!strcmp(argv[3], "-"))
|
||||||
|
{
|
||||||
|
f_in = stdin;
|
||||||
|
} else {
|
||||||
|
f_in = fopen(argv[1], "rb");
|
||||||
|
|
||||||
|
if(f_in == NULL)
|
||||||
|
{
|
||||||
|
printf("No valid input data to work with\n");
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t payload[16];
|
||||||
|
size_t bytes = 0;
|
||||||
|
|
||||||
|
while(1)
|
||||||
|
{
|
||||||
|
bytes = fread(payload, 1, 16, f_in);
|
||||||
|
fwrite(payload, 1, 16, f_out);
|
||||||
|
|
||||||
|
if(bytes < 16)
|
||||||
|
if(feof(f_in)) break;
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(f_in);
|
||||||
fclose(f_out);
|
fclose(f_out);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
printf("Not enough params\n");
|
printf("Invalid number of params\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
Loading…
Reference in New Issue