-
-
Save papr/33426d01d8f817a74d3e7247ab4dc29f to your computer and use it in GitHub Desktop.
Start and stop recordings of multiple Pupil Capture instances. Pass at least one address to start connecting. Format `<ip>:<port>`. Example `127.0.0.1:50020`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import logging | |
import zmq | |
logger = logging.getLogger(__name__) | |
def main(addresses): | |
logger.info(f"Connecting to {addresses}") | |
ctx = zmq.Context() | |
connections = [] | |
for addr in addresses: | |
requester = ctx.socket(zmq.REQ) | |
req_url = f"tcp://{addr}" | |
logger.debug(f"Connecting to req_url={req_url}") | |
requester.connect(req_url) | |
requester.send_string("v") | |
version = requester.recv_string() | |
logger.info(f"Connected to {addr} (version {version})") | |
connections.append(requester) | |
input("Press Enter to start recording") | |
for req in connections: | |
req.send_string("R") | |
req.recv_string() | |
input("Press Enter to stop recording") | |
for req in connections: | |
req.send_string("r") | |
req.recv_string() | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument( | |
"address", | |
type=str, | |
default=["127.0.0.1:50020"], | |
nargs="+", | |
help=( | |
"One or more Pupil Capture instance addresses. " | |
"Format <ip>:<port>. Example 127.0.0.1:50020" | |
), | |
) | |
args = parser.parse_args() | |
logging.basicConfig(level=logging.INFO) | |
main(args.address) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment