How To Find Your B&R PLC in a network with Python

Hello community,

There are often reports in the community of problems finding a B&R PLC in the network to connect with AS.

Unfortunately, for security reasons, searching via AS Online Settings (SNMP) and Ping (ICMP) is also becoming increasingly difficult.

There are already several posts dedicated to this topic:

I would like to add another (rather nerdy) option, provided that PVI (also required for AS) and Python are installed.

Nerdy because you have to use the command line.

create an empty folder and change to it:

md findplc
cd findplc

To install external Python modules, it is always a good idea to use a ā€˜virtual environment’.

py -m venv venv
venv\Scripts\activate
py -m pip install --upgrade pip
pip install pvipy

if everything went fine you should be able to execute a scan command: Anslscan <network address>

where <network> is an IP4 network address specification.
For example, the following address specifications are equivalent: 192.168.1.0/24 and 192.168.1.0/255.255.255.0

e.g.

Anslscan 192.168.1.0/24

could output this

256 hosts were checked.
Target: 1A4000.00, AR: I4.93, IP:192.168.1.68, Status:RUN
Target: 1A4000.00, AR: V6.00, IP:192.168.188, Status:RUN
2 targets found

(As this command performs a port scan via a further IP address range, the system administrator may notice this unpleasantly.)

There are two more commands available:

Inascan <network address>

which works similar but is intended for old Automation Runtime < 4.X using INA2000 protocol.

and

Snmpscan

which uses PVI’s SNMP line.

If your sysadmin blocks you or if your PC goes up in flames don’t blame me.

Project Sources are hosted here.

16 Likes

Hello again,

I’ve also put together a graphical user interface for these tasks (Pvi.py >= 1.2.11) now which can be started by:

Plcwatch

Since PVI6 provides ANSL and SNMP lines only I skipped the INA search.

if you installed a PVI6 - Version only then change to PVI 6.5.2++ since this fixed some SNMP issues.

I am still on PVI4 which seems to work with AR6 targets without issues.

ā€˜Targets/Search for Targets (ANSL)’: You can select a network adapter installed in your machine or type in a network addresse manually:

ā€˜Targets/Search for Targets (SNMP)’: You can select a target to change its network adapters:

If you picked a ANSL activated target it is possible to watch and change its variables, clocktime, restart it etc:

if you face issues then use the ā€˜Issues’ section in Github repository, please.

3 Likes