我正在寻找一个用python获取PLC的数据,我只需要得到“0”和“1”的值。我找到了这个python库pycomm(https://pypi.python.org/pypi/pycomm/1.0.7),这个代码片段也在哪里:from pycomm.ab_comm.slc import Driver as SlcDriver
if __name__ == '__main__':
c = SlcDriver(True, 'delete_slc.log')
if c.open('172.16.2.160'):
print c.read_tag('S:1/5')
print c.read_tag('S:60', 2)
print c.write_tag('N7:0', [-30, 32767, -32767])
print c.write_tag('N7:0', 21)
print c.read_tag('N7:0', 10)
print c.write_tag('F8:0', [3.1, 4.95, -32.89])
print c.write_tag('F8:0', 21)
print c.read_tag('F8:0', 3)
print c.write_tag('B3:100', [23, -1, 4, 9])
print c.write_tag('B3:100', 21)
print c.read_tag('B3:100', 4)
print c.write_tag('T4:3.PRE', 431)