Commit 6af36fa2 authored by Mateus Goto's avatar Mateus Goto

[Updated] method of connecting

parent 4ddcb4f6
This diff is collapsed.
Main.jpg

154 KB

...@@ -9,7 +9,7 @@ class NHR9400: ...@@ -9,7 +9,7 @@ class NHR9400:
def __init__(self, name): def __init__(self, name):
self.__name = name self.__name = name
self.__s = socket.socket(socket.AF_INET,socket.SOCK_STREAM) self.__s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
self.__s.timeout(1) self.__s.settimeout(1)
self.__out = RefineOutput self.__out = RefineOutput
......
...@@ -6,18 +6,21 @@ class NHR9410(NHR9400): ...@@ -6,18 +6,21 @@ class NHR9410(NHR9400):
def __init__(self): def __init__(self):
super().__init__("NHR9410") super().__init__("NHR9410")
def locateIp(self, clients = []): def locateIp(self,clients = []):
for client in clients: for client in clients:
try:
self.__s.connect((client, 5025)) self.__s.connect((client, 5025))
self.__s.send("SYST:RWL\n") #Command to activate remote control and locking the touchscreen self.__s.send("SYST:RWL\n") #Command to activate remote control and locking the touchscreen
self.__s.send("*IDN?\n") self.__s.send("*IDN?\n")
recv = self.receiveString() recv = super().receiveString()
if str.find("NH Research,9410-") != -1: #if find this subtring if recv.find("NH Research,9410-") != -1: #if find this subtring
self.__ip = client self.__ip = client
clients.remove(client) clients.remove(client)
break break
else: else:
self.__s.close() self.__s.close()
except:
pass
...@@ -8,16 +8,20 @@ class NHR9430(NHR9400): ...@@ -8,16 +8,20 @@ class NHR9430(NHR9400):
def locateIp(self,clients = []): def locateIp(self,clients = []):
for client in clients: for client in clients:
try:
self.__s.connect((client, 5025)) self.__s.connect((client, 5025))
self.__s.send("SYST:RWL\n") #Command to activate remote control and locking the touchscreen self.__s.send("SYST:RWL\n") #Command to activate remote control and locking the touchscreen
self.__s.send("*IDN?\n") self.__s.send("*IDN?\n")
recv = super().receiveString() recv = super().receiveString()
if recv.find("NH Research,9410-") != -1: #if find this subtring if recv.find("NH Research,9430-") != -1: #if find this subtring
self.__ip = client self.__ip = client
clients.remove(client) clients.remove(client)
break break
else: else:
self.__s.close() self.__s.close()
except:
pass
#Arquivo para teste em geral #Arquivo para teste em geral
import socket import socket
from scapy.all import ARP, Ether, srp, arping from scapy.all import ARP, Ether, srp, arping
import socket
import time import time
start = time.time() start = time.time()
...@@ -25,4 +26,10 @@ def getAllIp(): ...@@ -25,4 +26,10 @@ def getAllIp():
print(client) print(client)
getAllIp() getAllIp()
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.settimeout(1)
try:
s.connect(("192.168.15.10", 5025))
except:
print("conexão falhou")
print (time.time() - start) print (time.time() - start)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment