You are not registered yet. Please click here to register!

plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!

Go Back - Interactive Q & A > - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Thread Tools Display Modes
Old December 7th, 2017, 03:40 AM   #1

babido10 is offline
Join Date: Nov 2017
Location: rabat
Posts: 28
Exclamation plc-python-snap7

i started running this code python but give me errors

code python:
import snap7
import struct
import time
from snap7.snap7exceptions import Snap7Exception
import re
from ctypes import c_int, c_char_p, byref, sizeof, c_uint16, c_int32, c_byte
from ctypes import c_void_p
from time import sleep
import snap7.client as c

plc = snap7.client.Client()
plc.connect ('',0,1,tcpport=135)

plc.writeMem('QX0.0',True) # write Q0.0 to be true, which will only turn on the output if it isn't connected to any rung in your ladder code
print plc.getMem('MX0.1') # read memory bit M0.1
print plc.getMem('IX0.0') # read input bit I0.0
C:\Python27\python.exe C:/Users/simo/PycharmProjects/untitled2/
No handlers could be found for logger "snap7.common"
Traceback (most recent call last):
File "C:/Users/simo/PycharmProjects/untitled2/", line 13, in <module>
plc.connect ('',0,1,tcpport=135)
File "C:\Python27\lib\site-packages\snap7\", line 25, in f
check_error(code, context="client")
File "C:\Python27\lib\site-packages\snap7\", line 65, in check_error
raise Snap7Exception(error)
snap7.snap7exceptions.Snap7Exception: ISO : An error occurred during recv TCP : Connection timed out

any ideas??
  Reply With Quote
Old December 7th, 2017, 10:23 AM   #2
Lifetime Supporting Member
United States

JordanCClark is offline
JordanCClark's Avatar
Join Date: Mar 2007
Location: Michigan
Posts: 487
Pretty well sums it up:
Originally Posted by babido10 View Post
snap7.snap7exceptions.Snap7Exception: ISO : An error occurred during recv TCP : Connection timed out

Any man that can hitch the length and breadth of the Galaxy, rough it, slum it, struggle against terrible odds, win through and still know where his towel is, is clearly a man to be reckoned with.
-- Hitchhiker's Guide to the Galaxy
  Reply With Quote
Jump to Live PLC Question and Answer Forum


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
What can i do to get better at coding controls logics? Jrivers010 LIVE PLC Questions And Answers 54 August 23rd, 2017 06:08 PM
PLC Update - Back Issues Collection Now Available! Phil Melore LIVE PLC Questions And Answers 11 October 22nd, 2015 03:17 AM
PLC and Python Communication, HELP DiegoE LIVE PLC Questions And Answers 25 February 23rd, 2015 07:52 AM
Siemens PLC won't auto-run after power-up Lamboom LIVE PLC Questions And Answers 5 August 19th, 2014 05:32 PM
PC to PLC Protocol TheRixta LIVE PLC Questions And Answers 13 December 17th, 2008 01:56 PM

All times are GMT -5. The time now is 11:25 AM.