public:radio:radio_database:ar_7030
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| public:radio:radio_database:ar_7030 [07/08/22 07:53 BST] – [3. Remote Control] john | public:radio:radio_database:ar_7030 [06/03/25 06:49 GMT] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 2: | Line 2: | ||
| - | ====== AR7030 ====== | + | ====== |
| ===== - Faults/ | ===== - Faults/ | ||
| Line 73: | Line 73: | ||
| ===== - Remote Control ===== | ===== - Remote Control ===== | ||
| - | The Python module used in [[https:// | + | The Python module used in [[https:// |
| ++++ Generic aor.py | | ++++ Generic aor.py | | ||
| Line 1309: | Line 1309: | ||
| ++++ | ++++ | ||
| + | |||
| + | ++++ New (July 2022) server with AR7030 filter selection | | ||
| + | |||
| + | <file python ar_server_filter.py> | ||
| + | #from aor import * | ||
| + | from aor_filter import * | ||
| + | #from icom import * | ||
| + | from conf import * | ||
| + | #from m710 import * | ||
| + | import SocketServer | ||
| + | import time | ||
| + | |||
| + | try: | ||
| + | import readline | ||
| + | except: | ||
| + | pass | ||
| + | |||
| + | lock = threading.Lock() | ||
| + | |||
| + | radios = [] | ||
| + | |||
| + | |||
| + | |||
| + | #r1 = Icom(n1, a1, cal1) | ||
| + | # | ||
| + | |||
| + | #r2 = m710(n4) | ||
| + | # | ||
| + | |||
| + | #r2 = Icom(n2, a2, cal2) | ||
| + | # | ||
| + | |||
| + | #r3 = Ar7030(n3) | ||
| + | # | ||
| + | |||
| + | r1 = Ar7030(n3) | ||
| + | radios.append(n3) | ||
| + | |||
| + | print radios | ||
| + | #print r1.digi_off() | ||
| + | |||
| + | #print r2.remote_on() | ||
| + | |||
| + | def count_radios(): | ||
| + | count = len(radios) | ||
| + | return count | ||
| + | |||
| + | |||
| + | def list_radios(): | ||
| + | radiolist = "" | ||
| + | for n in range(0, len(radios)): | ||
| + | r = radios[n] | ||
| + | radiolist += (r + " ") | ||
| + | return radiolist | ||
| + | |||
| + | |||
| + | def write_file(text): | ||
| + | filename = ' | ||
| + | f = open(filename, | ||
| + | timenow = time.strftime(" | ||
| + | log = " " | ||
| + | f.write(log) | ||
| + | f.close() | ||
| + | |||
| + | |||
| + | def write_con(text): | ||
| + | filename = ' | ||
| + | f = open(filename, | ||
| + | timenow = time.strftime(" | ||
| + | log = " " | ||
| + | f.write(log) | ||
| + | f.close() | ||
| + | |||
| + | |||
| + | # The Server | ||
| + | class ThreadedRequestHandler(SocketServer.StreamRequestHandler): | ||
| + | def handle(self): | ||
| + | # we find the current thread for the client connection just set up, to | ||
| + | # use in the log file | ||
| + | cur_thread = threading.currentThread() | ||
| + | # log the new connection details | ||
| + | write_con(" | ||
| + | # print to the server' | ||
| + | print self.client_address | ||
| + | # loop to handle client requests.... | ||
| + | while True: | ||
| + | # using StreamRequestHandler means our input from the client | ||
| + | # is " | ||
| + | # we read a line at a time, using readline() | ||
| + | cmd = self.rfile.readline().lower() | ||
| + | # to keep things clean, we remove any characters that aren't | ||
| + | # " | ||
| + | # these are between 32 and 127 in the ASCII table | ||
| + | # we look at each character, and then make a new word by | ||
| + | # .join()ing each accepted character with no space in between | ||
| + | asccmd = "" | ||
| + | # we make a list called " | ||
| + | # will be inspected by various functions | ||
| + | words = asccmd.split() | ||
| + | # If a client uses sock.close() itself, to disconnect, it appears that | ||
| + | # we read a continuous stream of "" | ||
| + | # socket, which puts CPU to 100%. | ||
| + | # | ||
| + | # The " | ||
| + | # way to keep the connection up for multiple commands. | ||
| + | # | ||
| + | # Further connection are accepted due to the Threaded nature of the server. | ||
| + | # The CPU load is unacceptable though | ||
| + | # HACK ?>>>>> | ||
| + | # Looking for "" | ||
| + | # the connection from the server end (even though the client has | ||
| + | # gone) cures this. | ||
| + | if cmd == "": | ||
| + | break | ||
| + | else: | ||
| + | pass | ||
| + | # if the words list is empty, go back and get more input | ||
| + | if not words: | ||
| + | continue | ||
| + | # we have input.... | ||
| + | # filter based on the first word - these are the | ||
| + | # pre-set commands the server will accept | ||
| + | # the client wants to know the currently available | ||
| + | # radio names - held in the variable " | ||
| + | elif words[0] == " | ||
| + | self.wfile.write(rnames) | ||
| + | # words[-1] (the last word in the list) will always be the | ||
| + | # radio name. We give the variable " | ||
| + | # identifying which radio object to apply the method to | ||
| + | elif words[0] == " | ||
| + | count = count_radios() | ||
| + | self.wfile.write(count) | ||
| + | elif words[0] == " | ||
| + | ident_text = " | ||
| + | radio_list = list_radios() | ||
| + | self.wfile.write(ident_text + " | ||
| + | | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | filt_no = words[1] | ||
| + | newfilt = my_radio.set_filter(filt_no) | ||
| + | | ||
| + | self.wfile.write(newfilt) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[1]) | ||
| + | filt = my_radio.get_filter() | ||
| + | self.wfile.write(filt) | ||
| + | |||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | mode = my_radio.get_mode() | ||
| + | self.wfile.write(mode) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | freq = words[1] | ||
| + | freq = my_radio.get_freq() | ||
| + | self.wfile.write(freq) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | mode = words[1] | ||
| + | newmode = my_radio.set_mode(mode) | ||
| + | self.wfile.write(newmode) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | try: | ||
| + | freq = float(words[1]) | ||
| + | newfreq = my_radio.set_freq(freq) | ||
| + | self.wfile.write(newfreq) | ||
| + | except ValueError: | ||
| + | #freq = float(my_radio.get_freq()) | ||
| + | self.wfile.write(" | ||
| + | | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | smeter = round(float(my_radio.get_smeter()), | ||
| + | self.wfile.write(smeter) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | s = my_radio.get_s() | ||
| + | self.wfile.write(s) | ||
| + | elif words[0] == " | ||
| + | radios = list_radios() | ||
| + | self.wfile.write(radios) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | preamp = my_radio.get_pre() | ||
| + | self.wfile.write(preamp) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | preamp = my_radio.pre_on() | ||
| + | self.wfile.write(preamp) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | preamp = my_radio.pre_2_on() | ||
| + | self.wfile.write(preamp) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | preamp = my_radio.pre_off() | ||
| + | self.wfile.write(preamp) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | att = my_radio.get_att() | ||
| + | self.wfile.write(att) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | att = my_radio.att_on() | ||
| + | self.wfile.write(att) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | att = my_radio.att_off() | ||
| + | self.wfile.write(att) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | tune = my_radio.tune() | ||
| + | self.wfile.write(tune) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | pwr = my_radio.get_pwr() | ||
| + | self.wfile.write(pwr) | ||
| + | elif words[0] == " | ||
| + | my_radio = eval(words[-1]) | ||
| + | spwr = words[1] | ||
| + | pwr = my_radio.set_pwr(spwr) | ||
| + | self.wfile.write(pwr) | ||
| + | elif words[0] == " | ||
| + | write_con(" | ||
| + | self.wfile.write(" | ||
| + | break | ||
| + | else: # nothing in words[0] matches a pre-set command.... | ||
| + | write_file(" | ||
| + | self.wfile.write(" | ||
| + | |||
| + | |||
| + | class ThreadedIcomServer(SocketServer.ThreadingMixIn, | ||
| + | pass | ||
| + | |||
| + | |||
| + | if __name__ == ' | ||
| + | # define the lock to be used on the serial port access | ||
| + | lock = threading.Lock() | ||
| + | |||
| + | # address ('' | ||
| + | address = ('', | ||
| + | server = ThreadedIcomServer(address, | ||
| + | server.allow_reuse_address = True | ||
| + | |||
| + | # define that the server will be threaded, and will serve " | ||
| + | t = threading.Thread(target=server.serve_forever) | ||
| + | # start the server thread | ||
| + | t.start() | ||
| + | |||
| + | write_con( | ||
| + | " | ||
| + | </ | ||
| + | ++++ | ||
| + | |||
| + | ===== Documentation ===== | ||
| + | |||
| + | * {{ : | ||
| + | * {{ : | ||
public/radio/radio_database/ar_7030.1659855184.txt.gz · Last modified: (external edit)
