Commit 7ac1b86cfe0d0a398bb2b303cb320ca52a081fa6
1 parent
b1f2cb7de3
Exists in
master
TODO : kill unused threads
Showing 1 changed file with 0 additions and 2 deletions Inline Diff
redpitaya/server/server.py
#!/usr/bin/env python | 1 | 1 | #!/usr/bin/env python | |
import socket | 2 | 2 | import socket | |
from thread import start_new_thread | 3 | 3 | from thread import start_new_thread | |
import liboscimp_fpga | 4 | 4 | import liboscimp_fpga | |
5 | 5 | |||
ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | 6 | 6 | ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
ctrl_sock.bind(('', 1001)) | 7 | 7 | ctrl_sock.bind(('', 1001)) | |
ctrl_sock.listen(10) | 8 | 8 | ctrl_sock.listen(10) | |
9 | 9 | |||
def clientThread(conn, addr): | 10 | 10 | def clientThread(conn, addr): | |
print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '\n') | 11 | 11 | print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '\n') | |
while True: | 12 | 12 | while True: | |
data = '' | 13 | 13 | data = '' | |
while '\n' not in data: | 14 | 14 | while '\n' not in data: | |
data += conn.recv(8) | 15 | 15 | data += conn.recv(8) | |
if not data: | 16 | |||
break | 17 | |||
recv = data.split(';') | 18 | 16 | recv = data.split(';') | |
if recv[0] == "add_const_set_offset": | 19 | 17 | if recv[0] == "add_const_set_offset": | |
try: | 20 | 18 | try: | |
liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2])) | 21 | 19 | liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2])) | |
except: | 22 | 20 | except: | |
pass | 23 | 21 | pass | |
if recv[0] == "nco_counter_send_conf": | 24 | 22 | if recv[0] == "nco_counter_send_conf": | |
try: | 25 | 23 | try: | |
liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5])) | 26 | 24 | liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5])) | |
except: | 27 | 25 | except: | |
pass | 28 | 26 | pass | |
conn.close() | 29 | 27 | conn.close() | |
30 | 28 | |||
while 1: | 31 | 29 | while 1: |