def Handle_FTdx1200(): lSer=serial.Serial('/dev/cu.usbserial', 4800) # Open a Serial Port, and configure its Baud Rate. lSer.write('FA;'.encode()) # Tell FTdx-1200 to obtain 'FA' VFO-A Frequency. lFreq=lSer.read(11) # Retrieve the 'FA' Data lSer.flush() # Purge the Input Buffer of any Characters. lSer.write('MD0;'.encode()) # Tell FTdx-1200 to obtain 'MD' Module. lMode=lSer.read(5) # Retrieve the 'MD' Data lSer.flush() # Purge the Input Buffer of any Characters. lSer.write('PC;'.encode()) # Tell FTdx-1200 to obtain 'PC' lPower Output Value. lPower=lSer.read(6) # Retrieve the 'PC' Data lSer.close() # Close the Connection of the USB Serial Adapter. lFreq=lFreq[2:10] # Remove 'FA' and ending ';' lFreq=lFreq.decode("utf-8") # Without '.decode("utf-8")' 'lFreq' would be printed, #in the print Line below # "b'XXX', where XXX is the Value of lFreq. lPower=lPower[2:5] # Remove 'PC' and ending ';' #lPower=str(int(lPower)) # If 'lPower' is less than 100 a preceding '0' will appear. #This Code removes the preceding '0'. lPower=lPower.decode("utf-8") lMode=lMode[3:4] lMode=lMode.decode("utf-8") # Without '.decode("utf-8")' 'lMode' would be printed, #in the print Line below as "b'XXX', where XXX is the Value of lMode. if((lMode=='3') or (lMode=='7')): lMode='CW' elif((lMode=='1') or (lMode=='2')): lMode='PH' elif(lMode=='5'): lMode='AM' elif((lMode=='4') or (lMode=='B')): lMode='FM' elif((lMode=='8') or (lMode=='C')): lMode='DG' elif((lMode=='6') or (lMode=='9')): lMode='RY' else: lMode='---' return(lFreq, lMode, lPower)