1+ #=======================================================================================
2+ #This is an example code for RFExplorer python functionality.
3+ #Contributed by https://github.com/xiaolu1990 - check with author for support
4+ #=======================================================================================
15#try:
26# while True:
37# input_value = input("please enter [G] for next step, [Q] for quit: ")
@@ -32,13 +36,13 @@ def PrintPeak(objAnalazyer):
3236 fCenterFreq = objSweepTemp .GetFrequencyMHZ (nStep ) #Get frequency of the peak
3337
3438 print ("Sweep[" + str (nIndex )+ "]: Peak: " + "{0:.3f}" .format (fCenterFreq ) + "MHz " + str (fAmplitudeDBM ) + "dBm" )
35-
39+
3640 return fAmplitudeDBM
3741#---------------------------------------------------------
3842# global variables and initialization
3943#---------------------------------------------------------
4044
41- SERIALPORT = None #serial port identifier, use None to autodetect
45+ SERIALPORT = None #serial port identifier, use None to autodetect
4246BAUDRATE = 500000
4347
4448objRFE = RFExplorer .RFECommunicator () #Initialize object and thread
@@ -51,9 +55,8 @@ def PrintPeak(objAnalazyer):
5155
5256try :
5357 #Find and show valid serial ports
54- objRFE .GetConnectedPorts ()
55-
56-
58+ objRFE .GetConnectedPorts ()
59+
5760 #Connect to available port
5861 if (objRFE .ConnectPort (SERIALPORT , BAUDRATE )):
5962 #Reset the unit to start fresh
@@ -75,15 +78,15 @@ def PrintPeak(objAnalazyer):
7578 sample_value = []
7679 objRFE .ResetInternalBuffers ()
7780 input_value = input ("please enter [G] for next step, [Q] for quit: " )
78- if input_value == "G" :
81+ if input_value == "G" :
7982 #If object is an analyzer, we can scan for received sweeps
80- if (objRFE .IsAnalyzer ()):
83+ if (objRFE .IsAnalyzer ()):
8184 print ("Receiving data..." )
8285 #Process until we complete scan time
8386 nLastDisplayIndex = 0
8487 startTime = datetime .now ()
85- while ((datetime .now () - startTime ).seconds < TOTAL_SECONDS ):
86- #Process all received data from device
88+ while ((datetime .now () - startTime ).seconds < TOTAL_SECONDS ):
89+ #Process all received data from device
8790 objRFE .ProcessReceivedString (True )
8891 #Print data if received new sweep only
8992 if (objRFE .SweepData .Count > nLastDisplayIndex ):
@@ -108,4 +111,4 @@ def PrintPeak(objAnalazyer):
108111#---------------------------------------------------------
109112
110113#objRFE.Close() #Finish the thread and close port
111- objRFE = None
114+ objRFE = None
0 commit comments