This is untested, but give it a try. It uses the XML interface that is included in fldigi (and I think it was made so that you could do exactly what you are wanting to do!)
?
Make sure you have:
-
Python 3
-
pyserial
installed (pip install pyserial
)
-
Fldigi
running, in RTTY mode, with XML-RPC enabled
-
/dev/ttyUSB0
accessible, permissions set (you may need to add your user to the dialout
group)
?
Python script follows:
?
import xmlrpc.client
import serial
import time
# Connect to Fldigi XML-RPC
fldigi = xmlrpc.client.ServerProxy("http://localhost:7362")
# Configure serial port for ASR33
ser = serial.Serial(
? ? '/dev/ttyUSB0',
? ? baudrate=110, ? ? ? ? # ASR33 typical speed
? ? bytesize=serial.SEVENBITS,
? ? parity=serial.PARITY_NONE,
? ? stopbits=serial.STOPBITS_TWO,
? ? timeout=1
)
def main():
? ? print("Starting RTTY-to-ASR33 relay...")
? ? previous_text = ""
? ? try:
? ? ? ? while True:
? ? ? ? ? ? # Get current received text from Fldigi
? ? ? ? ? ? current_text = fldigi.main.get_rx_text()
? ? ? ? ? ? # Find new characters
? ? ? ? ? ? if current_text != previous_text:
? ? ? ? ? ? ? ? new_chars = current_text[len(previous_text):]
? ? ? ? ? ? ? ? for char in new_chars:
? ? ? ? ? ? ? ? ? ? if char.isprintable() or char in '\r\n':
? ? ? ? ? ? ? ? ? ? ? ? print(f"Sending: {repr(char)}")
? ? ? ? ? ? ? ? ? ? ? ? ser.write(char.encode('ascii', errors='ignore'))
? ? ? ? ? ? ? ? ? ? ? ? ser.flush()
? ? ? ? ? ? ? ? ? ? ? ? time.sleep(0.1) ?# Adjust for ASR33 mechanical response
? ? ? ? ? ? ? ? previous_text = current_text
? ? ? ? ? ? time.sleep(0.1) ?# Polling interval
? ? except KeyboardInterrupt:
? ? ? ? print("\nStopping...")
? ? finally:
? ? ? ? ser.close()
if __name__ == "__main__":
? ? main()
?