Hi. When i scan for devices on the network i get names of the devices. Is there a command to get device name in my programm ?
i found : DED.GetDeviceNameString( DED.GetRoot() ); but then i get his name in the programm. not his name in the network.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Reinier, I ran into the same confusion a while back, so your finding matches what I saw.
DED.GetDeviceNameString(DED.GetRoot()) gives you the name of the device object inside your project, basically the name from the device tree, not the name the scan shows on the network. That scan name is the one the runtime announces, so it comes from the target itself. On a Linux-based runtime that is usually the hostname, or the device name set in the runtime configuration, and on a controller it is whatever is set in the device's own settings or web interface.
So in practice I stopped trying to read the scan name through DED. What worked for me was to check where the name is actually set on that target first, make it match there, and then, if the program really needs the name for logging or on an HMI, read it from that same place, for example the hostname on a Linux target, or just hold it in a retained variable, a small config value that I set once per machine, and check it against the scan after a restart.
If you say which runtime or controller you are using, I can probably point at the exact setting, because it does differ a bit between a PC-based runtime and a hardware PLC. Before you rely on it on a running machine, I would try it in simulation or on a bench setup first, and keep it out of anything safety-related.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi. When i scan for devices on the network i get names of the devices. Is there a command to get device name in my programm ?
i found : DED.GetDeviceNameString( DED.GetRoot() ); but then i get his name in the programm. not his name in the network.
Hi Reinier, I ran into the same confusion a while back, so your finding matches what I saw.
DED.GetDeviceNameString(DED.GetRoot()) gives you the name of the device object inside your project, basically the name from the device tree, not the name the scan shows on the network. That scan name is the one the runtime announces, so it comes from the target itself. On a Linux-based runtime that is usually the hostname, or the device name set in the runtime configuration, and on a controller it is whatever is set in the device's own settings or web interface.
So in practice I stopped trying to read the scan name through DED. What worked for me was to check where the name is actually set on that target first, make it match there, and then, if the program really needs the name for logging or on an HMI, read it from that same place, for example the hostname on a Linux target, or just hold it in a retained variable, a small config value that I set once per machine, and check it against the scan after a restart.
If you say which runtime or controller you are using, I can probably point at the exact setting, because it does differ a bit between a PC-based runtime and a hardware PLC. Before you rely on it on a running machine, I would try it in simulation or on a bench setup first, and keep it out of anything safety-related.