Skip to content

Commit 0e2f51d

Browse files
author
Developer
committed
Added 'loader-options' to accept -c and/or -v (CODE/VERBOSE/CODE_VEROSE) options from web.
1 parent fa9dc23 commit 0e2f51d

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

BlocklyServer.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def ports(self):
8585
@cherrypy.expose(alias='load.action')
8686
@cherrypy.tools.json_out()
8787
@cherrypy.tools.allow(methods=['POST'])
88-
def load(self, action, binary, extension, comport=None):
88+
def load(self, option, action, binary, extension, comport=None):
8989
if action is None:
9090
self.logger.error('Load action is undefined.')
9191
return {
@@ -105,7 +105,7 @@ def load(self, action, binary, extension, comport=None):
105105

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

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

111111
self.logger.info('Application load complete.')

PropellerLoad.py

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ def __init__(self):
6464
"EEPROM": {"compile-options": "-e"}
6565
}
6666

67+
self.loaderOption = {
68+
"CODE": {"loader-options": "-c"},
69+
"VERBOSE": {"loader-options": "-v"},
70+
"CODE_VERBOSE": {"loader-options": "-c -v"}
71+
}
72+
6773
if not platform.system() in self.loaderExe:
6874
self.logger.error('The %s platform is not supported at this time.', platform.system())
6975
print(platform.system() + " is currently unsupported")
@@ -108,7 +114,7 @@ def get_ports(self):
108114
self.discovering = False
109115

110116

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

130-
# Set command to download to RAM or EEPROM and to run afterward download
136+
# Set command options to download to RAM or EEPROM and to run afterward download
131137
command = []
138+
139+
if self.loaderOption[option]["loader-options"] != "":
140+
# if loader-option not empty, add it to the list
141+
command.extend([self.loaderOption[option]["loader-options"]])
142+
132143
if self.loaderAction[action]["compile-options"] != "":
133144
# if RAM/EEPROM compile-option not empty, add it to the list
134145
command.extend([self.loaderAction[action]["compile-options"]])
146+
135147
command.extend(["-r"])
136148

137149
# Specify requested port

0 commit comments

Comments
 (0)