Comments (5)
Hello Rick! It could be very well you are the first reading out merker bytes. It could be that that constant is missing. You could try to read the source of snap7 and see which value s7areamk should be.
Read array returns a byte array which you need to interpret / cast to a python data type. There are are many examples of that in the snap7 python library.
from python-snap7.
S7AreaMK
is defined in snap7.snap7types
.
You should import it first, so above your read_area
you should put:
from snap7.snap7types import S7AreaMK
from python-snap7.
Ok thx as soon if i have some spare time i will try this.
from python-snap7.
Hello Gijs i tried it, bu no luck probably i do something wrong this the function i use:
def test_MB_read():
global client
counter = 0
size = 2
start = 0
db = 0
data = bytearray(size)
while counter < 10:
counter = counter + 1
from snap7.snap7types import S7AreaMK
data = client.read_area(S7AreaMK,db , start, size)
print('counter ' + str(counter))
print(type(data))
print ''.join('{:02x}'.format(x) for x in data)
time.sleep(1)
output:
ERROR:snap7.common:CPU : Invalid Transport size
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pibrella.py", line 285, in handle_callback
self.handle_pressed(self)
File "./example.py", line 82, in Sequence
test_MB_read()
File "./example.py", line 50, in test_MB_read
data = client.read_area(S7AreaMK,db , start, size)
File "/usr/local/lib/python2.7/dist-packages/snap7/client.py", line 185, in read_area
check_error(result, context="client")
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 65, in check_error
raise Snap7Exception(error)
snap7.snap7exceptions.Snap7Exception: CPU : Invalid Transport size
if i change the size to 1 , i get output:
counter 1
class 'snap7.client.c_byte_Array_1'
00
counter 2
class 'snap7.client.c_byte_Array_1'
00
counter 3
class 'snap7.client.c_byte_Array_1'
00
etc........
Gr.
from python-snap7.
Ik think you are trying read a merker BYTE!. which is just 1 byte long. so
the size should always be 1
the import statemetnt should be above all your other code.
The code you are writing now 10 times reads Merker byte 0 from db 0 , once
every second for 10 seconds. and it probably is just 1 byte :)
you should still convert te byte value, to someting pythonic.
go read the official snap7 documentation http://snap7.sourceforge.net/
it should have everything you need!
Stephan.
On Fri, Oct 17, 2014 at 9:27 AM, Dabbadoeber [email protected]
wrote:
Hello Gijs i tried it, bu no luck probably i do something wrong this the
function i use:def test_MB_read():
global client
counter = 0
size = 2
start = 0
db = 0
data = bytearray(size)
while counter < 10:
counter = counter + 1
from snap7.snap7types import S7AreaMK
data = client.read_area(S7AreaMK,db , start, size)
print('counter ' + str(counter))
print(type(data))
print ''.join('{:02x}'.format(x) for x in data)
time.sleep(1)output:
ERROR:snap7.common:CPU : Invalid Transport size
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pibrella.py", line 285, in
handle_callback
self.handle_pressed(self)
File "./example.py", line 82, in Sequence
test_MB_read()
File "./example.py", line 50, in test_MB_read
data = client.read_area(S7AreaMK,db , start, size)
File "/usr/local/lib/python2.7/dist-packages/snap7/client.py", line 185,
in read_area
check_error(result, context="client")
File "/usr/local/lib/python2.7/dist-packages/snap7/common.py", line 65, in
check_error
raise Snap7Exception(error)
snap7.snap7exceptions.Snap7Exception: CPU : Invalid Transport sizeif i change the size to 1 , i get output:
counter 1
00
counter 200
counter 300
counter 400
counter 500
counter 600
counter 700
counter 800
counter 900
counter 1000
Gr.
—
Reply to this email directly or view it on GitHub
#33 (comment)
.
from python-snap7.
Related Issues (20)
- 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
- Snap7Exception is not used HOT 1
- Replace `OrderedDict` with the built-in `dict` HOT 1
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.