Giter VIP home page Giter VIP logo

Comments (5)

spreeker avatar spreeker commented on June 6, 2024

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.

gijzelaerr avatar gijzelaerr commented on June 6, 2024

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.

Dabbadoeber avatar Dabbadoeber commented on June 6, 2024

Ok thx as soon if i have some spare time i will try this.

from python-snap7.

Dabbadoeber avatar Dabbadoeber commented on June 6, 2024

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.

spreeker avatar spreeker commented on June 6, 2024

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 size

if i change the size to 1 , i get output:

counter 1

00
counter 2

00
counter 3

00
counter 4

00
counter 5

00
counter 6

00
counter 7

00
counter 8

00
counter 9

00
counter 10

00

Gr.


Reply to this email directly or view it on GitHub
#33 (comment)
.

from python-snap7.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.