From 4535f78e0dab2e1e8ad95da4f57ed70cce434766 Mon Sep 17 00:00:00 2001 From: Pablo Prietz Date: Fri, 19 May 2017 13:41:42 +0200 Subject: [PATCH] TimeSync: Introduce protocol versioning and change group name convention (#721) * Introduce protocol versioning and change group name convention * Add Time Sync protocol version to UI * PTS v0.3 -- Host sends timestamps as 64-bit le floats instead of string repr * Update version numbers to decimals --- pupil_src/shared_modules/network_time_sync.py | 10 ++-- pupil_src/shared_modules/time_sync.py | 46 ++++++++++++------- pupil_src/shared_modules/time_sync_spec.md | 19 ++++---- 3 files changed, 46 insertions(+), 29 deletions(-) diff --git a/pupil_src/shared_modules/network_time_sync.py b/pupil_src/shared_modules/network_time_sync.py index 41b0982367..8f4b9e5cb7 100644 --- a/pupil_src/shared_modules/network_time_sync.py +++ b/pupil_src/shared_modules/network_time_sync.py @@ -13,6 +13,7 @@ import socket import threading import asyncore +import struct from random import random import logging @@ -44,9 +45,10 @@ def __init__(self, sock, time_fn): asyncore.dispatcher_with_send.__init__(self, sock) def handle_read(self): - data = self.recv(1024) + # expecting `sync` message + data = self.recv(4) if data: - self.send(repr(self.time_fn()).encode()) + self.send(struct.pack('