Python Development Environment Setup

These are the instructions for installing and configuring software to provide the best script development environment for Sutron Satlink 3 and XLink 500.

These instructions should only be followed if you plan on developing Python code. If all you wish to do is to load an existing Python script into the station, please see the following page: Loading a script and setup into Satlink 3 and XLink 500

Light weight Python coding may be done without installing the development environment. Please see Writing Measurement Scripts

The instructions are geared for a Windows PC. However, Sutron Python development may be done on other platforms too.

1. LinkComm

LinkComm is the program used to communicate with Satlink 3 and XLink 500. It sends Python scripts to Satlink 3 and XLink 500, configures the setup to invoke them, and it can test them as well. LinkComm also integrates into PyCharm, allowing a one-click script send and test.

Download LinkComm for Windows: http://www.sutron.com/documents/linkcomm-for-pc-2.zip LinkComm also runs on iOS and Android: http://www.sutron.com/product/linkcomm/

2. Git

Python source code examples are hosted on GitHub.

Git is version control software. It plugs nicely into PyCharm, simplifies installation, and allows for contribution to the Sutron Python GitHub project.

While you may download those examples through your browser, if you are planning on developing Python code, you really should get Git software.

2.1 Please choose one:

  • Either install Git or download the examples

A. Either Install Git

B. Or Download Examples

  • Go to https://github.com/SutronPyto/LinkPython
  • Download the example files (click Clone or download and choose Download ZIP)
  • Extract the downloaded files to a folder of your choice (e.g. “C:\pyto”)

3. Python

Python is freely available. It is required to run Python code on your PC.

  • Download https://www.python.org/downloads/
  • 6280cc16259545ac472a1a3fcafe952b
  • The latest version of Python is likely fine. We developed with 3.5.
  • Run the executable downloaded from python.org
  • Make sure to check the “Add Python to Path” option
  • Choose Install Now
  • If your computer requires administrative privileges to install programs, you may need to do a custom install and make sure to check box to install for all users.

e86ad1236df6be71408d6f25b3123830

You may verify installation is good and OS environment is setup by opening a command window (CMD) and typing in “python” and enter. You should see 3 arrow prompt show up indicating python is running. You can press Ctrl+Z to exit out of the python prompt.

4. PyCharm

PyCharm is an integrated development environment that makes it easier to code in Python.

- PyCharm may be used to write and debug Python code.
- PyCharm may also be used to load Python scripts into Satlink.
- PyCharm features Git integration, making it easy to access the example code and contribute to the Python libraries.

4.1 Install

  1. Download PyCharm from:
    Make sure to get the free community version.
  2. Run the downloaded file and complete PyCharm install with default options

3A. If you have installed Git, hook into the Sutron Python project on GitHub

- f42404ec67107a3ed5f3643108fe33d0
- Run PyCharm
- Choose Check out from Version Control -> Git
- d684229500f463377576feb0cdf551b1
- For the Directory, choose any local folder
- Click Clone
- At this point, the source code has been downloaded onto your PC.

3B. If you have downloaded the examples onto your computer (e.g. in “C:\pyto”):

- Run Pycharm
- Choose Create New Project
- f977daa87461360eeeeeec230b974bbc
- Browse over to the folder where the examples are (e.g. in “C:\pyto\LinkPython-master”)
- Click Create
- Choose Yes if asked to create a project from existing sources

4.2 Settings

- 19e6b54499021d93f9687bd29d09a91f
- Go to PyCharm -> File -> Settings -> Project -> Project Interpreter
- Check that the Python Interpreter says Python 3
- 39a99a6be278de8fa7b1dc41878b0d95
- The folders must be marked as source.
- Go to PyCharm -> File -> Settings -> Project -> Project Structure
- Right click pc folder and mark it as source
- Do the same for the src folder

4.3 Verification

Verify installation by running main.py
d1f2a5aa46686fb2dc0bc72e5bc845d3
- In the PyCharm Project window, expand the project, expand the pc folder, right click main.py and choose Run
- If all went well, PyCharm will say ‘All Tests Complete’.

5. Configure PyCharm to use LinkComm

The steps below will guide you through setting up LinkComm as an External Tool in PyCharm. Doing these steps will allow you to run your scripts on Satlink 3 and XLink 500 directly from PyCharm. This will also allow you to easily debug your code since any errors reported by Satlink 3 and XLink 500 will be turned into hyperlinks that jump directly to the line containing the error in your code.

5.1 Script load and test

ca557bade4290cf151b4ca76a024b9b6
1. PyCharm -> File -> Settings -> Tools -> External Tools
2. Create new tool (“+” icon)
3. Name it “Script load and test”
4. Set “Program” to LinkComm.exe path which is usually
"C:\Program Files (x86)\Sutron\LinkComm\LinkComm.exe"
5. Set “Arguments” to
--scripttest $FilePath$
6. Click Advanced Options
7. Set “Output filters” to
$FILE_PATH$, line $LINE$
8. Click OK

5.2 Script save

One more external tool needs to be created for saving scripts.

f977daa87461360e70a2bc230b974bbc
1. Copy the “Script load and test” just created (icon above external tools)
2. Rename it to “Script save”
3. Change the “Arguments” to
--scriptsave
4. Click OK

5.3 Test out the connection to LinkComm

Now, if you go to PyCharm -> Tools -> External Tools, you will see two new options:

  • “Script load and test” - this will send the currently open python file to Satlink 3 and XLink 500 and test it out.
  • “Script save” - this will permanently save the file last sent to Satlink 3 and XLink 500

5.4 Test out the connection to Satlink 3 and XLink 500

d810f7a197b8e701c5af872149e5d082
1. Power on the Sutron data logger
2. Connect to unit via USB
3. Run LinkComm and connect to the Sutron data logger (see manual for instructions).
4. Leave LinkComm running.
5. Run PyCharm and open the project.
6. In PyCharm, open alarm.py from the src folder
7. Go to PyCharm -> Tools -> External Tools -> Script load and test
8. Verify output window shows the file was tested on the Sutron data logger