From 7677b859294b23b250d11dda59f082884d58a208 Mon Sep 17 00:00:00 2001 From: Tom Hunger Date: Fri, 13 Mar 2015 22:22:22 +0000 Subject: [PATCH] Emulator: Decode binary payload of a device command. --- sirius/emulate/commands.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sirius/emulate/commands.py b/sirius/emulate/commands.py index ca7f5bf..6be25e2 100644 --- a/sirius/emulate/commands.py +++ b/sirius/emulate/commands.py @@ -11,6 +11,8 @@ import json import re import random import time +import struct +import base64 from flask.ext import script @@ -52,6 +54,13 @@ def heartbeat(ws): assert False # unreachable +def _decode_binary(base64_data): + bdata = base64.b64decode(base64_data) + _, _, command, print_id, _, length = struct.unpack("