def __init__(self, is_llc=False, ifname=None, timeout=3, log_dir=None): if is_llc: self._mac_addr_ = get_if_hwaddr(ifname) self._ifname_ = ifname self._ether_ = ether.EtherRaw(ifname, self._mac_addr_) else: self._mac_addr_ = None self._ifname_ = None self._ether_ = None self._conn_ = s7.S7Layer(is_llc, ifname, self._mac_addr_, timeout) self._szl_list_ = [] self._timeout_ = timeout self._is_llc = is_llc self.results = OrderedDict() self.results["Scan start time"] = datetime.datetime.now().strftime( "%Y-%m-%d %H:%M") self.results["Command line arguments"] = [] for arg in sys.argv: self.results["Command line arguments"].append( arg.decode(sys.stdin.encoding).encode("utf-8")) self.plcs = OrderedDict() if log_dir: self.logfile = open(log_dir + "\\" + S7SCAN_LOG_FILE, "wb") self.plcfile = open(log_dir + "\\" + S7SCAN_PLC_FILE, "wb") else: self.logfile = None self.plcfile = None self.silent = False
def reset(self, is_llc=False, ifname=None, timeout=3): if is_llc: self._mac_addr_ = get_if_hwaddr(ifname) self._ifname_ = ifname self._ether_ = ether.EtherRaw(ifname, self._mac_addr_) else: self._mac_addr_ = None self._ifname_ = None self._ether_ = None self._conn_ = s7.S7Layer(is_llc, ifname, self._mac_addr_, timeout) self._timeout_ = timeout self._is_llc = is_llc