mirror of
https://github.com/DJ2LS/FreeDATA
synced 2024-05-14 08:04:33 +00:00
updated ptt and audio functions
This commit is contained in:
parent
68d0e70a61
commit
e3778c16d9
44
tnc/modem.py
44
tnc/modem.py
|
@ -166,25 +166,27 @@ class RF():
|
||||||
|
|
||||||
# --------------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------------------
|
||||||
def ptt_and_wait(self, state):
|
def ptt_and_wait(self, state):
|
||||||
|
static.PTT_STATE = state
|
||||||
|
|
||||||
if state:
|
if state:
|
||||||
static.PTT_STATE = True
|
|
||||||
self.my_rig.set_ptt(self.hamlib_ptt_type, 1)
|
self.my_rig.set_ptt(self.hamlib_ptt_type, 1)
|
||||||
#rigctld.ptt_enable()
|
#rigctld.ptt_enable()
|
||||||
ptt_togle_timeout = time.time() + 0.1
|
ptt_toggle_timeout = time.time() + 0.5
|
||||||
while time.time() < ptt_togle_timeout:
|
while time.time() < ptt_toggle_timeout:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
||||||
ptt_togle_timeout = time.time() + 0.5
|
ptt_toggle_timeout = time.time() + 0.5
|
||||||
while time.time() < ptt_togle_timeout:
|
while time.time() < ptt_toggle_timeout:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
static.PTT_STATE = False
|
|
||||||
self.my_rig.set_ptt(self.hamlib_ptt_type, 0)
|
self.my_rig.set_ptt(self.hamlib_ptt_type, 0)
|
||||||
#rigctld.ptt_disable()
|
#rigctld.ptt_disable()
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def play_audio(self):
|
def play_audio(self):
|
||||||
|
@ -192,16 +194,16 @@ class RF():
|
||||||
while True:
|
while True:
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
|
||||||
while len(self.streambuffer) > 0:
|
#while len(self.streambuffer) > 0:
|
||||||
time.sleep(0.01)
|
# time.sleep(0.01)
|
||||||
if len(self.streambuffer) > 0:
|
if len(self.streambuffer) > 0 and self.audio_writing_to_stream:
|
||||||
self.audio_writing_to_stream = True
|
self.streambuffer = bytes(self.streambuffer)
|
||||||
self.streambuffer = bytes(self.streambuffer)
|
|
||||||
|
|
||||||
# we need t wait a little bit until the buffer is filled. If we are not waiting, we are sending empty data
|
# we need t wait a little bit until the buffer is filled. If we are not waiting, we are sending empty data
|
||||||
time.sleep(0.1)
|
time.sleep(0.1)
|
||||||
self.stream_tx.write(self.streambuffer)
|
self.stream_tx.write(self.streambuffer)
|
||||||
self.streambuffer = bytes()
|
# clear stream buffer after sending
|
||||||
|
self.streambuffer = bytes()
|
||||||
|
|
||||||
self.audio_writing_to_stream = False
|
self.audio_writing_to_stream = False
|
||||||
# --------------------------------------------------------------------------------------------------------
|
# --------------------------------------------------------------------------------------------------------
|
||||||
|
@ -261,9 +263,10 @@ class RF():
|
||||||
##state_before_transmit = static.CHANNEL_STATE
|
##state_before_transmit = static.CHANNEL_STATE
|
||||||
##static.CHANNEL_STATE = 'SENDING_SIGNALLING'
|
##static.CHANNEL_STATE = 'SENDING_SIGNALLING'
|
||||||
|
|
||||||
self.ptt_and_wait(True)
|
while self.ptt_and_wait(True):
|
||||||
|
pass
|
||||||
self.audio_writing_to_stream = True
|
self.audio_writing_to_stream = True
|
||||||
|
|
||||||
# wait until audio has been processed
|
# wait until audio has been processed
|
||||||
while self.audio_writing_to_stream:
|
while self.audio_writing_to_stream:
|
||||||
time.sleep(0.01)
|
time.sleep(0.01)
|
||||||
|
@ -402,7 +405,8 @@ class RF():
|
||||||
|
|
||||||
# -------------- transmit audio
|
# -------------- transmit audio
|
||||||
|
|
||||||
self.ptt_and_wait(True)
|
while self.ptt_and_wait(True):
|
||||||
|
pass
|
||||||
# this triggers writing buffer to audio stream
|
# this triggers writing buffer to audio stream
|
||||||
# this way we are able to run this non blocking
|
# this way we are able to run this non blocking
|
||||||
# this needs to be optimized!
|
# this needs to be optimized!
|
||||||
|
|
Loading…
Reference in a new issue