Bisku Posted March 15 Report Share Posted March 15 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 More sharing options...
Saragani Posted March 17 Report Share Posted March 17 There is another DLL called Unitronics.DataTables.dll, which uses the .Net driver. It lets you write and read values from data tables. 1 Link to comment Share on other sites More sharing options...
Bisku Posted March 19 Author Report Share Posted March 19 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 More sharing options...
Saragani Posted March 19 Report Share Posted March 19 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 More sharing options...
Bisku Posted April 1 Author Report Share Posted April 1 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 More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now