When I run the script in a terminal (using the commented out for statement at the end and), it seems to work fine. But when I run it with Tkinter, it typically works fine for the first iteration and on occasional iterations after that, but on the vast majority of iterations, the string received back from the radio is highly truncated. I typically get about 8 characters back rather than the expected 34.
I am doing this on a Win7 computer. A prior, virtually identical version on a Ubuntu machine worked well.
Does anybody have any suggestions about where I may be going wrong?
Thanks in advance.
- Code: Select all
from Tkinter import *
from ttk import *
from datetime import datetime
def readrig(): #retrievs rig parameters for display
rig = serial.Serial('COM1')
send = 'FEFE68E003FD' #Retrieve Frequency
received = rig.read(rig.inWaiting()).encode('hex')
receivedfreq = received[-6:-4] + received[-8:-6] + received[-10:-9] + '.' + received[-9:-8]
freqlabel.after(1000, readrig) #this is what causes freq etc. to repeatedly update
root = Tk()
freqframe = Frame(root)
freq = StringVar()
freqlabel = Label (freqframe, textvariable = freq, width = 7, anchor = CENTER, font = ("Helvetica", "50", "bold"))
freqlabel.pack(side = LEFT)
#for i in range(0, 9):