Execute PVI-SNMP commands for B&R plcs
SNMP commands enable remote network configuration and monitoring of B&R PLCs without physical access. Anyone who uses B&R Automation Studio has unconsciously used SNMP commands at some point when temporarily assigning a new IP address to a controller on the network via the "Online/Settings" menu. Unfortunately, these functions are not yet available in the Runtime Utility Center (RUC). The SNMP functions are part of PVI. This project therefore utilizes these functions and provides them as simple commands.
Please note that Automation Studio 6 disables the SNMP protocol by default in new projects. However, if the target is switched to BOOT mode, SNMP should be enabled again.
Based on my findings so far, PVI version 4.12 can also be used with Automation Runtime >= 6.0. Therefore, brsnmp.exe version 1.0 should still work in this case as well.
However, if only PVI version 6 is installed, brsnmp.exe version 1.1 must be used. There were some SNMP issues with PVI 6, but these were resolved in PVI 6.5.2.
download MS-Windows binary from https://github.com/hilch/brsnmp/releases
- Windows: 32-bit MinGW compiler (for PviCom.lib compatibility)
- MSYS2: Recommended for managed, pre-built toolchain
-
Download and run the MSYS2 installer for Windows
-
Open the MSYS2 MINGW32 terminal
-
Install the 32-bit MinGW toolchain:
pacman -S --noconfirm --needed mingw-w64-i686-toolchain
.\build.ps1 release # Build release executable
.\build.ps1 debug # Build debug executable
.\build.ps1 clean # Clean build outputs
.\build.ps1 -Help # Show usagemingw32-make release # Build release executable
mingw32-make debug # Build debug executable
mingw32-make clean # Clean build outputs- Press
Ctrl+Shift+Bto run the default build task (Release) - Use
Ctrl+Shift+P→Tasks: Run Taskto select other tasks (Debug, Clean, etc.)
Compiled binaries are placed in:
- Release:
bin/Release/brsnmp.exe(optimized, no symbols) - Debug:
bin/Debug/brsnmp.exe(with debug symbols)
Use within Runtime Utility Center *.pil file to setup a new or unreachable CPU in BOOT state via network without need of Automation Studio.
see Examples
-h, --help this help
-v, --version software version
-f=<EXPR>, --filter=<EXPR> Filter(regular expression following ECMA syntax)
-t=<MS>, --timeout=<MS> SNMP Line Timeout [ms], default: <3000>
-l, --list list MAC addresses of available B&R plc
-d, --details list detailed properties of available B&R plc
--<NAME>=<VALUE> set parameter <NAME> to <VALUE> (see --details)outputs the program version in JSON e.g.
{
"brsnmp":"0.1",
"build-time":"09:47:24",
"build-date":"Nov 27 2018"
}sets a filter for the operations to be executed (highly recommended if you plan to set the ip settings 😬 ). The filter is applied to a --details - output. The filter is an ECMA Regual Expression regex101.com. But in most cases a simple text should be sufficient.
--filter=targetTypeDescription.+X20CP\d{4}
sets filter to all X20-CPUs (regular expression)
--filter=arVersion.+I.4\.34
sets filter to AR-Version I4.3.4 (regular expression)
--filter=macAddress.+00-60-65-3a-39-10
sets filter to given MAC address (regular expression)
--filter=X20CP3585
sets filter for X20CP3585. (simple filter, no regex. 'X20CP3585' must not have be used as hostname in this case)
--filter=$LAST
sets filter to the expression from previous call (V1.0++)
(all filter expressions are stored in TEMP directory)
--filter=
clears previous filter settings and sets filter to 'all' (V1.0++)
--filter=.*
sets filter to 'all'. (As this expression is default, it can be omitted.)
outputs a list of MAC of reachable PLCs as JSON array e.g.
[
"00-60-65-16-fd-da"
,"00-60-65-23-bd-1a"
,"00-60-65-32-cb-48"
,"00-60-65-44-92-0f"
]outputs a detailed list of reachable PLCs as JSON array of objects e.g.
[
{
"targetTypeDescription":"X20CP1583",
"serialNumber":"D45B0168612",
"cfSerialNumber":"000060076643A1000085",
"arVersion":"B04.45",
"arVersionNorm":"04.45.2",
"arState":"4",
"arBootPhase":"40",
"deviceName":"IF2",
"macAddress":"00-60-65-16-fd-da",
"baudrate":"0",
"ipAddress":"192.168.0.14",
"subnetMask":"255.255.255.0",
"ipMethod":"0",
"nodeNumber":"129",
"inaNodeNumber":"129",
"inaActivated":"1",
"inaPortNumber":"11159",
"snmpMode":"2",
"clusterHostName":"",
"anslPortNumber":"11169",
"processCtrlState":"65535",
"redAvailable":"0",
"switchoverLevel":"0",
"hostName":"br-automation",
"defaultGateway":"",
"dnsActivated":"0",
"dnsFromDhcp":"0",
"dnsServer1":"",
"dnsServer2":"",
"dnsServer3":""
}
]possible values and their meanings:
FAQ: how can I store this list ?
Answer: brsnmp --details > details.json
sets parameter <NAME> to <VALUE> e.g.
ipAddress=192.168.0.14
subnetMask=255.255.255.0
if <VALUE> is surrounded by '%' character an environment variable is used e.g.
```batch
ipAddress=%IP_ADDRESS%
(only parameters which are declared RW can be written. see description of --details)
brsnmp comes „as is“, e.g. without support and warranty. You can freely copy it but use it at your own risk.
brsnmp requires PVI 4.x. it needs a previously installed PVI Development Setup to run. Beware: if you do not own a PVI license 1TG0500.02 (+ TG Guard e.t. 0TG1000.02) PVI will run for two hours only. After this period brsnmp will stop working and PVI-Manager must be stopped and restarted again. Contact your local B&R office for a license.
If using brsnmp with Runtime Utility Center
StartPviMan "LoadLocal"
at the beginning of *.pil and
StopPviManat the end of *.pil is recommended.
If you prefer a IDE Code::Blocks is suitable. Find a project file for it in the repo.
Thanks to https://github.com/adishavit/argh for the command line parser. Additional thatnks to https://github.com/nlohmann/json for the JSON lib.