.. _zmq_connection: Get Data from API via ZeroMQ ============================ Requires pymepix to be installed as shown in :ref:`Install Pymepix` It is possible to send data from the computer that is connected to the camera to another computer or application. Pymepix is only required to run on the computer sending the data it gets from the timepix camera. Said data is made available through a ZeroMQ socket, which requires Python to be accessed since Python objects are being sent. More Information on ZeroMQ and supported languages can be found here: https://zeromq.org/ and for python in particular here: https://learning-0mq-with-pyzmq.readthedocs.io/en/latest/pyzmq/basics.html To access the data using python, simply do the following: 1. Start the Timepix camera or start the spidrDummyTCP script to simulate a camera 2. Start the api from a terminal using ``pymepix-acq api-service``, connecting the either the camera or the spidrDummyTCP 3. For an example application, let's try running this script: .. code-block:: python if __name__ == "__main__": # Create ZeroMQ socket context = zmq.Context() socket = context.socket(zmq.SUB) # Connect to Pymepix socket. Here we assume it to run on the same machine as this script # To connect to a different machine instead change ip address as needed # The API port can be found and configured in pymepix/config/default.yaml socket.connect ("tcp://127.0.0.1:%s" % 5056) socket.setsockopt_string(zmq.SUBSCRIBE, "") print ("Listening…") while True: # Listen for and receive data obj = socket.recv_pyobj() message_type = obj["type"] message_data = obj["data"] # TODO: your code print(message_type) time.sleep(0.1) 4. Start sending data to Pymepix from Timepix camera or start the spidrDummyUDP script to simulate data being sent