Comments (18)
Hi OldFellow,
Thanks for reporting this issue.
The second issue is a separate issue, can you open a new issue for that?
from python-snap7.
It looks like a signed vs unsigned issue to me @spreeker , what do you think? It is quite weird though, I think read_area
is one of the most used functions in python-snap7, so it should have shown up before?
from python-snap7.
try to work with the "db_read" function! does it also happen there?
I will add to the util.py file.
try:
# try with the standard library
from collections import OrderedDict
except ImportError:
# fallback to Python 2.6-2.4 back-port
from ordereddict import OrderedDict
from python-snap7.
Please keep the python2.6 discussion here #44
from python-snap7.
@oldfellow please teast the "db_read" and an older snap7 to rule out all options. snap7 1.3 came with some endian awareness..
Snap7 1.3.0 is out !!!
(Platform and comfort release)
Snap7 now is runtime endian-aware.
(Runtime = No compilers switches are needed to work with Big-Endian CPUs)
from python-snap7.
i've updated the package in the launchpad PPA (Ubuntu) and homebrew (OS X)
from python-snap7.
db_read has the same behavior like read_area.
Which snap7 should I give a try?
from python-snap7.
Any lower than 1.3 I find the whole issue really weird.
What kind of values are you trying to read? Are only some values wrong and
others good?
On Apr 1, 2015 8:12 AM, "oldfellow" [email protected] wrote:
db_read has the same behavior like read_area.
Which snap7 should I give a try?—
Reply to this email directly or view it on GitHub
#42 (comment)
.
from python-snap7.
did the signature of the function change to unsigned or something since 1.3.0? I can't check this now, in conference
from python-snap7.
With snap7-1.2.1 I have exactly the same behavior.
I guess this must be related to the python wrapper. Using the same snap7.so ( from Version 1.3.0 or 1.2.1 ) with cpp or plain-c works fine.
from python-snap7.
this is the the content of the plc:
DB2:
Byte 0 - 3 Real: 12.34
Byte 4 - 5 WORD: 0xABCD
Byte 6 - 7 INT: 4537
Byte 8 - 9 WORD: 0xFF00
( I use this funtion to print the raw data in client.py line 109 )
print "".join("0x%02x " % b for b in data)
In Windows Environment the result of db_read and read_area is equal:
0x41 0x45 0x70 0xa4 0xab 0xcd 0x11 0xb9 0xff 0x00
On Linux the result look like this:
0x41 0x45 0x70 0x-5c 0x-55 0x-33 0x11 0x-47 0x-1 0x00
As you can see in the last WORD, the 0xff is "translated" into 0x-1.
I agree, that this seems to be a signed / unsigned error. But at what point?
from python-snap7.
When I add the following lines to client.py I can resolve this issue:
- To client.py I add:
import binascii - Before the return of the function db_read, I add the following:
hex_data = binascii.hexlify( data )
data = binascii.unhexlify( hex_data )
return bytearray(data)
I don't really understand, why converting two times solves this issue.
Any idea?
from python-snap7.
it could be a bug in snap7, where the type of the byte is not defined as signed and the compiler functions differently on the two platforms.
from python-snap7.
ah right, it works correctly if you write a C program
from python-snap7.
@oldfellow Could you find out if and what the difference is of the data1 before and the data2 after the
hexilfy steps?
hex_data = binascii.hexlify( data1 )
data2 = binascii.unhexlify( hex_data )
return bytearray(data)
from python-snap7.
Could you try to replace the python2.6 ctypes extension with a newer version?
Googling python2.6 ctypes gives a lot of bug results.
from python-snap7.
Sorry, because I'm working in a blackbox environment I can't change any python evironment.
How can I find out a difference bevore and after the hexlify? What PyCode should I use?
from python-snap7.
hi @oldfellow this is quite an old issue now, sorry about that. Are you still experiencing these problems? Did you manage in the end?
from python-snap7.
Related Issues (20)
- Too much logging in client db_read() method HOT 2
- PLC crashed when executing the "get_cpu_info" function HOT 1
- How to read and write values of type bool using snap7 module?
- Can not use this library to read timers of simatic S7-200 smart PLC HOT 2
- Redundant 400-H get_cpu_state() returning incorrect value.
- Add python 3.12 support, build wheels HOT 2
- RuntimeError: b' ISO : An error occurred during recv TCP : Connection timed out'
- Error in util.Set_String and util.Get_String
- as_db_read() doesnt work
- Wrong values set_lreal
- db[0]['x']=22.33 raises ValueError HOT 2
- Improve doc for area_read in client HOT 2
- Communication between PLC and PC HOT 1
- Can't read from S210 Drive
- Get data block layout
- TypeError: '_ctypes.PyCArrayType' object is not subscriptable HOT 1
- Make client and server a contextmanager HOT 1
- Drop Python 3.8 from metadata and doc HOT 1
- Drop Snap7Library singleton and use python functools caching HOT 1
- version 1.4 broken on python 3.8 HOT 2
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 python-snap7.