diff options
author | Matthias P. Braendli (think) <matthias@mpb.li> | 2013-11-08 18:15:22 +0100 |
---|---|---|
committer | Matthias P. Braendli (think) <matthias@mpb.li> | 2013-11-08 18:15:22 +0100 |
commit | 7a260a48edf00b3375c5f4adf299f6b9f408eb48 (patch) | |
tree | cbad14efd428b9e1bef55b3792fc5304c328f037 | |
parent | 80c1256d2884b7c9898caaa43790261cf37819e2 (diff) | |
download | mmbtools-aux-7a260a48edf00b3375c5f4adf299f6b9f408eb48.tar.gz mmbtools-aux-7a260a48edf00b3375c5f4adf299f6b9f408eb48.tar.bz2 mmbtools-aux-7a260a48edf00b3375c5f4adf299f6b9f408eb48.zip |
add example ZeroMQ receiver script
-rwxr-xr-x | zmq-rx.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/zmq-rx.py b/zmq-rx.py new file mode 100755 index 0000000..927b5ed --- /dev/null +++ b/zmq-rx.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python + +import sys +import zmq + +context = zmq.Context() + +sock = context.socket(zmq.SUB) + +sock.connect("tcp://localhost:8080") + +sock.setsockopt(zmq.SUBSCRIBE, bytes([])) + +print("Entering loop") +for i in range(10): + data = sock.recv(flags=0, copy=True, track=False) + print("RX {0}B, {1:2x}, {2:2x}, {3:2x}, {4:2x}, ...".format( + len(data), + data[0], data[1], data[2], data[3] )) |