I am using a raspberry pi3 and would like to access an S7-300 with SmartHomeNG. I installed Snap7 according to the instructions. the file libsnap7.so is in the folder /usr/lib. But it looks like snap7 is not available. I get the following log entry when calling "import snap7" from a python script.
"ImportError: No module named 'snap7'"
When i run "dpkg -l", there is no entry regarding snap7
Does anyone have any idea what´s wrong on my installation?
Regards
Markus
Last edit: macs 2017-11-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I got the same error "No module named snap7"
Finally i understood, that i have installed the snap7-Files into the Python3.9 Folder. But when i was running a python-script, a formerly installed version of python, Python2.7, was beeing used. When i start my python-scripts with
sudo python3.9 [scriptname].py
it works.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I know and I've already done that .
It still didn't work , apparently I installed snap7 on python 2 not 3
that's why it stated that error when trying to execute it on python 3 .
However when I tried to run it on python 2 I got this
I know and I've already done that .
It still didn't work , apparently I installed snap7 on python 2 not 3
that's why it stated that error when trying to execute it on python 3 .
However when I tried to run it on python 2 I got this
hello, are you familiar with siemens s7 1200 plcs ? i'm using Tia
portal V14 , my pc sees the plc but can not detect it ! can you help
me or do you know anyone who can help ? thank you
Le ven 3 mai 2019 12:53 PM, takwa bakri takwa.bakri@gmail.com a écrit :
Hey ,
I know and I've already done that .
It still didn't work , apparently I installed snap7 on python 2 not 3
that's why it stated that error when trying to execute it on python 3 .
However when I tried to run it on python 2 I got this
Le ven 3 mai 2019 12:45 PM, Davide Nardella davenardella@users.sourceforge.net a écrit :
use
sudo make –f arm_v7_linux.mk all
instead of
sudo make –f arm_v6_linux.mk all
v6 is only for Raspberry 1
v7 is for all other (Raspberry and other SBCs)
If you mean that the pc sees it but TIA portal doesn't, I think it's because you're using DHCP (automatic IP), try to fix the ip adress in the settings of both your adapter ipv4 properties and in Sinmatic Sutomation Tool as this video shows from 0:00 to 1:20 https://www.youtube.com/watch?v=yJNEsI5KJxs
about your previous problem:
this problem happens because the function "connect()" on file client.py located at "usr/local/lib/python2.7/dist-packages/snap7/" has not been given the right parameters
Hey , I'm using tia portal v14 so I don't really have the automation tool
since it's integrated in tia v 14 , however I've already tried fixing the
ip adress for the pc (in the internet and network settings and it's
192.168.5.55) and an ip adress for ethernet port in the plc (192.168.5.100)
but I still get this when trying to charge the program ! The ip adress that
I have fixed to the plc (192.168.5.100) gets automatically attributed to
the pc while the plc gets another ip adress (192.168.1.100) that is
impossible to change ( I actually got the error : impossible to change the
ip adress when I tried to )
If you mean that the pc sees it but TIA portal doesn't, I think it's
because you're using DHCP (automatic IP), try to fix the ip adress in the
settings of both your adaptor ipv4 properties and in Sinmatic Sutomation
Tool as this video shows from 0:00 to 1:20 https://www.youtube.com/watch?v=yJNEsI5KJxs
I can assume that the scenario you're facing is that your plc is already programmed with 192.168.1.100 as an ip address so it can't upload a program when the pc is in another sub-network that you gave it which is 192.168.5.55 so:
I don't have a supply to fire up the PLC i have right now and do the tests but I can suggest you some workarounds
try to (compile the hardware config) and then (upload hardware config) as shown here: https://www.youtube.com/watch?v=zChne9SU1Go
from 1:02 to 1:37 so that would change your plc's ip address to your desired one
try to assign an ip address to your pc (if that doesn't mess up with your network setup) that is in the same sub-network as your plc, let it be 192.168.1.101 so the configurations in your program would be:
plc: 192.168.1.100
pc:192.168.1.101
even though I recommend the first solution but in case it didn't work there's the 2nd one, hopefully that's gonna fix your problem
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey , I knew what's wrong : incompatible firmware , the plc runs on v1.0
firmware version however this firmware doesn't exist in tia v 14 ( there's
from v4.2 to v2.0 ) and the plc refuses to charge under any other version .
So is there a possibilité to add the v1. 0 firmware version to tia v14 ??
Or should I just install tia v13 since it has the v1.0 firmware version ?
Thank you
I can assume that the scenario you're facing is that your plc is already
programmed with 192.168.1.100 as an ip address so it can't upload a program
when the pc is in another sub-network that you gave it which is
192.168.5.55 so:
I don't have a supply to fire up the PLC i have right now and do the tests
but I can suggest you some workarounds
try to (compile the hardware config) and then (upload hardware config) as
shown here: https://www.youtube.com/watch?v=zChne9SU1Go
from 1:02 to 1:37 so that would change your plc's ip address to your
desired one
try to assign an ip address to your pc (if that doesn't mess up with your
network setup) that is in the same sub-network as your plc, let it be
192.168.1.101 so the configurations in your program would be:
plc: 192.168.1.100
pc:192.168.1.101
even though I recommend the first solution but in case it didn't work
there's the 2nd one, hopefully that's gonna fix your problem
Unfortunately I have no idea about adding firmware versions to the TIA Portal, even upgrading the PLC itself require an expensive SD Card, I'm afraid the only thing left is to roll back to a previous version of TIA Portal...
.
By the way I'm working on a similar project, trying to simulate everything, using PLCSim (on a vm) with snap7 (on a RPi) to test and develope applications without the need of a real PLC, the thing is, I don't seem to abe to succeed on pinging any device on the network from my Pi, I can actually ping it from everywhere on the network, phone, pcs, vms, it got internet, but it can't ping anything back, and it gives me a TCP Time out when I do the plc.connect() method , i'm using a phone hotspot everything seems to work fine except that one glitch...
I suspect the apt-get update that's messing with my distribution...
or maybe i don't have to be able to ping at all to control a PLC with snap7
any idea ?
Last edit: Yacine Hadjadj 2019-05-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
EDIT: Never mind I managed to do it, it's not a networking problem, it was me misconfiguring the rack/slot of the NetToPLCSim... now it's connecting normally, from my host pc, from the RPi, pretty much anywhere from the network, I didn't test from a VM yet where I'm thinking to put a Raspbian Desktop for a better RPi simulation experience but i'm pretty sure it would connect...
Last edit: Yacine Hadjadj 2019-05-13
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm so sorry, but I don't know Python at all because I don't like it at all.
My suggestions stops to Snap7 (C/C++, Delphi and the other wrappers that I wrote).
try https://github.com/gijzelaerr/python-snap7
or if you decide to move to the dark side of "c", I'll be happy to help you.
regards
Dave
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi guys,
I am using a raspberry pi3 and would like to access an S7-300 with SmartHomeNG. I installed Snap7 according to the instructions. the file libsnap7.so is in the folder /usr/lib. But it looks like snap7 is not available. I get the following log entry when calling "import snap7" from a python script.
"ImportError: No module named 'snap7'"
When i run "dpkg -l", there is no entry regarding snap7
Does anyone have any idea what´s wrong on my installation?
Regards
Markus
Last edit: macs 2017-11-02
I got the same error "No module named snap7"
Finally i understood, that i have installed the snap7-Files into the Python3.9 Folder. But when i was running a python-script, a formerly installed version of python, Python2.7, was beeing used. When i start my python-scripts with
sudo python3.9 [scriptname].py
it works.
Use root permissions and look if you install snap7 in python 2 or 3...
i did this tutorial and its worked.. http://simplyautomationized.blogspot.com.es/2014/12/raspberry-pi-getting-data-from-s7-1200.html
i tried the same tutorial and i got the same error as him
use
sudo make –f arm_v7_linux.mk all
instead of
sudo make –f arm_v6_linux.mk all
v6 is only for Raspberry 1
v7 is for all other (Raspberry and other SBCs)
Hey ,
I know and I've already done that .
It still didn't work , apparently I installed snap7 on python 2 not 3
that's why it stated that error when trying to execute it on python 3 .
However when I tried to run it on python 2 I got this
Le ven 3 mai 2019 12:45 PM, Davide Nardella davenardella@users.sourceforge.net a écrit :
Le ven 3 mai 2019 12:53 PM, takwa bakri takwa.bakri@gmail.com a écrit :
hello, are you familiar with siemens s7 1200 plcs ? i'm using Tia
portal V14 , my pc sees the plc but can not detect it ! can you help
me or do you know anyone who can help ? thank you
Le ven. 3 mai 2019 à 14:33, takwa bakri takwaa@users.sourceforge.net a écrit :
If you mean that the pc sees it but TIA portal doesn't, I think it's because you're using DHCP (automatic IP), try to fix the ip adress in the settings of both your adapter ipv4 properties and in Sinmatic Sutomation Tool as this video shows from 0:00 to 1:20
https://www.youtube.com/watch?v=yJNEsI5KJxs
about your previous problem:
this problem happens because the function "connect()" on file client.py located at "usr/local/lib/python2.7/dist-packages/snap7/" has not been given the right parameters
notice right here https://github.com/gijzelaerr/python-snap7/blob/master/snap7/client.py
in line 117 that the definition of connect() is:
def connect(self, address, rack, slot, tcpport=102)
where the parameters are:
address: IP address of server
rack: rack on server
slot: slot on server.
Last edit: Yacine Hadjadj 2019-05-09
Hey , I'm using tia portal v14 so I don't really have the automation tool
since it's integrated in tia v 14 , however I've already tried fixing the
ip adress for the pc (in the internet and network settings and it's
192.168.5.55) and an ip adress for ethernet port in the plc (192.168.5.100)
but I still get this when trying to charge the program ! The ip adress that
I have fixed to the plc (192.168.5.100) gets automatically attributed to
the pc while the plc gets another ip adress (192.168.1.100) that is
impossible to change ( I actually got the error : impossible to change the
ip adress when I tried to )
Le jeu 9 mai 2019 9:01 PM, Yacine HADJADJ ycinhdj@users.sourceforge.net a
écrit :
I can assume that the scenario you're facing is that your plc is already programmed with 192.168.1.100 as an ip address so it can't upload a program when the pc is in another sub-network that you gave it which is 192.168.5.55 so:
I don't have a supply to fire up the PLC i have right now and do the tests but I can suggest you some workarounds
try to (compile the hardware config) and then (upload hardware config) as shown here:
https://www.youtube.com/watch?v=zChne9SU1Go
from 1:02 to 1:37 so that would change your plc's ip address to your desired one
try to assign an ip address to your pc (if that doesn't mess up with your network setup) that is in the same sub-network as your plc, let it be 192.168.1.101 so the configurations in your program would be:
plc: 192.168.1.100
pc:192.168.1.101
even though I recommend the first solution but in case it didn't work there's the 2nd one, hopefully that's gonna fix your problem
Hey , I knew what's wrong : incompatible firmware , the plc runs on v1.0
firmware version however this firmware doesn't exist in tia v 14 ( there's
from v4.2 to v2.0 ) and the plc refuses to charge under any other version .
So is there a possibilité to add the v1. 0 firmware version to tia v14 ??
Or should I just install tia v13 since it has the v1.0 firmware version ?
Thank you
Le ven 10 mai 2019 6:09 AM, Yacine HADJADJ ycinhdj@users.sourceforge.net
a écrit :
Unfortunately I have no idea about adding firmware versions to the TIA Portal, even upgrading the PLC itself require an expensive SD Card, I'm afraid the only thing left is to roll back to a previous version of TIA Portal...
.
By the way I'm working on a similar project, trying to simulate everything, using PLCSim (on a vm) with snap7 (on a RPi) to test and develope applications without the need of a real PLC, the thing is, I don't seem to abe to succeed on pinging any device on the network from my Pi, I can actually ping it from everywhere on the network, phone, pcs, vms, it got internet, but it can't ping anything back, and it gives me a TCP Time out when I do the plc.connect() method , i'm using a phone hotspot everything seems to work fine except that one glitch...
I suspect the apt-get update that's messing with my distribution...
or maybe i don't have to be able to ping at all to control a PLC with snap7
any idea ?
Last edit: Yacine Hadjadj 2019-05-13
EDIT: Never mind I managed to do it, it's not a networking problem, it was me misconfiguring the rack/slot of the NetToPLCSim... now it's connecting normally, from my host pc, from the RPi, pretty much anywhere from the network, I didn't test from a VM yet where I'm thinking to put a Raspbian Desktop for a better RPi simulation experience but i'm pretty sure it would connect...
Last edit: Yacine Hadjadj 2019-05-13
I'm so sorry, but I don't know Python at all because I don't like it at all.
My suggestions stops to Snap7 (C/C++, Delphi and the other wrappers that I wrote).
try
https://github.com/gijzelaerr/python-snap7
or if you decide to move to the dark side of "c", I'll be happy to help you.
regards
Dave