Skip to content

Commit 0b8c3ac

Browse files
committed
tooldb.py: include traceback for nak_reply()
Provides additional debugging information for negative acknowledgment. Note: empty_line is special case with no traceback reqd
1 parent 17be667 commit 0b8c3ac

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

lib/python/tooldb.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import sys
2+
import traceback
23

34
# A python interface for LinuxCNC tool database usage
45

@@ -30,6 +31,7 @@ def currentline():
3031

3132
def nak_reply(msg):
3233
theline = currentline()
34+
if msg != "empty_line": sys.stderr.write(traceback.format_exc()+"\n")
3335
sys.stdout.write("NAK %s <%s>\n"%(msg,theline))
3436
sys.stdout.flush()
3537

@@ -56,7 +58,7 @@ def get_cmd(cmd,params):
5658
for tno in tools:
5759
try: msg = get_tool(tno)
5860
except Exception as e:
59-
nak_reply( "get_cmd():%s"%str(e))
61+
nak_reply( "get_cmd():Exception:%s"%str(e))
6062
return
6163
try: do_reply(msg)
6264
except:
@@ -88,7 +90,7 @@ def put_cmds(cmd,params):
8890
elif cmd == "l": load_spindle( toolno,toolline)
8991
elif cmd == "u": unload_spindle(toolno,toolline)
9092
except Exception as e:
91-
nak_reply( "cmd=%s: %s"%(cmd,str(e)))
93+
nak_reply( "cmd=%s: Exception:%s"%(cmd,str(e)))
9294
return
9395
do_reply("FINI (update recvd) %s"%params)
9496

@@ -152,7 +154,7 @@ def tooldb_loop():
152154
line=sys.stdin.readline().strip()
153155

154156
saveline(line)
155-
if (line == ""): nak_reply("empty line")
157+
if (line == ""): nak_reply("empty_line")
156158
else: do_cmd(line)
157159
except BrokenPipeError: sys.stdout.close()
158160
except Exception as e:

0 commit comments

Comments
 (0)