mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
Delete test directory
This commit is contained in:
parent
66cf834bed
commit
e1f64e7512
5 changed files with 0 additions and 256 deletions
|
@ -1,64 +0,0 @@
|
|||
# TESTS
|
||||
|
||||
### TEST_RX.py
|
||||
|
||||
Receive string "HALLO" with a lot of debugging output
|
||||
```
|
||||
./TEST_TX.py | ./TEST_RX.py
|
||||
```
|
||||
Output should be:
|
||||
```
|
||||
SYNC
|
||||
INPUT PARSER: 1760
|
||||
INPUT LENGTH: 1760
|
||||
BUFFER LENGTH: 1848
|
||||
MODULATION LENGTH: 924
|
||||
SYNC
|
||||
b'HALLO\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x15S'
|
||||
INPUT PARSER: 1760
|
||||
INPUT LENGTH: 1760
|
||||
BUFFER LENGTH: 1848
|
||||
MODULATION LENGTH: 924
|
||||
SYNC
|
||||
INPUT PARSER: 1760
|
||||
```
|
||||
|
||||
### TEST_TX.py
|
||||
|
||||
Send string "HALLO"
|
||||
```
|
||||
./TEST_TX.py | ./freedv_data_raw_rx DATAC3 - - | hexdump -C
|
||||
```
|
||||
Output should be:
|
||||
```
|
||||
payload bytes_per_modem_frame: 30
|
||||
00000000 54 45 53 54 00 00 00 00 00 00 00 00 00 00 00 00 |TEST............|
|
||||
modem bufs processed: 22 output bytes: 30 output_frames: 1
|
||||
00000010 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |..............|
|
||||
0000001e
|
||||
```
|
||||
|
||||
|
||||
### Checksum comparison FREEDV vs CRCENGINE
|
||||
```
|
||||
|
||||
###################### CHECKSUM COMPARISON FREEDV VS CRCENGINE ########
|
||||
#https://crccalc.com
|
||||
|
||||
teststring = b'TEST'
|
||||
|
||||
|
||||
|
||||
# freedv crc16 checksum
|
||||
crctest2 = c_ushort(self.c_lib.freedv_gen_crc16(teststring, len(teststring)))
|
||||
print("FREEDV2: " + str(crctest2.value) + " = " + hex(crctest2.value))
|
||||
|
||||
|
||||
#Python crc16 checksum
|
||||
crc_algorithm = crcengine.new('crc16-ccitt-false') #load crc16 library
|
||||
crctest3 = crc_algorithm(teststring)
|
||||
print("CRCENGINE: " + str(crctest3) + " = " + hex(crctest3))
|
||||
|
||||
|
||||
#######################################################################
|
||||
```
|
111
test/TEST_RX.py
111
test/TEST_RX.py
|
@ -1,111 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Tue Dec 15 18:29:22 2020
|
||||
|
||||
@author: DJ2LS
|
||||
"""
|
||||
|
||||
|
||||
import ctypes
|
||||
from ctypes import *
|
||||
import pathlib
|
||||
|
||||
import binascii #required for string.to_bytes() function
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
modem = FreeDV() #Load FreeDV Class as "modem"
|
||||
|
||||
modem.Demodulate()
|
||||
|
||||
class FreeDV():
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.mode = 12 # define mode
|
||||
|
||||
libname = pathlib.Path().absolute() / "libcodec2.so"
|
||||
self.c_lib = ctypes.CDLL(libname) # Load FreeDV shared libary
|
||||
|
||||
self.freedv = self.c_lib.freedv_open(self.mode) #Set FreeDV waveform ( 10,11,12 --> DATA1-3 )
|
||||
|
||||
self.bytes_per_frame = int(self.c_lib.freedv_get_bits_per_modem_frame(self.freedv)/8) #get bytes per frame from selected waveform
|
||||
self.payload_per_frame = self.bytes_per_frame -2 #get frame payload because of 2byte CRC16 checksum
|
||||
self.n_max_modem_samples = self.c_lib.freedv_get_n_max_modem_samples(self.freedv)
|
||||
self.nin = self.c_lib.freedv_nin(self.freedv)
|
||||
|
||||
print("N MAX MODEM SAMPLES: " + str(self.n_max_modem_samples))
|
||||
print("NIN: " + str(self.nin))
|
||||
print("BYTES PER FRAME: " + str(self.bytes_per_frame))
|
||||
print("---------------------------------")
|
||||
|
||||
# MODULATION-IN OBJECT
|
||||
def ModulationIn(self):
|
||||
return (c_short * (self.n_max_modem_samples)) ##
|
||||
|
||||
|
||||
# Pointer for changing buffer data type
|
||||
def FrameBytes(self):
|
||||
return (c_ubyte * self.bytes_per_frame)
|
||||
|
||||
|
||||
# Modulate function which returns modulated data
|
||||
def Demodulate(self):
|
||||
|
||||
|
||||
nin = self.c_lib.freedv_nin(self.freedv)
|
||||
#while (self.c_lib.freedv_nin(self.freedv) == nin):
|
||||
#while sys.stdin.buffer != 0:
|
||||
while True:
|
||||
|
||||
samples = self.c_lib.freedv_nin(self.freedv)*2 ### MIT DER *2 funktioniert das irgendwie recht zuverlässig bei mode 5! Bei Mode 12 auch
|
||||
data_in = sys.stdin.buffer.read(samples)
|
||||
|
||||
|
||||
#buffer = bytearray(len(self.ModulationIn()())*sizeof(c_short)) # create empty byte array
|
||||
#buffer = bytearray(len(self.ModulationIn()())*self.n_max_modem_samples) # create empty byte array
|
||||
buffer = bytearray(self.n_max_modem_samples*2) # N MAX SAMPLES * 2
|
||||
buffer[:len(data_in)] = data_in # copy across what we have
|
||||
|
||||
self.ModulationIn()() #Create new ModulationIn Object
|
||||
modulation = self.ModulationIn()# get an empty modulation array
|
||||
modulation = modulation.from_buffer_copy(buffer) # copy buffer across and get a pointer to it.
|
||||
bytes_out = self.FrameBytes()() # initilize a pointer to where bytes will be outputed
|
||||
|
||||
nbytes = self.c_lib.freedv_rawdatarx(self.freedv, bytes_out, data_in) # Demodulated data and get number of demodulated bytes
|
||||
#self.nin = self.c_lib.freedv_nin(self.freedv)
|
||||
|
||||
|
||||
# ------------- SOME DEBUGGING OUTPUT
|
||||
#print("INPUT PARSER: " + str(samples))
|
||||
#print("INPUT LENGTH: " + str(len(data_in)))
|
||||
#print("BUFFER LENGTH: " + str(len(buffer)))
|
||||
#print("MODULATION LENGTH: " + str(len(modulation)))
|
||||
|
||||
#sync_state = self.c_lib.freedv_get_sync(self.freedv)
|
||||
#if sync_state > 0:
|
||||
# print("SYNC")
|
||||
#else:
|
||||
# print("NO SYNC")
|
||||
# -------------
|
||||
|
||||
|
||||
|
||||
# print data to terminal if nbytes == bytes_per_frame for selected mode
|
||||
if nbytes == self.bytes_per_frame:
|
||||
print(bytes(bytes_out))
|
||||
self.c_lib.freedv_set_sync(self.freedv, 0)
|
||||
|
||||
|
||||
#Stop loop until data input is empty
|
||||
#if len(data_in) == 0:
|
||||
# False
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
main()
|
|
@ -1,81 +0,0 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Created on Sun Dec 13 13:45:58 2020
|
||||
@author: DJ2LS
|
||||
"""
|
||||
|
||||
import ctypes
|
||||
from ctypes import *
|
||||
import pathlib
|
||||
|
||||
import binascii #required for string.to_bytes() function
|
||||
import sys
|
||||
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
modem = FreeDV() #Load FreeDV Class as "modem"
|
||||
|
||||
data = b'HALLO' #byte string which will be send
|
||||
|
||||
modem.Modulate(data) #Call Modulate function, which modulates data and prints it to the terminal
|
||||
|
||||
|
||||
class FreeDV():
|
||||
|
||||
def __init__(self):
|
||||
|
||||
self.mode = 12 # define mode
|
||||
|
||||
libname = pathlib.Path().absolute() / "libcodec2.so"
|
||||
self.c_lib = ctypes.CDLL(libname) # Load FreeDV shared libary
|
||||
|
||||
self.freedv = self.c_lib.freedv_open(self.mode) #Set FreeDV waveform ( 10,11,12 --> DATAC1-3 )
|
||||
|
||||
self.bytes_per_frame = int(self.c_lib.freedv_get_bits_per_modem_frame(self.freedv)/8) #get bytes per frame from selected waveform
|
||||
self.payload_per_frame = self.bytes_per_frame -2 #get frame payload because of 2byte CRC16 checksum
|
||||
self.n_tx_modem_samples = self.c_lib.freedv_get_n_tx_modem_samples(self.freedv)*2 #get n_tx_modem_samples which defines the size of the modulation object
|
||||
|
||||
# MODULATION-OUT OBJECT
|
||||
def ModulationOut(self):
|
||||
return (c_short * self.n_tx_modem_samples) ##
|
||||
|
||||
# Pointer for changing buffer data type
|
||||
def FrameBytes(self):
|
||||
return (c_ubyte * self.bytes_per_frame)
|
||||
|
||||
# Modulate function which returns modulated data
|
||||
def Modulate(self,data_out):
|
||||
|
||||
mod_out = self.ModulationOut()() # new modulation object and get pointer to it
|
||||
|
||||
data_list = [data_out[i:i+self.payload_per_frame] for i in range(0, len(data_out), self.payload_per_frame)] # split incomming bytes to size of 30bytes, create a list and loop through it
|
||||
data_list_length = len(data_list)
|
||||
for i in range(data_list_length): # LOOP THROUGH DATA LIST
|
||||
|
||||
if self.mode < 10: # don't generate CRC16 for modes 0 - 9
|
||||
|
||||
buffer = bytearray(self.bytes_per_frame) # use this if no CRC16 checksum is required
|
||||
buffer[:len(data_list[i])] = data_list[i] # set buffersize to length of data which will be send
|
||||
|
||||
if self.mode >= 10: #generate CRC16 for modes 10-12..
|
||||
|
||||
buffer = bytearray(self.payload_per_frame) # use this if CRC16 checksum is required ( DATA1-3)
|
||||
buffer[:len(data_list[i])] = data_list[i] # set buffersize to length of data which will be send
|
||||
|
||||
crc = c_ushort(self.c_lib.freedv_gen_crc16(bytes(buffer), self.payload_per_frame)) # generate CRC16
|
||||
crc = crc.value.to_bytes(2, byteorder='big') # convert crc to 2 byte hex string
|
||||
buffer += crc # append crc16 to buffer
|
||||
|
||||
|
||||
data = self.FrameBytes().from_buffer_copy(buffer) #change data format from bytearray to ctypes.u_byte and copy from buffer to data
|
||||
|
||||
self.c_lib.freedv_rawdatatx(self.freedv,mod_out,data) # modulate DATA and safe it into mod_out pointer
|
||||
|
||||
sys.stdout.buffer.write(mod_out) # print data to terminal for piping the output to other programs
|
||||
sys.stdout.flush() # flushing stdout
|
||||
|
||||
|
||||
main()
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in a new issue