-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathexample.py
53 lines (35 loc) · 1.25 KB
/
example.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
###########################################################
#
#
# Author: Collin Matthews - 2020
###########################################################
import os, sys
import argparse
from time import sleep
from lib.GE_SRTP import GeSrtp
###########################################################
# MAIN()
###########################################################
def main():
try:
plc.initConnection()
result = plc.readSysMemory(args.reg)
print("The Result from PLC = {}".format(result.register_result))
print("PLC Status Codes (42,43): 0x{:02x} 0x{:02x}".format(
result.status_code, result.status_code_minor))
plc.closeConnection()
print("Demo Over...")
except Exception as err:
print("High level system exception.")
print(err)
return(1)
if __name__ == "__main__":
# Parse Arguments - Global
parser = argparse.ArgumentParser(description='GE SRTP PLC Communication Test.')
parser.add_argument(action="store", dest='plc_ip', help='IP address of PLC')
parser.add_argument(action="store", dest='reg', help='Register to read or write')
args = parser.parse_args()
# Global PLC init
plc = GeSrtp(args.plc_ip)
resp = main()
sys.exit(resp)