SHARE
TWEET

kxc1_subscriber

DeaD_EyE Mar 7th, 2019 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env python3
  2.  
  3. """
  4. Subscriber for: https://pastebin.com/yECG4APX
  5. """
  6.  
  7. import zmq
  8. import struct
  9.  
  10.  
  11. IQ_STRUCT = struct.Struct('>512h')
  12.  
  13.  
  14. def parse(data):
  15.     iq = IQ_STRUCT.unpack(data)
  16.     return iq[:256], iq[256:]
  17.  
  18.  
  19. def receive(address):
  20.     with zmq.Context() as ctx:
  21.         sock = ctx.socket(zmq.SUB)
  22.         sock.connect(address)
  23.         sock.subscribe(b'sensor')
  24.         while True:
  25.             topic, frame = sock.recv_multipart()
  26.             i, q = parse(frame)
  27.             print(i[:4], q[:4])
  28.  
  29.  
  30. if __name__ == '__main__':
  31.     address = 'tcp://192.168.0.254:5050'
  32.     receive(address)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top