Skip to content

Commit

Permalink
linuxcnc: Add option to enable project file writing
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Buesch <[email protected]>
  • Loading branch information
mbuesch committed Feb 22, 2020
1 parent 668b5b3 commit ed0585f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions awlsim-linuxcnc-hal
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ def usage():
print("Usage: awlsim-linuxcnc-hal [OPTIONS] PROJECT.awlpro")
print("")
print("Options:")
print(" -w|--rw-project Enable project file writing after download of new program.")
print(" Default: Do not write to the project file.")
print("")
print(" -i|--input-size SIZE The input area size, in bytes.")
print(" Overrides input-size from project file.")
print(" -I|--input-base BASE The AWL/STL input address base.")
Expand Down Expand Up @@ -120,6 +123,7 @@ def main():
global opt_watchdog
global opt_maxRuntime
global opt_extInsns
global opt_rwProject

opt_inputSize = None
opt_inputBase = None
Expand All @@ -131,15 +135,17 @@ def main():
opt_watchdog = True
opt_maxRuntime = None
opt_extInsns = None
opt_rwProject = False

try:
(opts, args) = getopt.getopt(sys.argv[1:],
"hi:I:o:O:l:L:N:W:M:x",
"hi:I:o:O:l:L:N:W:M:xw",
[ "help", "input-size=", "input-base=",
"output-size=", "output-base=",
"listen=",
"loglevel=", "nice=",
"watchdog=", "max-runtime=", "extended-insns", ])
"watchdog=", "max-runtime=", "extended-insns",
"rw-project", ])
except getopt.GetoptError as e:
printError(str(e))
usage()
Expand Down Expand Up @@ -208,6 +214,8 @@ def main():
return 1
if o in ("-x", "--extended-insns"):
opt_extInsns = True
if o in ("-w", "--rw-project"):
opt_rwProject = True
if len(args) != 1:
usage()
return 1
Expand Down Expand Up @@ -307,6 +315,7 @@ def main():
server.startup(host=opt_listen[0],
port=opt_listen[1],
project=project,
projectWriteBack=opt_rwProject,
raiseExceptionsFromRun=True,
handleMaintenanceServerside=True)
try:
Expand Down
3 changes: 3 additions & 0 deletions examples/linuxcnc-demo/awlsim.hal
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
# --nice NICE : Renice the process. -20 <= NICE <= 19.
# Default: Do not renice.
#
# --rw-project : Enable project file writing after download of new program.
# Default: Do not write to the project file.
#
# Last argument : The Awlsim AWL/STL project to load and run.
#
loadusr -Wn awlsim awlsim-linuxcnc-hal --listen localhost:4151 linuxcnc-demo.awlpro
Expand Down

0 comments on commit ed0585f

Please sign in to comment.