wiki:SNAP7

SNAP7 Siemens

Python3 as server and client to test with Siemens Logo8, pls download attached file Snap7.tar​ After untar run PLC server, TCP port 102 will be opened for waiting connection

$ cd  Snap7/python-snap7-1.2/build/scripts-3.7
[krit@mini scripts-3.7]$ ./snap7-server.py

To test server, run client to connect server with

root@OpenWrt:~/pysiemens# python3 test.py
0
00:00:00
1990-01-01
Result of write at address 2
[{'function': 5, 'items_count': 1, 'result_code': 255}]
root@OpenWrt:~/pysiemens# 

We can use wireshark to capture packet. We can apply filter with s7comm on wireshark. The meaning of data frame of S7 explain in ​here

Modbus TCP

We use GL-inet Mifi and need to install package pylibmodbus, while Logo!8 act as TCP server on port 502.

python3-libmodbus - 0.6.2-1
python3-light - 3.11.7-1

We can control ON/OFF Q1 with write_NI_choice2.py​.
We can read all register with read_all_NQ_chunk.py​ and we can public to MQTT with read_NAQ_pub.py​.

Last modified 20 months ago Last modified on 02/03/25 15:37:46

Attachments (4)

Download all attachments as: .zip