This commit is contained in:
@@ -53,6 +53,15 @@ def system_check(robot_move=True):
|
||||
raise Exception("Guiding tool not parked")
|
||||
|
||||
|
||||
def start_puck_detection():
|
||||
run("tools/RestartPuckDetection")
|
||||
|
||||
def check_puck_detection():
|
||||
return run("tools/CheckPuckDetection")
|
||||
|
||||
def stop_puck_detection():
|
||||
run("tools/StopPuckDetection")
|
||||
|
||||
###################################################################################################
|
||||
# Device initialization
|
||||
###################################################################################################
|
||||
|
||||
6
script/tools/CheckPuckDetection.py
Normal file
6
script/tools/CheckPuckDetection.py
Normal file
@@ -0,0 +1,6 @@
|
||||
USR,PWD = "pi", "raspberry"
|
||||
HOST,PORT = "tell-raspberrypi", 22
|
||||
CMD= "sudo systemctl status puck_detection.service"
|
||||
|
||||
ret = run("tools/SshExec")
|
||||
set_return(ret)
|
||||
6
script/tools/RestartPuckDetection.py
Normal file
6
script/tools/RestartPuckDetection.py
Normal file
@@ -0,0 +1,6 @@
|
||||
USR,PWD = "pi", "raspberry"
|
||||
HOST,PORT = "tell-raspberrypi", 22
|
||||
CMD= "sudo systemctl stop puck_detection.service;sudo systemctl start puck_detection.service"
|
||||
|
||||
ret = run("tools/SshExec")
|
||||
set_return(ret)
|
||||
61
script/tools/SshExec.py
Normal file
61
script/tools/SshExec.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import com.jcraft.jsch.Channel as Channel
|
||||
import com.jcraft.jsch.ChannelShell as ChannelShell
|
||||
import com.jcraft.jsch.JSch as JSch
|
||||
import com.jcraft.jsch.JSchException as JSchException
|
||||
import com.jcraft.jsch.Session as Session
|
||||
import java.lang.System as System
|
||||
import java.io.PrintStream as PrintStream
|
||||
|
||||
|
||||
#Parameters:
|
||||
#CMD
|
||||
#USR
|
||||
#PWD
|
||||
#HOST
|
||||
#PORT
|
||||
|
||||
jsch= JSch()
|
||||
session=jsch.getSession(USR, HOST, PORT)
|
||||
session.setPassword(PWD)
|
||||
session.setConfig("StrictHostKeyChecking", "no")
|
||||
session.connect()
|
||||
|
||||
#channel=session.openChannel("shell")
|
||||
#input_stream=channel.getInputStream()
|
||||
#output_stream = channel.getOutputStream()
|
||||
#print_stream = PrintStream(output_stream, True)
|
||||
#print_stream.println("ls")
|
||||
|
||||
channel=session.openChannel("exec")
|
||||
channel.setCommand(CMD)
|
||||
channel.setInputStream(None)
|
||||
channel.setOutputStream(System.out)
|
||||
channel.setErrStream(System.err)
|
||||
input_stream=channel.getInputStream()
|
||||
|
||||
|
||||
def wait_ret():
|
||||
global input_stream
|
||||
rx = ""
|
||||
while True:
|
||||
while (input_stream.available() > 0):
|
||||
i = input_stream.read()
|
||||
if i < 0:
|
||||
break
|
||||
rx=rx+chr(i)
|
||||
if channel.closed:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
return rx
|
||||
|
||||
|
||||
channel.connect()
|
||||
|
||||
try:
|
||||
ret = wait_ret()
|
||||
except:
|
||||
channel.disconnect()
|
||||
session.disconnect()
|
||||
raise
|
||||
|
||||
set_return(ret)
|
||||
8
script/tools/StopPuckDetection.py
Normal file
8
script/tools/StopPuckDetection.py
Normal file
@@ -0,0 +1,8 @@
|
||||
USR,PWD = "pi", "raspberry"
|
||||
HOST,PORT = "tell-raspberrypi", 22
|
||||
CMD= "sudo systemctl stop puck_detection.service"
|
||||
|
||||
ret = run("tools/SshExec")
|
||||
set_return(ret)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user