-
Notifications
You must be signed in to change notification settings - Fork 12
Python Gui
With the VNA giving us much better results, a user friendly VNA GUI would be an ideal addition to this project. We set out to design our own GUI from scratch; however, Dr. Frohne did some research of his own and found an open source VNA GUI that was already complete and very user friendly. The GUI comes courtesy of Github user pavel-demin. The original design of the GUI won't inherently work for our VNA since the GUI is setup to communicate with an IP address as opposed to a serial port. We will need to modify the program to fit our project; this will require us to modify the python script that drives the program as well as the PyQT script that makes up the GUI.
In order to suit our needs, we needed to re-purpose the python coded GUI to first read from a serial port instead of an IP address, then we'll need to ensure we're communicating with our VNA. Our first step was to identify how the the program was communicating with an IP address. We found that the creator used a python package from PyQt5 called QtNetwork to communicate with network sockets: from PyQt5.QtNetwork import QAbstractSocket, QTcpSocket
. We found a package for serial port communication that worked well for us: from PyQt5.QtSerialPort import QSerialPort
. Now that we are using a new package for communication ports we need to change each instance of QtcpSocket: self.socket = qtcpsocket()
with QtSerialPort: self.serial = qserialport()
. This gave us the means to communicate with our VNA but we still couldn't input a COM port in the GUI. This was due to a IP validator in the initialization function:
# IP address validator
rx = QRegExp('^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$')
self.addrValue.setValidator(QRegExpValidator(rx, self.addrValue))
With this removed we can now select a comport as seen below.
Once we started to communicate with the serial port we found that we were receiving back a Qbytearray. We had to add in the Qbytearray class to handle the Qbytearray that was returned when the serial port is called to read the data.
We are using Qbytearray to handle the returned data, however the returned data is just a bytearray, so we might need to change all instances in the script from bytearray to Qbytearray so that way we're dealing with a Qbytearray. Another option is to convert the returned data into a Qbytearray. Whichever is easier.
After the Qbytearray returned data is dealt with, final debugging needs to be done to ensure all data is being handled correctly. we need to parse the data and store them into the respective containers that already exist in the gui