Comments (8)
Can you post a simple example that causes this issue? It will probably be important to know the tags and their data types.
from pylogix.
For future reference please provide an mre.
For your case it would be one script with one Read call, in a while loop and a sleep of N seconds. We don't need to know about sms and other stuff going on.
Also ensure that you are using code tags when posting so that is formatted properly.
What are the data types for the tags giving you the exception?
Does the same exception happens when doing individual reads?
When opening an issue there's a template for some questions and you didn't provide those.
OS type and version?
Pylogix version?
Python version?
PLC model?
from pylogix.
Good morning. The error manifested itself with the following code. The tags I read are two to simplify. The first is an integer, the other is boolean. I would like to point out that the Raspberry Pi 3 is connected to the PLC via a HyperLAN network at a distance of 10 km. Might you need code that checks the connection and avoids blocking code execution? Let me start by saying that I am a newbie. Thank you.
[342, True]
12/10/2023, 11:32:31
['Livello 3.42 mt 😃']
Traceback (most recent call last):
File "/home/nino/TorrreP2/TorreP2Test.py", line 49, in
dati_adesso = leggi_tags()
File "/home/nino/TorrreP2/TorreP2Test.py", line 34, in leggi_tags
ret = comm.Read(tags)
File "/home/nino/.local/lib/python3.9/site-packages/pylogix/eip.py", line 120, in Read
return self._batch_read(tag)
File "/home/nino/.local/lib/python3.9/site-packages/pylogix/eip.py", line 265, in _batch_read
conn = self.conn.connect()
File "/home/nino/.local/lib/python3.9/site-packages/pylogix/lgx_comm.py", line 49, in connect
return self._connect(connected)
File "/home/nino/.local/lib/python3.9/site-packages/pylogix/lgx_comm.py", line 104, in _connect
ret_data = self.receive_data()
File "/home/nino/.local/lib/python3.9/site-packages/pylogix/lgx_comm.py", line 181, in receive_data
part = self.Socket.recv(4096)
socket.timeout: timed out
(program exited with code: 1)
Press return to continue
#from future import print_function
#import gammu
import sys
import logging
import time
#*********************************************************************************************************************
from pylogix import PLC
from datetime import datetime, timedelta
from threading import Timer
#----------------------------------------------------------------------------------------------------------------------------------------
#Timestamp ******************************************************************************************************************************
def Data_Ora():
DataOraReport = []
timestamp = time.time()
date_time = datetime.fromtimestamp(timestamp)
str_date_time = date_time.strftime("%d/%m/%Y, %H:%M:%S")
DataOraReport = (str_date_time)
return DataOraReport
#----------------------------------------------------------------------------------------------------------------------------------------
#Variabili PLC **************************************************************************************************************************
tags=['Program:TIM.MISURA_06','Program:TIM.MISURA_OK_06']
#-----------------------------------------------------------------------------------------------------------------------------------------
#Legge le tags nel PLC *******************************************************************************************************************
def leggi_tags():
value_tags = []
with PLC() as comm:
comm.IPAddress = '***.***.***.***'
ret = comm.Read(tags)
for r in ret:
#print(r.Value)
value_tags.append(r.Value)
return value_tags
dati_prima = leggi_tags()
did_change = False
#------------------------------------------------------------------------------------------------------------------------------------------
while True:
TimeStampAdesso = Data_Ora()
dati_adesso = leggi_tags()
print(dati_adesso)
# Loop che comprende tutti i valori e li compara
items_variati = [] # <- New list
indici_variati = []
for val_adesso, val_prima in zip(dati_adesso, dati_prima):
# Compara nuovi valori con quelli precedenti
if val_adesso != val_prima:
print(f"I valori {val_adesso} {val_prima} sono diversi")
items_variati.append(val_adesso) # <- Aggiungi un item alla lista
#print(items_variati)
indici_variati.append(dati_adesso.index(val_adesso))
#print(indici_variati)
did_change = True
if did_change:
dati_prima = dati_adesso
did_change = False
# ------------------------------------------------------------------------------------------------------------------------------------------
# Verifica Misure Analogiche Idrauliche ****************************************************************************************************
# Livello Torre *************************************************************************************************************************
LivTorreP2 = (dati_adesso[0]) # integer
LivTorreP2_OK = (dati_adesso[1]) # boolean
MesLiv = []
if (LivTorreP2_OK) == True :
MesLiv.append ("Livello "+ str(LivTorreP2/100) + " mt" + " \U0001F603")
if (LivTorreP2/100) > 4.20 and (LivTorreP2_OK) == True:
MesLiv.append ("Livello "+ str(LivTorreP2/100) + " mt" + " alto \U00002B06")
elif (LivTorreP2/100) < 2.30 and (LivTorreP2_OK) == True:
MesLiv.append ("Livello "+ str(LivTorreP2/100) + " mt" + " basso \U00002B07")
else:
MesLiv.append("Livello " + "***" + " mt" + " \U0001F621")
#------------------------------------------------------------------------------------------------------------------------------------------
print(TimeStampAdesso)
print(MesLiv)
time.sleep(10)
- RaspBerry PI 3
- Raspbian GNU/Linux11 (bulleye)
- Python 3.9.2
- Pylogix 0.8.14
- PLC AB CompactLogix
from pylogix.
Ah, okay, the details about the network are important. Seems like maybe the request makes it to the PLC, but you never get a response. I'll have to recreate the same scenario.
from pylogix.
Good morning everyone. Is there any news regarding this problem? Thanks for your contribution.
from pylogix.
Nothing yet. I'll work on it as soon as I can
from pylogix.
I see what is going on @horus61, I'm working on a fix.
from pylogix.
@horus61, try 0.9.1
from pylogix.
Related Issues (20)
- Unknown Error 255 on Multi-Write when including a string HOT 6
- read tag from 80 sets of plc HOT 22
- Double read packets? HOT 6
- cannot import name 'Adapter' from 'pylogix' HOT 23
- Tag Write falsely reports Success HOT 7
- "Forward open failed" when trying to read tags from Berghof PLC HOT 8
- .GetDeviceProperties always returns DeviceType of "None" HOT 5
- Issues connecting to emulate HOT 7
- micro850 connection HOT 5
- Return data gets jumbled up on a multi write when the tags don't exist. HOT 13
- The return value is different when using a multi write compared to a single write for a string. HOT 4
- cannot get a tag list HOT 3
- Is it possible to inhibit a periodic task? HOT 2
- pylogix - returning a tag list as a row of values HOT 7
- PLC REAL values HOT 5
- Pylogix - compare a previously acquired tag list with the current one HOT 5
- Discover does not work while running pylogix in docker HOT 10
- Invalid Continuation Byte HOT 5
- Do I need to use routing? HOT 20
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pylogix.