begin prologix class
This commit is contained in:
parent
260940e0ea
commit
c3c125fe19
|
@ -57,7 +57,7 @@ def ValidateNetParams(ip_str, mask_str, gw_str):
|
|||
# Validate network mask
|
||||
|
||||
# Convert to integer from byte array
|
||||
mask = struct.unpack("!L", mask)[0]
|
||||
mask = struct.unpack("!L", mask)[0]
|
||||
|
||||
# Exclude restricted masks
|
||||
if (mask == 0) or (mask == 0xFFFFFFFF):
|
||||
|
@ -75,7 +75,7 @@ def ValidateNetParams(ip_str, mask_str, gw_str):
|
|||
octet1 = ord(gw[0])
|
||||
|
||||
# Convert to integer from byte array
|
||||
gw = struct.unpack("!L", gw)[0]
|
||||
gw = struct.unpack("!L", gw)[0]
|
||||
|
||||
# Exclude restricted addresses
|
||||
# 0.0.0.0 is valid
|
||||
|
@ -88,7 +88,7 @@ def ValidateNetParams(ip_str, mask_str, gw_str):
|
|||
octet1 = ord(ip[0])
|
||||
|
||||
# Convert to integer from byte array
|
||||
ip = struct.unpack("!L", ip)[0]
|
||||
ip = struct.unpack("!L", ip)[0]
|
||||
|
||||
# Exclude restricted addresses
|
||||
if ((octet1 == 0) or (octet1 == 127) or (octet1 > 223)):
|
||||
|
@ -197,8 +197,12 @@ def main():
|
|||
else:
|
||||
|
||||
try:
|
||||
eth_addr = eth_addr.strip().replace(":", "").replace("-", "")
|
||||
eth_addr = eth_addr.decode('hex')
|
||||
#eth_addr = eth_addr.strip().replace(":", "").replace("-", "")
|
||||
#eth_addr = eth_addr.decode('hex')
|
||||
eth_addr = eth_addr.replace(" ", "")
|
||||
eth_addr = eth_addr.replace(":", "")
|
||||
eth_addr = eth_addr.replace("-", "")
|
||||
eth_addr = bytes.fromhex(eth_addr)
|
||||
except:
|
||||
print("Invalid Ethernet address.")
|
||||
sys.exit(1)
|
||||
|
|
|
@ -731,7 +731,13 @@ def SetEthernetAddress(s, r, eth_addr, new_eth_addr):
|
|||
|
||||
#-----------------------------------------------------------------------------
|
||||
def FormatEthAddr(a):
|
||||
return "%02X-%02X-%02X-%02X-%02X-%02X" % (ord(a[0]), ord(a[1]), ord(a[2]), ord(a[3]), ord(a[4]), ord(a[5]))
|
||||
return "%02X-%02X-%02X-%02X-%02X-%02X" % (ord(a[0]),
|
||||
ord(a[1]),
|
||||
ord(a[2]),
|
||||
ord(a[3]),
|
||||
ord(a[4]),
|
||||
ord(a[5])
|
||||
)
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
|
@ -774,3 +780,24 @@ def PrintDetails(d):
|
|||
else:
|
||||
print('Unknown')
|
||||
|
||||
|
||||
class ProGPIB:
|
||||
"""
|
||||
=====
|
||||
ProGPIB
|
||||
=====
|
||||
|
||||
Provides an interface to Prologix GPIB adapters
|
||||
"""
|
||||
|
||||
from bits import Bytes
|
||||
import time
|
||||
|
||||
def __init__(self, MAC="02:01:01:01:01:01", Virtual=False, IP="0.0.0.0"):
|
||||
"""
|
||||
MAC: Media Access Control (MAC) Address of device
|
||||
Virtual: (bool) Set True to emulate a Prologix GPIB device
|
||||
IP: The IPv4 address of the device
|
||||
"""
|
||||
self.__start = time.time()
|
||||
|
||||
|
|
Loading…
Reference in New Issue