Jump to content

Migration von ActiveX.dll to .NET-Driver


Recommended Posts

Quite some time ago I wrote a programm to access a Samba PLC using the ActiveX dll.

I want to migrate to the .net-driver which seems to work fine - but there's one issue. I cannot find an equivalent form the  .write_db within in the .NET-driver.
The command I need to substitute is a single line in the code: "PLC.Write_DB(26637, 1, 2, 1, DBValues)"...


Any help is highly appreciated.

Link to comment
Share on other sites

Thanks Saragani, that was a step forward allthough the handling is quite different to the pld PLC.Write_DB -function.


However, for me there is one issue left:

At some point I need to find out if the PLC is running or if it has been stopped.

I have found the comands plc.run and plc.stop to invoke the behavior but I haven't found an equivalent to the PLC.PLC_GetStatus(x)-command the ActiveX.dll was offering.

Any ideas on this?

Link to comment
Share on other sites

You are correct, there isn't a specific command for it in the .Net Driver, but looking at the source code of the ActiveX communication driver, then you can call plc.SendString("RS")

I'm not sure what are the return values for each state (run and stop), but the code returns Mid(res, 3, 1), meaning 1 character at the 3rd position, for example, for ABCDEFG, it will return C.


Please check and update me if it helped you, and what are the returns strings you get for Run and Stop mode (before and after the Mid / Substring)




Link to comment
Share on other sites

  • 2 weeks later...

Thanks Saragani,

that really did the job. The reply message is was looking for is either "R" (for running), "S" (for stopped) or "?" (for boot mode). I never noticed any other return value.

Why do I need this?
I have put in place some security features, e.g. blocking USB-access while programm is active and user hasn't presented a valid access code to the PLC.  A backdoor is accessing the PLC while in boot mode (putting a finger on Screen during startup), because during boot mode the usb-port isn't block. So I use the return code to identify if the ladder code is running ("R"), if it is stoped ("S") and I just need to run the PLC or if the user is accessing the PLC via boot mode ("?").

If the return value is "?" of it is "S" and stays "S" even after sending a plc.run-comand then I know someone is using my programm via boot mode and hasn't done  the "offical" login with a password.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...