Skip to content

Commit

Permalink
Merge pull request #108 from PropGit/results_simplify
Browse files Browse the repository at this point in the history
Enabled coded download messages
  • Loading branch information
PropGit authored Dec 29, 2017
2 parents 7fa02c2 + 44ee2c5 commit 72f2bbb
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 12 deletions.
4 changes: 2 additions & 2 deletions BlocklyPropClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
# Please verify that the version number in the local about.txt and the
# ./package/win-resources/blocklypropclient-installer.iss matches this.
# -----------------------------------------------------------------------
VERSION = "0.7.0"
VERSION = "0.7.5"


# Enable logging for functions outside of the class definition
Expand Down Expand Up @@ -229,7 +229,7 @@ def handle_connect(self):
# read entered values and start server
self.server_process = multiprocessing.Process(
target=BlocklyServer.main,
args=(int(self.port.get()), self.version, self.q))
args=(int(self.port.get()), self.version, self.app_version, self.q))

self.server_process.start()

Expand Down
15 changes: 9 additions & 6 deletions BlocklyServer.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@

class BlocklyServer(object):

def __init__(self, version, queue):
def __init__(self, version, app_version, queue):
self.logger = logging.getLogger('blockly.server')
self.logger.info('Creating server logger.')

self.version = version
self.app_version = app_version
self.queue = queue

# Find the path from which application was launched
Expand All @@ -47,9 +48,11 @@ def __init__(self, version, queue):
def index(self):
cherrypy.response.headers['Access-Control-Allow-Origin'] = '*'

# version supports pre-0.99 web clients, version_str supports v0.99+ web clients
serverinfo = {
"server": "BlocklyPropHTTP",
"version": self.version
"version": self.version,
"version_str": self.app_version
}
self.queue.put((1, 'TRACE', 'Server poll received'))
self.logger.debug('Server poll received')
Expand Down Expand Up @@ -85,7 +88,7 @@ def ports(self):
@cherrypy.expose(alias='load.action')
@cherrypy.tools.json_out()
@cherrypy.tools.allow(methods=['POST'])
def load(self, action, binary, extension, comport=None):
def load(self, option, action, binary, extension, comport=None):
if action is None:
self.logger.error('Load action is undefined.')
return {
Expand All @@ -105,7 +108,7 @@ def load(self, action, binary, extension, comport=None):

self.logger.debug('Loading program to device.')

(success, out, err) = self.propellerLoad.download(action, binary_file, comport)
(success, out, err) = self.propellerLoad.download(option, action, binary_file, comport)
self.queue.put((10, 'INFO', 'Application loaded (%s)' % action))

self.logger.info('Application load complete.')
Expand All @@ -125,7 +128,7 @@ def serial_socket(self):
handler = cherrypy.request.ws_handler


def main(port, version, queue):
def main(port, version, app_version, queue):
module_logger.info("Server starting")
queue.put((10, 'INFO', 'Server starting'))

Expand All @@ -137,7 +140,7 @@ def main(port, version, queue):

queue.put((10, 'INFO', 'Websocket configured'))

cherrypy.quickstart(BlocklyServer(version, queue), '/', config={'/serial.connect': {
cherrypy.quickstart(BlocklyServer(version, app_version, queue), '/', config={'/serial.connect': {
'tools.websocket.on': True,
'tools.websocket.handler_cls': SerialSocket
}})
Expand Down
16 changes: 14 additions & 2 deletions PropellerLoad.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,12 @@ def __init__(self):
"EEPROM": {"compile-options": "-e"}
}

self.loaderOption = {
"CODE": {"loader-options": "-c"},
"VERBOSE": {"loader-options": "-v"},
"CODE_VERBOSE": {"loader-options": "-c -v"}
}

if not platform.system() in self.loaderExe:
self.logger.error('The %s platform is not supported at this time.', platform.system())
print(platform.system() + " is currently unsupported")
Expand Down Expand Up @@ -108,7 +114,7 @@ def get_ports(self):
self.discovering = False


def download(self, action, file_to_load, com_port):
def download(self, option, action, file_to_load, com_port):
# Download application to Propeller
# Set loading flag to prevent interruption
self.loading = True
Expand All @@ -127,11 +133,17 @@ def download(self, action, file_to_load, com_port):
# # launch path is blank; try extracting from argv
# self.appdir = os.path.dirname(os.path.realpath(sys.argv[0]))

# Set command to download to RAM or EEPROM and to run afterward download
# Set command options to download to RAM or EEPROM and to run after download
command = []

if self.loaderOption[option]["loader-options"] != "":
# if loader-option not empty, add it to the list
command.extend([self.loaderOption[option]["loader-options"]])

if self.loaderAction[action]["compile-options"] != "":
# if RAM/EEPROM compile-option not empty, add it to the list
command.extend([self.loaderAction[action]["compile-options"]])

command.extend(["-r"])

# Specify requested port
Expand Down
2 changes: 1 addition & 1 deletion about.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Version: v0.7.0
Version: v0.7.5

Contributors:
- Michel Lampo
Expand Down
2 changes: 1 addition & 1 deletion package/blocklypropclient-installer.iss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

#define MyAppName "BlocklyPropClient"
#define MyAppVersion "0.7.0"
#define MyAppVersion "0.7.5"
#define MyAppPublisher "Parallax Inc."
#define MyAppURL "http://blockly.parallax.com/"
#define MyAppExeName "BlocklyPropClient.exe"
Expand Down

0 comments on commit 72f2bbb

Please sign in to comment.