'GUI not starting when trying to display a console message
I have managed to get the response from the radio and I can read the current frequency into a console. Now I would like to display that output into a label or similar, without clicking on a button or something. I have a separate file with the GUI interface but if I try to display the output the GUI doesn't run. I have googled quite a lot but I can't figure out how yet, any help will be much appreciated. I have included the code to read from radio.
import serial
import time
comPort = 'COM4'
comBaud = 115200
icomCivAddress = 148
ser = serial.Serial(comPort, comBaud)
ser.setDTR(False) # Prevent TCVR cw send if USB key is set on DTR
ser.setRTS(False) # Prevent TCVR going transmit if USB key is set on RTS
def readFromIcom():
time.sleep(0.04)
b = bytearray()
while ser.inWaiting():
b = b + ser.read()
while b.count(b'\xfd') > 1:
del b[0:b.find(b'\xfd') + 1]
if len(b) > 0:
validMsg = bytes([254, 254, 224, icomCivAddress, 0, 253])
if b[0:5] == validMsg:
b = b[6:len(b)]
if len(b) > 0:
if b[0] == 254 and b[1] == 254 and b[-1] == 253:
return b
else:
b = bytearray()
else:
b = bytearray()
else:
if b[0] == 254 and b[1] == 254 and b[-1] == 253:
b = b
else:
b = bytearray()
return b
def writeToIcom(b):
s = ser.write(bytes([254, 254, icomCivAddress, 224]) + b + bytes([253]))
return readFromIcom()
def getFrequency():
b = writeToIcom(b'\x03')
c = ''
if len(b) > 0:
for a in reversed(b[5:9]):
c = c + '%0.2X' % a
if len(c) > 0:
if c[0] == '0':
c = c[0:len(c)] # To show the exact numbers position even if below 10Mhz need to put 0
return c
freq = 1
while freq == 1:
c = getFrequency()
print('Frequency: ' + c[0:1] + c[1:2] + "." + c[2:3] + c[3:4] + c[4:5] + "." + c[5:6] + c[6:7] + c[7:8])
else:
print('No response from Radio!')
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
