#!/usr/bin/env python3
################################################################################
# #
# This file is part of the Buildbotics firmware. #
# #
# Copyright (c) 2015 - 2018, Buildbotics LLC #
# All rights reserved. #
# #
# This file ("the software") is free software: you can redistribute it #
# and/or modify it under the terms of the GNU General Public License, #
# version 2 as published by the Free Software Foundation. You should #
# have received a copy of the GNU General Public License, version 2 #
# along with the software. If not, see . #
# #
# The software is distributed in the hope that it will be useful, but #
# WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU #
# Lesser General Public License for more details. #
# #
# You should have received a copy of the GNU Lesser General Public #
# License along with the software. If not, see #
# . #
# #
# For information regarding this software email: #
# "Joseph Coffland" #
# #
################################################################################
import struct
import base64
import json
# Keep this in sync with AVR code command.def
SET = '$'
SET_SYNC = '#'
MODBUS_READ = 'm'
MODBUS_WRITE = 'M'
SEEK = 's'
SET_AXIS = 'a'
LINE = 'l'
SYNC_SPEED = '%'
SPEED = 'p'
INPUT = 'I'
DWELL = 'd'
PAUSE = 'P'
STOP = 'S'
UNPAUSE = 'U'
JOG = 'j'
REPORT = 'r'
REBOOT = 'R'
RESUME = 'c'
ESTOP = 'E'
SHUTDOWN = 'X'
CLEAR = 'C'
FLUSH = 'F'
DUMP = 'D'
HELP = 'h'
SEEK_ACTIVE = 1 << 0
SEEK_ERROR = 1 << 1
def encode_float(x):
return base64.b64encode(struct.pack('