Writing Transmission Formatting Python Scripts ######################################################### The transmission message may be modified using Python scripts. This tutorial will show you how. You do not need to have the full Python development environment setup for this. `LinkComm <|link_linkcomm_for_win|>`_ will suffice. The manual has crucial information about how scripts work. |link_satlink_manual| Please take the time to read the chapter on Python scripts. Without that knowledge, it is going to be difficult to work with |short_port_name| scripts. Appending Data to Transmissions ******************************************* In this example, we want to append a specific data string to the transmission message. Suppose that the system currently uses CSV formatting to transmit data, making the transmission message look like this: :: 04/02/2018,09:00:00,STAGE,20.501 04/02/2018,09:00:00,TEMP,23.5 Our goal is to append the following fixed string to the message: :: Little Creek A21938 Such that the final message is :: 04/02/2018,09:00:00,STAGE,20.501 04/02/2018,09:00:00,TEMP,23.5 Little Creek A21938 ------------ These are the steps that the station will take: - The system will create a standard transmission message based on the setup - The Python script will be invoked - The standard message will be provided to the script - The script will modify the message - The script will return the modified message to the system - The system will transmit the modified message ------------ Python code would look like this: .. code-block:: python @TXFORMAT def append_info(standard): return standard + "Little Creek A21938" - Note that all transmission formatting scripts must have the @TXFORMAT descriptor. Here is the completed Python script: :download:`append_info.py<./setup_script/append_info.py>` ------------ Now that we have the script, we need to integrate it into the setup using LinkComm. * Run LinkComm ------------ |LinkCommSL3Connect| * Choose Station Type XLink 500 * Click Work offline. ------------ |LinkCommOpenScript| * Go to the Script tab of LinkComm and open the append_info script file. ------------ |LinkCommTxFormat| * Go to the Telemetry tab of LinkComm. * Setup the Transmission format: * Set Tx Format CSV * Check Custom Script Format * Choose append_info as the Script Format Function Completed setup file: - :download:`append info<./setup_script/append_info_setup.txt>` That completes this example. For more example scripts, please see - :doc:`examples/txformat_simple` - :doc:`examples/dga` - :doc:`examples/log_txformat` - :doc:`examples/NFDRS_TX_Format` .. |LinkCommSL3Connect| image:: ./media/image30.png :width: 5.00000in :height: 3.70000in .. |LinkCommOpenScript| image:: ./media/image47.png :width: 6.00000in :height: 4.50000in .. |LinkCommTxFormat| image:: ./media/image48.png :width: 6.00000in :height: 4.50000in