Skip to content

Commit

Permalink
Adding time sync command
Browse files Browse the repository at this point in the history
  • Loading branch information
ps2 committed Apr 13, 2017
1 parent 45ec026 commit 2acbdfe
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pyaci/sensei_cmd.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import time

class SetTime(object):
OpCode = 0x02

def __init__(self, time_to_set=None):
if (time_to_set != None):
self.epoch = time_to_set
else:
self.epoch = time.time()

def serialize(self):
ms = int(self.epoch % 1 * 1000)
print("epoch = {epoch}".format(epoch=self.epoch))
#print("Waiting {ms}ms".format(ms=(1000-ms)))
return bytearray([self.OpCode]) + int(self.epoch).to_bytes(4, byteorder='little') + ms.to_bytes(2, byteorder='little')

0 comments on commit 2acbdfe

Please sign in to comment.