首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >读出思科Ie3300 modbus tcp

读出思科Ie3300 modbus tcp
EN

Stack Overflow用户
提问于 2021-06-24 07:35:29
回答 1查看 24关注 0票数 0

已为modbusTCP ip启用思科交换机...

代码语言:javascript
复制
cisco#show scada modbus tcp server
Summary: enabled, running, process id 330

Conn Stats: listening on port 502, 5 max simultaneous connections
    0 current client connections
    6 total accepted connections, 0 accept connection errors
    6 closed connections, 0 close connection errors

Send Stats: 7 tcp msgs sent, 63 tcp bytes sent, 0 tcp errors
    0 responses sent, 7 exceptions sent, 0 send errors

Recv Stats: 7 tcp msgs received, 84 tcp bytes received, 0 tcp errors
    7 requests received, 0 receive errors

...but如果我读出一个寄存器--> https://www.cisco.com/c/en/us/td/docs/switches/lan/cisco_ie3X00/software/17_3/b_cip-modbus_17-3_iot_switch_cg/m_modbus.html ...get back NONE用于演示目的,我确实使用了全部3个methods...to检查,如果它们生成了不同的..

代码语言:javascript
复制
if __name__ == "__main__":
try:
    #create new object
    c = ModbusClient(host=SERVER_HOST, port=SERVER_PORT, debug=False, auto_open=True)
except ValueError:
    #something went whrong...wrong ip, server port ?
    print("Error with host or port params")  
    
#start the while loop
while loop: 
    try:
        #connection is open
        if c.is_open():
            #loop through the coils
            print(f"Connected to {SERVER_HOST}:{SERVER_PORT}")
            print(c.read_coils(1000,64))
            print(c.read_holding_registers(1000,64))
            print(c.read_input_registers(1000,64))
            loop = False
        else:
            #connection is not open
            print(f"Trying to connect to {SERVER_HOST}: SERVER_PORT}")           
            #try to open it again
            c.open()
            #give it some time
            sleep(1)
    #break loop if keyboard interrupt...        
    except KeyboardInterrupt: 
        #break

在执行时

代码语言:javascript
复制
Trying to connect to 192.168.178.95:502
Connect to 192.168.178.95:502
None
None
None

设置"debug=True“

代码语言:javascript
复制
Trying to connect to 192.168.178.95:502
Connected to 192.168.178.95:502
Tx
[B5 1D 00 00 00 06 01] 01 03 E8 00 40 
Rx
[B5 1D 00 00 00 03 01] 81 01 
except (code 1)
None
Tx
[B7 1A 00 00 00 06 01] 03 03 E8 00 40 
Rx
[B7 1A 00 00 00 03 01] 83 02 
except (code 2)
None
Tx
[8B 3A 00 00 00 06 01] 04 03 E8 00 40 
Rx
[8B 3A 00 00 00 03 01] 84 01 
except (code 1)
None

am work ...what I am wrong...using functions...

EN

回答 1

Stack Overflow用户

发布于 2021-06-24 07:55:02

应该使用十六进制格式的....0x1000

代码语言:javascript
复制
   print(f"Connected to {SERVER_HOST}:{SERVER_PORT}") 
   #print(c.read_coils(0x1000,64))
   print(c.read_holding_registers(0x1000,64))
   #print(c.read_input_registers(0x1000,64))

现在我得到了以下内容...

代码语言:javascript
复制
   Trying to connect to 192.168.178.95:502
   Connected to 192.168.178.95:502
   [18281, 26465, 25193, 29765, 29800, 25970, 28261, 29745, 12081, 0, 0,    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68108051

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档