Libnodave and PLCSim

jakubokaj

Level-1
Beiträge
3
Reaktionspunkte
0
Zuviel Werbung?
-> Hier kostenlos registrieren
Dear All,

I have problem with python script and connection with PLCSim via nettoplcsim.
Example from Delphi (included in libnodave) works fine.

Here is my code:
# calculate.py
import ctypes
import os
daveProtoPPI = 10 # PPI for S7 200
daveProtoAS511 = 20 # S5 programming port protocol
daveProtoS7online = 50 # use s7onlinx.dll for transport
daveProtoISOTCP = 122 # ISO over TCP */
daveProtoISOTCP243 = 123 # ISO over TCP with CP243 */
daveProtoISOTCPR = 124 # ISO over TCP with Routing */
daveSpeed9k = 0
daveSpeed19k = 1
daveSpeed187k = 2
daveSpeed500k = 3
daveSpeed1500k = 4
daveSpeed45k = 5
daveSpeed93k = 6
daveBlockType_OB = '8'
daveBlockType_DB = 'A'
daveBlockType_SDB = 'B'
daveBlockType_FC = 'C'
daveBlockType_SFC = 'D'
daveBlockType_FB = 'E'
daveBlockType_SFB = 'F'
class daveOSserialType(ctypes.Structure):
_fields_ = [("rfd", ctypes.c_int),
("wfd", ctypes.c_int)]
print "start skryptu"
#APPDIR = os.path.dirname(os.path.abspath(__file__))
#DLL_LOC = os.path.join(APPDIR, 'libnodave', 'win', 'libnodave.dll')
libnodave = ctypes.windll.LoadLibrary("libnodave.dll")
fds = daveOSserialType()
fds.rdf = libnodave.openSocket(102,'192.168.208.131')
fds.wdf = fds.rdf
if(fds.rfd >= 0):

di = libnodave.daveNewInterface(fds, "IF1", 0 ,daveProtoISOTCP ,daveSpeed187k)
libnodave.daveSetTimeout(di, 5000000)
res = libnodave.daveInitAdapter(di)
print "InitAdapter: " + str(res)
dc = libnodave.daveNewConnection(di,0,0,2)
res = libnodave.daveConnectPLC(dc)
print "ConnectPLC: " + str(res)
buf = ctypes.create_string_buffer(100)
res = libnodave.daveReadBytes(dc,daveBlockType_DB,1,0,2,buf)
print "ReadBytes: " + str(res)


I am not specialist in Python, I try to connect XBMC to PLC via ethernet that's why I need to this.

Wait for any suggestions.
Qba:sad:
 
There is a problem with libnodave when you use pclcsim, you need to do a little fix in the dll.

You can use the dll included in my connectionlib, with this one it should work!
 
Zuviel Werbung?
-> Hier kostenlos registrieren
I've checked libnodave_jfkmod.dll but with the same result ;(
I have no idea where is a problem, parameters in demo program (slot, rack etc) seems to be the same. Nettoplcsim detect connection but nothing more.
 
Ah sorry, you try to connect to NetToPlcSim, that should work with normal libnodave also! Only to PLCSim directly there is an Error!

Should this line:
dc = libnodave.daveNewConnection(di,0,0,2)
not be:
dc = libnodave.daveNewConnection(di,2,0,2)
 
Hello,

Thank You for answer.
In fact I also checked this option (documentation says that this is MPI address and is no important for TCP), situation is the same. NettoPLCSim can detect client connection (I assume after open socket function) and nothing more, no access request.

Results from script:

IDLE 2.6 ==== No Subprocess ====
>>>
start skryptu
InitAdapter: 0
ConnectPLC: -1
ReadBytes: -1025
>>>

I think result from "libnodave.daveConnectPLC(dc)" should be 0 but I have no idea what can be wrong.

How do you connect directly to plcsim, by S7Online and MPI?
 
Zuviel Werbung?
-> Hier kostenlos registrieren
Hello,

Thank You for answer.
In fact I also checked this option (documentation says that this is MPI address and is no important for TCP), situation is the same. NettoPLCSim can detect client connection (I assume after open socket function) and nothing more, no access request.

Results from script:

IDLE 2.6 ==== No Subprocess ====
>>>
start skryptu
InitAdapter: 0
ConnectPLC: -1
ReadBytes: -1025
>>>

I think result from "libnodave.daveConnectPLC(dc)" should be 0 but I have no idea what can be wrong.

How do you connect directly to plcsim, by S7Online and MPI?

Yes, direct connection is done via S7Online and MPI! But this works only with my changed libnodave dll!
 
Zurück
Oben