#!/usr/bin/env python # Notes: # # This is a simple example program for excercising the rx320_tune class # module code. A database file from my graphical tuning utility # called 'RX-320.320' is supplied for testing purposes. # import string import sys from time import sleep def runit(): # These should come from elsewere eventually. Hard coded for testing. # SET ME ||||||||||||||||||| # ------ vvvvvvvvvvvvvvvvvvv db_file = './RX-320.320' # what file? lines_o_interest = [0,1,2,4,5,9,11,10] # what lines to tune? desired_volume = '23' #'63' is low, '0' is max. sleep_time = 3 # Seconds to hold on station. #------ ^^^^^^^^^^^^^^^^^^^ # ||||||||||||||||||| # Import. May have to set PYTHONPATH if not in CWD or # not in distribution install location. import rx320_tune # Instantiate. Since serial port is currently hard-coded, # and locking is not implemented in version # 0.9.0, there is nothing to pass here. rx320_obj = rx320_tune.Rx320() # Suck in the whole file to a list since the file is small... dbfh = open(db_file,'r') db_list = [] for line in dbfh.readlines(): db_list.append(line) dbfh.close() # Loop through all stations desired (once)... for line_o_interest in lines_o_interest: # Assign Values... tune_params_dict = {} tune_params_dict['freq'] = db_list[line_o_interest].split(',')[1] tune_params_dict['mode'] = db_list[line_o_interest].split(',')[2] tune_params_dict['bwf'] = db_list[line_o_interest].split(',')[3] tune_params_dict['agc'] = db_list[line_o_interest].split(',')[4] tune_params_dict['pbt'] = db_list[line_o_interest].split(',')[6] # Set volume too (Note 'lvol' is line volume.) tune_params_dict['svol'] = desired_volume # Try to set vals, and show errors if failure. er = rx320_obj.update_state(tune_params_dict) if er[0] != 0: print "Error(s) durring 'update_state' call" print er[1] sys.exit(0) # Burn the current tune to the radio... rx320_obj.burn() # Sleep for a time... sleep(sleep_time) # See Python reference matierial if you don't know what this means... if __name__ == '__main__': runit()