Skip to content

Commit 458d668

Browse files
committed
qtvcp: mdi_line use halcmd for net command instead of halmodule
Increases functionality while decreasing confusion, bonus of more robust error messages.
1 parent 074d46f commit 458d668

2 files changed

Lines changed: 17 additions & 12 deletions

File tree

docs/src/gui/qtvcp-widgets.adoc

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,12 +1892,10 @@ program or access the feature:
18921892
link:http://linuxcnc.org/docs/devel/html/ladder/classic-ladder.html[ClassicLadder GUI] if the ClassicLadder realtime HAL component was loaded by the machine's config files
18931893
* `PREFERENCE` - Loads the preference file onto the gcodeEditor
18941894
* `CLEAR HISTORY` - Clears the MDI History
1895-
* `net` - Connects a pin to a signal. An error will result if
1896-
the command is unsuccessful. Running LinuxCNC from terminal
1897-
may help determine the root cause as error messages from hal_lib.c
1898-
will be displayed there.
1899-
** _Syntax_: `net <pin name> <signal name>`
1900-
** __Example__: `net motion.jog-stop plasmac:jog-inhibit`
1895+
* `net` - See link:http://linuxcnc.org/docs/devel/html/man/man1/halcmd.1.html#COMMANDS[halcmd net COMMAND].
1896+
An error will result if the command is unsuccessful.
1897+
** _Syntax_: `net <signal name> <pin name>`
1898+
** __Example__: `net plasmac:jog-inhibit motion.jog-stop`
19011899
* `setp` - Sets the value of a pin or a parameter. Valid values depend
19021900
on the object type of the pin or parameter. An error will result if
19031901
the data types do not match or the pin is connected to a signal.

lib/python/qtvcp/widgets/mdi_line.py

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import hal
2020
import time
2121

22+
import subprocess
23+
2224
from PyQt5.QtWidgets import QLineEdit, QApplication
2325
from PyQt5.QtCore import Qt, QEvent, pyqtProperty
2426

@@ -204,14 +206,19 @@ def unlinkp(self, unlinkpString):
204206

205207
def net(self, netString):
206208
arguments = len(netString.lower().replace('net',' ').split())
207-
if arguments == 2:
208-
halpin, signal = netString.lower().replace('net',' ').split()
209+
if arguments >= 2:
210+
args = ['halcmd', 'net']
211+
split = netString.lower().replace('net',' ').split()
212+
for arg in split:
213+
args.append(arg)
209214
else:
210-
ACTION.SET_ERROR_MESSAGE('NET ERROR:\nnet requires 2 arguments, {} given\n'.format(arguments))
215+
ACTION.SET_ERROR_MESSAGE('NET ERROR:\nnet requires at least 2 arguments, {} given\n'.format(arguments))
211216
return
212-
reply = hal.connect(halpin, signal)
213-
if reply:
214-
ACTION.SET_ERROR_MESSAGE('NET ERROR:\nFailed to link pin "{}" to signal "{}"\n'.format(halpin, signal))
217+
reply = subprocess.Popen(args, stderr=subprocess.PIPE)
218+
stdout, stderr = reply.communicate()
219+
if stderr:
220+
error = stderr.decode().replace('<commandline>:0:', '').strip()
221+
ACTION.SET_ERROR_MESSAGE('NET ERROR:\n{}\n'.format(error))
215222

216223
def spindle_inhibit(self, state):
217224
self.spindleInhibit = state

0 commit comments

Comments
 (0)