Jump to content

The latest .Net drivers for using 'Unitronics.ComDriver.Security.dll' download location


Recommended Posts

Hi Saragani,

Can I change the PLC ethernet communication password using the api?

This what  I have  done:

            var pwdStorage = PLCFactory.PasswordStorage;
            pwdStorage.SetPassword("Uni1237@", "168673.....");
            ethernet.Password = "Uni1237@";

I dont know if this is the rigth way to change the plc communication password (It's not work), can it done?

Link to comment
Share on other sites

No, you can't affect the password inside the PLC with the API. It must be done from the Ladder code.

Password Storage is for caching the password. When the password is correct, then it's being automatically saved in the storage for the specific PLC.

The default password storage is RAM storage, which means that it's being deleted when you close your application. The communication driver also supports an SQLite password storage out of the box, so you can use it and it will keep the password encrypted inside the SQLite DB, and will retain it after you close your app.

Link to comment
Share on other sites

Thanks, There is a way to affect (change) the communication password in the PLC memory by sending something using the PLC protocol (using the apl)?

If I know the PLC password and I whant to change it only in the PLC memory for the connection session.. 

Link to comment
Share on other sites

No, you cannot change it only for a session.

The only way to change it is using the Ladder. You can have a code in your ladder that checks for a specific bit, and then the bit is set (Normally open contact), then reset the bit and then call Set PCOM Password ladder element.

The Set PCOM Password ladder element is working on a vector of MIs or XIs, so if you know which MIs (or XIs) you are using as the password, then you can first use the communication driver in order to set them, and only then set the bit that sets the PLC password, then you will be able to change the password.

Please note that once Set PCOM Password is called, then session will become protected again, and it will not communicate with your program until you  either close the socket, or actively call ethernet.CheckPlcPassword();

Since your cached password will now be incorrect, then you will get a ComDriveUnauthorizedAccessException. You should handle it and ask for the new password from the user, or set it (if you know its value) on the ethernet object.

Link to comment
Share on other sites


About SB 314 "Block PC access to PLC. OFF by default. When ON: access via VisiLogic, RA, etc. blocked"

If I set it to 1 then how to revert it to 0 if I cant connect anymore via the VisiLogic or the API?

Another thing, by sending new data to "Ethernet Password Offset" (For example MI 100) it's will efentc somthing?

Link to comment
Share on other sites

Probably only physically with Ladder or using "Info". If you need to access the PLC, then don't block it.

If you are just setting the data to the Ethernet Password Offset without re-calling the Set PCOM Password, then it won't affect. The password is copied from the Ethernet Password Offset to another location in RAM, so it won't be tampered while PLC is doing some manipulations on the operands.

Link to comment
Share on other sites

Thanks Saragani,

How can I re-calling the 'Set PCOM Password' ?

The API support it maybe by sending the rigth operand?

I need to develope  funcunality that can change the password (PCOM), so i need to find a way to do this (using API)

The senario:

1. Connect the plc using known PCOM password

2. Change the PCOM password for the next connection (this what i need to solve)



Link to comment
Share on other sites

You will need to have a code in your Ladder that will change the password (So you must change the code in your PLC for that), something like:

The password can be 8 to 16 characters, and since each character takes 1 byte, and MI is Int16 (2 bytes) then 8 MIs should be reserved for the password (max length). I would also take 1 extra MI (for null termination. I'm not sure if it's needed), so in this case, you need to make sure that MIs 100 to 108 are not in use by anything else in your project, but for password.


Then you need to write the password to your PLC

var password = "MyPassword"; // Must be english only characters (can also contain numbers). No hebrew or any other language
short[] passwordValues = new short[8];

Buffer.BlockCopy(ASCIIEncoding.ASCII.GetBytes(password), 0, passwordValues, 0, password.Length);

var rw = new ReadWriteRequest[1];
var wo = new WriteOperands()
    NumberOfOperands = 8,
    OperandType = OperandTypes.MI,
    StartAddress = 100, // The Ethernet Password Offset
    Values = passwordValues.Cast<object>().ToArray(),

rw[0] = wo;

plc.ReadWrite(ref rw);


And then, after the Write Operands request succeeds, then you set the Set password bit (MB 0), by:

rw = new ReadWriteRequest[1];
wo = new WriteOperands()
    NumberOfOperands = 1,
    OperandType = OperandTypes.MB,
    StartAddress = 0, // Set password Bit offset
    Values = new object[] { 1 },

rw[0] = wo;

plc.ReadWrite(ref rw);


I did not test this code.

You should have an accessible screen in your HMI were you can set the password to MI 100 from there, and also set bit MB 0 by pressing a button, so just in case something went wrong and you can't communicate with the PLC (for example, a bug in your code, or unknown password that was set to PLC), then you could restore password and communication.


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...