removed unnecessary line

This commit is contained in:
DJ2LS 2020-12-22 12:58:25 +01:00 committed by GitHub
parent b5fc5b6275
commit da1046605e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 25 deletions

View file

@ -15,9 +15,6 @@ import binascii #required for string.to_bytes() function
import sys
import base64
def main():
modem = FreeDV() #Load FreeDV Class as "modem"
@ -27,11 +24,13 @@ def main():
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(12) #Set FreeDV waveform ( 10,11,12 --> DATA1-3 )
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
@ -46,13 +45,12 @@ class FreeDV():
# MODULATION-IN OBJECT
def ModulationIn(self):
return (c_short * (self.n_max_modem_samples)) ##
#return (c_short * 40000)
#return (c_short * (self.nin))
# Pointer for changing buffer data type
def FrameBytes(self):
return (c_ubyte * self.bytes_per_frame)
#return (c_ubyte * 2)
# Modulate function which returns modulated data
def Demodulate(self):
@ -65,8 +63,6 @@ class FreeDV():
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
@ -74,31 +70,32 @@ class FreeDV():
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()()
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)
self.nin = self.c_lib.freedv_nin(self.freedv)
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")
# print data to terminal if bytes have been demodulated
# -------------
# print data to terminal if nbytes > 0
if nbytes > 0:
print(bytes(bytes_out))
#print(nbytes)
#print(bytes(bytes_out))
#Stop loop until data input is empty
if len(data_in) == 0:

View file

@ -19,9 +19,8 @@ def main():
modem = FreeDV() #Load FreeDV Class as "modem"
data = b'HALLO' #byte string which will be send
modulated_data = modem.Modulate(data) #Call Modulate function, which modulates data and prints it to the terminal
modem.Modulate(data) #Call Modulate function, which modulates data and prints it to the terminal
class FreeDV():
@ -70,9 +69,8 @@ class FreeDV():
crc = crc.value.to_bytes(2, byteorder='big') # convert crc to 2 byte hex string
buffer += crc # append crc16 to buffer
#print(self.bytes_per_frame)
#print(buffer)
data = self.FrameBytes().from_buffer_copy(buffer) #change data format from bytearray to ctypes.u_byte
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