Blame view

redpitaya/server/server.py 1.13 KB
9d344927e   bmarechal   first commit
1
  #!/usr/bin/env python
ed4b2fee6   bmarechal   minor fixes
2

9d344927e   bmarechal   first commit
3
4
5
  import socket
  from thread import start_new_thread
  import liboscimp_fpga
21598fce1   bmarechal   add nco HW config
6
  ###########################################################   
9d344927e   bmarechal   first commit
7
8
9
10
11
12
13
14
  def clientThread(conn, addr):
      print('Open connection from ' + addr[0] + ':' + str(addr[1]) + '
  ')
      while True:
          data = ''
          while '
  ' not in data:
              data += conn.recv(8)
9d344927e   bmarechal   first commit
15
16
17
18
19
20
21
22
          recv = data.split(';')
          if recv[0] == "add_const_set_offset":
              try:
                  liboscimp_fpga.add_const_set_offset(recv[1], int(recv[2]))
              except:
                  pass
          if recv[0] == "nco_counter_send_conf":
              try:
21598fce1   bmarechal   add nco HW config
23
                  liboscimp_fpga.nco_counter_send_conf(recv[1], int(recv[2]), int(recv[3]), int(recv[4]), int(recv[5]), int(recv[6]), int(recv[7]))
9d344927e   bmarechal   first commit
24
              except:
21598fce1   bmarechal   add nco HW config
25
26
27
                   pass
  
  ###########################################################
9d344927e   bmarechal   first commit
28

ed4b2fee6   bmarechal   minor fixes
29
30
31
  ctrl_sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  ctrl_sock.bind(('', 1001))
  ctrl_sock.listen(10)
9d344927e   bmarechal   first commit
32

ed4b2fee6   bmarechal   minor fixes
33
34
35
36
37
38
  try:
      while True:
          conn, addr = ctrl_sock.accept()
          start_new_thread(clientThread ,(conn, addr,))
  except KeyboardInterrupt:
      ctrl_sock.close()