Package: pyfldm
PyFLDMPython Fast Light Digital ModemA library to be used for interacting with and controlling the Fldigi application. Uses the Fldigi xmlrpc API to give the user programmatic control of Fldigi via python.ContentsInstallationFeaturesIssues and ContributionsLoggingUsing pyfldmList of all methodsInstallationpip install pyfldmTo use the headless feature (linux only)sudo apt install xvfbFeaturesAppMonitor for launching, stopping, and monitoring the running status of the Fldigi applicationClient for exercising all the Fldigi xmlrpc endpointsHeadless mode for linux to run fldigi purely via script with no Fldigi guiSee or change Fldigi configuration via AppMonitor.config_managerIssues and ContributionsI welcome bringing up any issues you encounter with PyFLDM. Either submit and issue on github (https://github.com/philliphall131/pyfldm/issues) or contact me directly
If you want to contribute, submit a pull request or feel free to contact me via github/emailLoggingpyfldm uses the built in python logging for all output *(except when print in the method name, like print_methods()). This is to avoid spamming users with unnecessary output unless desired. The user is responsible for setting up logging in whatever fashion they want, here is the example I use for all my sandboxing:import logging

pyfldm_logger = logging.getLogger('pyfldm')
pyfldm_logger.setLevel(logging.DEBUG)
console_handler1 = logging.StreamHandler()
console_handler1.setLevel(logging.DEBUG)
console_formatter1 = logging.Formatter('%(name)s - %(levelname)s - %(filename)s:%(lineno)d - %(message)s')
console_handler1.setFormatter(console_formatter1)
pyfldm_logger.addHandler(console_handler1)Using pyfldmBelow demonstrates some of the main usage with a few examples, but does not cover every possible use case1. Controlling the Application (start, stop, status)>>> from pyfldm.appmonitor import AppMonitor
>>> app = AppMonitor()
>>> app.start()
>>> app.is_running() # checks that Fldigi is a currently running process
True
>>> app.is_functional() # verifies that the xmlrpc interface is responsive
True
>>> result = app.stop() # asks fldigi to gracefully shut down, returns True if successfully stopped, otherwise False
>>> if not result:
...     app.kill()  # forcibly kills the process
>>> # Or use app.stop(force_if_unsuccessful=True) to force close if graceful shutdown not possible
>>> app.is_running()
False2. Using the XMLRPC APITo setup the client for use:# * assuming that Fldigi is already running
>>> from pyfldm.client import Client
>>> client = Client()For various ways to list available client methods, use the following example:# to get all the methods as a list of dictionaries
>>> methods = client.get_all_methods()
>>> print(methods)
[{'fldigi': ['config_dir', 'list', 'name', 'name_and_version', ...

# to print all the methods to stdout in a readable format:
>>> client.print_all_methods()
---------------------
client.fldigi methods
---------------------
fldigi.config_dir
fldigi.list
fldigi.name
...
 
# to print only the methods of a sub-section of fldigi xmlrpc
>>> client.text.print_methods()
---------------------
client.text methods
---------------------
text.add_tx
text.add_tx_bytes
text.clear_rx
...

# to get the methods of a sub-section of fldigi xmlrpc as a list
>>> client.text.get_methods()
>>> print(methods)
['add_tx', 'add_tx_bytes', 'clear_rx', 'clear_tx', 'get_rx', 'get_rx_data', 'get_rx_length', 'get_rxtx_data', 'get_tx_data']To use the various xmlrpc endpoint functions:The functions are grouped into sub-categories of related functionality. For example to access text manipulation in Fldigi, use client.text...., to use the high level, generic fldigi info, use client.fldigi..., see some examples below:# * assuming that Fldigi is already running
>>> from pyfldm.client import Client
>>> client = Client()
>>> client.fldigi.version()
4.1.26
>>> client.text.add_tx("some text")
# the fldigi Tx widget should have "some text" populated and ready to send upon triggering transmit

# to trigger transmit
>>> client.main.tx()

# to stop transmitting and revert to receive mode
>>> client.main.rx()3. Using pyfldm with fldigi headless**** Only on linux, must have xvfb installed ****from pyfldm.appmonitor import AppMonitor
app = AppMonitor(headless=True)4. Using pyfldm to view and change Fldigi configurations**** Warning: this does not type check config values, be sure you know the correct value to use if setting values ****This functionality interacts with the config file that saves all of Fldigi's settingsTo get and set config items:>>> from pyfldm.appmonitor import AppMonitor
>>> app = AppMonitor()

# to search for a particular config item using a part or whole of the config name:
>>> app.config_manager.search_config('tx')
['SHOW_TX_TIMER', 'TX_TIMEOUT', 'RSIDTXMODESEXCLUDE',  ...

# to get the value of a stored config item
>>> app.config_manager.get_config('TX_TIMEOUT')
5

# to set the value of a stored config item (returns True if successful)
>>> app.config_manager.set_config('CONFIRMEXIT', 1)
TrueTo determine which config item is associated with a specific action in Fldigi, the following functionality will allow you to monitor changes to config as you make the change in the Fldigi GUI and report back the exact config item thats been changed. To use this, you must enable monitoring config updates in the AppMonitor and the python script must be running while making changes in the Fldigi GUI.Example:>>> from pyfldm.appmonitor import AppMonitor
# Use either this:
>>> app = AppMonitor(monitor_config_updates=True)

# or this:
>>> app = AppMonitor()
>>> app.config_manager.start_listening()

# if running from a script, ensure the script runs long enough for you to make config changes, ie time.sleep()
>>> import time
>>> time.sleep(120)

# Open Fldigi via the GUI and make a change to any config item from Configure > Config Dialog

The TOOLTIPS value has changed from 1 to 0
The CONFIRMEXIT value has changed from 1 to 0

# Now you have the exact names to use for getting/setting config items via app.config_manager.set_config/get_configMethods Listclient.fldigifldigi.config_dirfldigi.listfldigi.namefldigi.name_and_versionfldigi.terminatefldigi.versionfldigi.version_structclient.ioconfigioconfig.enable_arqioconfig.enable_kissioconfig.in_useclient.mainmain.abortmain.get_afcmain.get_char_ratesmain.get_char_timingmain.get_frequencymain.get_lockmain.get_max_macro_idmain.get_reversemain.get_rsidmain.get_squelchmain.get_squelch_levelmain.get_status1main.get_status2main.get_trx_statemain.get_trx_statusmain.get_tx_timingmain.get_txidmain.get_wf_sidebandmain.inc_frequencymain.inc_squelch_levelmain.run_macromain.rxmain.rx_onlymain.rx_txmain.set_afcmain.set_frequencymain.set_lockmain.set_reversemain.set_rsidmain.set_squelchmain.set_squelch_levelmain.set_txidmain.set_wf_sidebandmain.toggle_afcmain.toggle_lockmain.toggle_reversemain.toggle_rsidmain.toggle_squelchmain.toggle_txidmain.tunemain.txclient.modemmodem.get_afc_search_rangemodem.get_bandwidthmodem.get_carriermodem.get_idmodem.get_max_idmodem.get_namemodem.get_namesmodem.get_olivia_bandwidthmodem.get_olivia_tonesmodem.get_qualitymodem.increment_afc_search_rangemodem.increment_bandwidthmodem.increment_carriermodem.search_downmodem.search_upmodem.set_afc_search_rangemodem.set_bandwidthmodem.set_by_idmodem.set_by_namemodem.set_carriermodem.set_olivia_bandwidthmodem.set_olivia_tonesclient.navtexnavtex.get_messagenavtex.send_messageclient.rigrig.get_bandwidthrig.get_bandwidthsrig.get_moderig.get_modesrig.get_namerig.get_notchrig.release_controlrig.set_bandwidthrig.set_bandwidthsrig.set_frequencyrig.set_moderig.set_modesrig.set_namerig.set_pwrmeterrig.set_smeterrig.take_controlclient.spotspot.get_autospot.get_pskrep_countspot.set_autospot.toggle_autoclient.texttext.add_txtext.add_tx_bytestext.clear_rxtext.clear_txtext.get_rxtext.get_rx_datatext.get_rx_lengthtext.get_rxtx_datatext.get_tx_dataclient.wefaxwefax.end_receptionwefax.get_received_filewefax.send_filewefax.set_adif_logwefax.set_max_lineswefax.set_tx_abort_flagwefax.skip_aptwefax.skip_phasingwefax.state_string