### Install .NET SDK using Homebrew Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/macos.adoc Installs the .NET SDK using Homebrew, providing an alternative to the official Microsoft installer. ```bash brew install --cask dotnet-sdk8 ``` -------------------------------- ### Start Kafka Server Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/apache-kafka.adoc Starts the Kafka server, which handles message brokering. ```bash bin/kafka-server-start.sh config/server.properties ``` -------------------------------- ### Start Zookeeper Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/apache-kafka.adoc Starts the Zookeeper server, a prerequisite for running Kafka. ```bash bin/zookeeper-server-start.sh config/zookeeper.properties ``` -------------------------------- ### Install .NET SDK 8.0 on Ubuntu Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/linux.adoc Installs the .NET SDK version 8.0 on Ubuntu systems. This involves adding the Microsoft package repository and then installing the SDK. ```bash sudo mkdir -p /etc/apt/keyrings wget https://packages.microsoft.com/keys/microsoft.asc -O /etc/apt/keyrings/microsoft.asc echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/microsoft.asc] https://packages.microsoft.com/ubuntu/24.04/prod noble main" | sudo tee /etc/apt/sources.list.d/microsoft-dotnet.list sudo apt update sudo apt install dotnet-sdk-8.0 ``` -------------------------------- ### Start JQAssistant Web-UI Server Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/jqassistant.adoc Run this command after a build to start the Neo4j server with the JQAssistant web console. This allows for ad-hoc queries and rule development. ```bash mvn jqassistant:server ``` -------------------------------- ### Install plc4xLicencer Tool Source: https://github.com/apache/plc4x/blob/develop/plc4go/README.md Install the plc4xLicencer tool, a generator for adding the Apache license to files. ```bash go install github.com/apache/plc4x-extras/plc4go/tools/plc4xLicencer@latest ``` -------------------------------- ### Install PLC4Py Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/getting-started/plc4py.adoc Install PLC4Py from the GitHub repository using pip. This command installs the package into your global repository. ```bash pip install . ``` -------------------------------- ### Install plc4xGenerator Tool Source: https://github.com/apache/plc4x/blob/develop/plc4go/README.md Install the plc4xGenerator tool, used for generating Serializable and String methods. ```bash go install github.com/apache/plc4x-extras/plc4go/tools/plc4xGenerator@latest ``` -------------------------------- ### GUID Address Examples Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/protocols/opcua.adoc Provides examples of valid OPC UA addresses using GUID identifiers. ```plaintext ns=2;g=09087e75-8e5e-499b-954f-f2a8624db28a ``` ```plaintext ns=2;g=09087e75-8e5e-499b-954f-f2a8624db28a;REAL ``` ```plaintext ns=2;g=09087e75-8e5e-499b-954f-f2a8624db28a;a=Value;REAL ``` -------------------------------- ### Start JQAssistant Server with Neo4j 3 Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/jqassistant.adoc Use this command to start the JQAssistant server when Neo4j 3 support is required. This is necessary when integrating with IntelliJ IDEA's Neo4j plugin. ```bash mvn -Djqassistant.neo4jVersion=3 jqassistant:server ``` -------------------------------- ### Install GCC on Apt-based Systems Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/linux.adoc Installs the GCC compiler using the apt package manager. ```bash sudo apt install gcc ``` -------------------------------- ### Check .NET Version Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/windows.adoc Verify if the .NET SDK is installed, which is typically pre-installed on Windows. Download the installer from the official .NET website if needed. ```bash dotnet --version ``` -------------------------------- ### Running PLC4X with IoTDB Example Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/apache-iotdb.adoc This command demonstrates how to run the PLC4X Java example to collect data from a simulated PLC and write it to Apache IoTDB. It specifies connection details for both PLC4X and IoTDB, along with data mapping and storage group information. ```bash java -jar ..... --connection-string simulated://127.0.0.1 --field-address RANDOM/foo:Integer --polling-interval 1000 --iotdb-address 127.0.0.1:6667 --iotdb-user-name root --iotdb-user-password root --iotdb-sg mi --iotdb-device d1 --iotdb-datatype INT32 --use-jdbc false ``` -------------------------------- ### Install Git using Homebrew Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/macos.adoc Installs Git using the Homebrew package manager if it's not already installed or if an update is required. ```bash brew install git ``` -------------------------------- ### Start Kafka Console Consumer Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/apache-kafka.adoc Starts a console consumer to read messages from the 'test' Kafka topic. ```bash bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning ``` -------------------------------- ### Profinet Connection String Example Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/protocols/profinet.adoc This example demonstrates a Profinet connection string for two devices, test-device-1 and test-device-2, connected on the localhost interface. It includes the GSD directory path and the devices parameter with their respective configurations. ```url profinet:raw://127.0.0.1?gsddirectory=/Profinet/GSD&devices=[[test-device-1,MOD_1,(SUBMOD_1,,SUBMOD_1,)],[test-device-2,MOD_1,(SUBMOD_1,,SUBMOD_1,)]] ``` -------------------------------- ### Install Required Packages Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/infrastructure/vm.adoc Install necessary packages for building site graphics, including `python-seqdiag` and `python-nwdiag`, using apt-get. ```bash sudo apt-get install python-seqdiag ``` ```bash sudo apt-get install python-nwdiag ``` -------------------------------- ### Install OpenJDK using Homebrew Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/macos.adoc Installs OpenJDK using Homebrew, which is a common way to install Java Development Kit on macOS. ```bash brew install openjdk ``` -------------------------------- ### Prepare Release with Maven Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/release/build-tools.adoc Execute this command to start the release preparation process. It will prompt for version information and tag names. ```bash mvn release:prepare ``` -------------------------------- ### Install plc4xbrowser Tool Source: https://github.com/apache/plc4x/blob/develop/plc4go/README.md Install the plc4xbrowser tool, a terminal application for running REPL commands against a PLC using plc4x. ```bash go install github.com/apache/plc4x-extras/plc4go/tools/plc4xbrowser@latest ``` -------------------------------- ### Example Choose Block with Default When Source: https://github.com/apache/plc4x/blob/develop/plc4j/drivers/knxnetip/src/site/asciidoc/knx-device-profiles.adoc This example demonstrates a 'choose' block with a default 'when' condition. The 'when' block will be evaluated if no other 'when' conditions are met. ```xml ``` -------------------------------- ### Install Git on Apt-based Systems Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/linux.adoc Installs Git using the apt package manager. This is typically used on Debian/Ubuntu-based systems. ```bash sudo apt install git ``` -------------------------------- ### Install LibPCAP on Apt-based Systems Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/linux.adoc Installs the libpcap development library, required for raw-ethernet support, using the apt package manager. ```bash sudo apt install libpcap-dev ``` -------------------------------- ### Install plc4xpcapanalyzer Tool Source: https://github.com/apache/plc4x/blob/develop/plc4go/README.md Install the plc4xpcapanalyzer tool, which is used to evaluate plc4x parsing against a pcap file. ```bash go install github.com/apache/plc4x-extras/plc4go/tools/plc4xpcapanalyzer@latest ``` -------------------------------- ### Example Application Using Connection Cache Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/tools/connection-cache.adoc This example demonstrates how to use the CachedPlcConnectionManager to obtain and use PLC connections. Connections are obtained via `getConnection` and are automatically returned to the cache when the try-with-resources block finishes. It includes error handling for various connection and execution exceptions. ```java public static void main(String[] args) throws Exception { PlcConnectionManager connectionManager = CachedPlcConnectionManager.getBuilder().build(); for (int i = 0; i < 10000; i++) { try(PlcConnection connection = connectionManager.getConnection("s7://192.168.1.192")) { if (connection.isConnected()){ PlcReadRequest.Builder builder = connection.readRequestBuilder(); builder.addTagAddress("PollingValue", "%DB1:4.0:BOOL"); PlcReadRequest readRequest = builder.build(); PlcReadResponse syncResponse = readRequest.execute().get(2000, TimeUnit.MILLISECONDS); printResponse(syncResponse); } else { logger.info("PLC is not connected, let's try again to connect"); connection.connect(); } } catch (PlcConnectionException e){ logger.error("Connection exception in trying to connect", e); } catch (CancellationException e){ logger.error("Polling Thread canceled", e); } catch (IllegalStateException e){ logger.error("Error in Netty state machine", e); } catch (ExecutionException e){ logger.error("Interrupted Exception fired", e); } catch (TimeoutException e) { logger.error("Timeout exception fired", e); } TimeUnit.MILLISECONDS.sleep(100); } System.exit(0); } ``` -------------------------------- ### String Address Examples Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/protocols/opcua.adoc Provides examples of valid OPC UA addresses using string identifiers. ```plaintext ns=2;s=HelloWorld/ScalarTypes/Boolean ``` ```plaintext ns=2;s=HelloWorld/ScalarTypes/Boolean;BOOL ``` ```plaintext ns=2;s=HelloWorld/ScalarTypes/Boolean;a=Value;BOOL ``` -------------------------------- ### Full SimpleType POJO Example Source: https://github.com/apache/plc4x/blob/develop/code-generation/protocol-test/src/site/asciidoc/index.adoc A complete Java code example of the generated SimpleType POJO, demonstrating its structure and methods. ```java include::{sourcedir}/org/apache/plc4x/java/test/readwrite/SimpleType.java[] ``` -------------------------------- ### OPC UA Server Configuration Example Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/eclipse-milo.adoc Example configuration file (config.yml) for the OPC UA server. It defines server settings and lists devices with their connection strings and tags. ```yaml --- version: "0.8" dir: {path-to-security-dir} name: "Plc4xOPCUAServer" disableInsecureEndpoint: true devices: - name: "ModbusDevice" connectionString: "modbus-tcp://127.0.0.1:502" tags: - alias: "TemporaryBOOLARRAY" address: "000001:BOOL[10]" - alias: "TemporaryWORD2" address: "400002:WORD" - alias: "TemporaryUINT3" address: "400003:UINT" - alias: "TemporaryINT4" address: "400004:INT" - alias: "TemporaryDINT5" address: "400005:DINT[4]" - alias: "TemporaryREAL6" address: "400006:REAL" - alias: "TemporaryREAL7" address: "400007:REAL" - alias: "TemporaryREAL8" address: "400008:REAL" - name: "SimulationDevice" connectionString: "simulated://127.0.0.1" tags: - alias: "Temporary" address: "RANDOM/Temporary:Integer" tcpPort: 12687 httpPort: 8445 ``` -------------------------------- ### Start Kafka Connect Source Worker (Standalone) Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/apache-kafka.adoc Starts a Kafka Connect worker in standalone mode for testing purposes. Requires configuration files for both the standalone worker and the PLC4X source connector. ```bash bin/connect-standalone.sh config/connect-standalone.properties config/plc4x-source.properties ``` -------------------------------- ### Check LibPCAP Installation Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/windows.adoc Check for the presence of NPcap library files in system directories to confirm support for raw ethernet transport. If not found, download and install from the official NPcap website. ```bash C:\Windows\System32\packet.dll ``` ```bash C:\Windows\System32\wpcap.dll ``` ```bash C:\Windows\SysWOW64\packet.dll ``` ```bash C:\Windows\SysWOW64\wpcap.dll ``` -------------------------------- ### PLC4X Connection String Example Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/apache-nifi.adoc Example of a PLC4X connection string and a PLC resource address string for configuring a PLC4X source processor in NiFi. Consult PLC4X documentation for driver-specific address formats. ```text PLC connection String: s7://192.168.23.30 PLC resource address String: time-value=%DB2:8:TIME;string-value=%DB2:30.0:STRING(10) ``` -------------------------------- ### Initialize Scraper Configuration Builder Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/tools/scraper.adoc Start building the Scraper configuration by instantiating the `ScraperConfigurationTriggeredImplBuilder`. ```java ScraperConfigurationTriggeredImplBuilder builder = new ScraperConfigurationTriggeredImplBuilder(); ``` -------------------------------- ### Check Java Version Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/windows.adoc Verify if Java is installed and meets the minimum version requirement (Java 11). Installation instructions for Oracle OpenJDK 21 are provided, emphasizing the configuration of the JAVA_HOME environment variable. ```bash java --version ``` -------------------------------- ### Read Extended Registers Examples Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/protocols/modbus.adoc Examples for reading extended registers starting at address 50. Specify the address and the number of registers to read in square brackets, e.g., 'extended-register:50[10]'. Other formats include '600050[10]', '6x00050[10]', '60050[10]', and '6x0050[10]'. ```modbus extended-register:50[10] ``` ```modbus 600050[10] ``` ```modbus 6x00050[10] ``` ```modbus 60050[10] ``` ```modbus 6x0050[10] ``` -------------------------------- ### Read Extended Registers Near End of File Record Examples Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/protocols/modbus.adoc Examples for reading extended registers starting at address 9995. This request may be split into multiple Modbus protocol requests. Formats include 'extended-register:9995[10]', '609995[10]', '6x09995[10]', '69995[10]', and '6x9995[10]'. ```modbus extended-register:9995[10] ``` ```modbus 609995[10] ``` ```modbus 6x09995[10] ``` ```modbus 69995[10] ``` ```modbus 6x9995[10] ``` -------------------------------- ### Asynchronous PLC Communication Example Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/getting-started/plc4py.adoc This Python script demonstrates asynchronous communication with a PLC using PlcDriverManager. It connects to a Modbus device, builds a read request for a specific tag, executes the request, and prints the response code. Ensure you have asyncio and plc4py installed. ```python import asyncio from plc4py.PlcDriverManager import PlcDriverManager connection_string = "modbus://127.0.0.1:5020" driver_manager = PlcDriverManager() async def communicate_with_plc(): """ Asynchronously communicates with a PLC using a PlcDriverManager. This function establishes a connection to the PLC defined by the connection_string. It builds a read request for a specific item ("Random Tag" in this case) using the connection's read request builder. The request is then executed asynchronously, and the response code is printed. """ print(f"Connecting to plc: {connection_string}") async with driver_manager.connection(connection_string) as connection: print(f"Connected to {connection_string}") with connection.read_request_builder() as builder: print(f"Building read request") builder.add_item("Random Tag", "4x00001[10]") request = builder.build() print(f"Request built") print(f"Executing request") response = await connection.execute(request) print(f"Request executed") print(f"Response code: {response.response_code}") asyncio.run(communicate_with_plc()) ``` -------------------------------- ### Create Main Application File Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/getting-started/plc4go.adoc Creates a basic Go application file with an empty main function. ```go package main func main() { } ``` -------------------------------- ### Install Homebrew Package Manager Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/macos.adoc Installs Homebrew, a package manager for macOS, which is used to install most of the required libraries. Ensure Homebrew is installed before proceeding with other installations. ```bash /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" ``` -------------------------------- ### Install with Neo4j 3 Support Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/jqassistant.adoc Execute this command to build the project while forcing JQAssistant to use Neo4j 3. This ensures the data directory is created in the Neo4j 3 format, compatible with the IntelliJ plugin. ```bash mvn -Djqassistant.neo4jVersion=3 clean install ``` -------------------------------- ### Initialize Go Project Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/getting-started/plc4go.adoc Initializes a new Go project by creating a go.mod file. This is similar to Maven's pom.xml. ```go go mod init main ``` -------------------------------- ### Build Project with Profiles and Tests Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/release/validation.adoc Build the project with all 'with-xyz' profiles and tests enabled, using an empty Maven local repository to ensure a clean build. ```bash mvn clean install -Dmaven.repo.local=../.m2 ``` ```bash mvn clean install -D"maven.repo.local"="../.m2" ``` -------------------------------- ### Check Git Version Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/windows.adoc Verify if Git is installed and accessible. If not, install it using Chocolatey. ```bash git --version ``` ```bash choco install git ``` -------------------------------- ### Prepare PLC Subscription Request (v0.10.0) Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/getting-started/plc4go.adoc Prepares a subscription request for PLC data, including change-of-state and cyclic items. Requires KNX protocol for demonstration. ```go // Prepare a subscription-request subscriptionRequest, err := connection.SubscriptionRequestBuilder(). AddChangeOfStateItem("heating-actual-temperature", "*/*/10:DPT_Value_Temp"). AddChangeOfStateItem("heating-target-temperature", "*/*/11:DPT_Value_Temp"). AddCyclicItem("heating-valve-open", "*/*/12:DPT_OpenClose", 500 * time.Millisecond). AddItemHandler(knxEventHandler). Build() if err != nil { fmt.Printf("Error preparing subscription-request: %s", connectionResult.Err.Error()) return } ``` -------------------------------- ### Install GCC on Yum-based Systems Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/linux.adoc Installs the GCC compiler using the yum package manager. ```bash sudo yum install gcc ``` -------------------------------- ### Build All PLC4X Modules with Maven Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/building.adoc Build all available language modules (C, .Net, Go, Java, Python) and run all tests using the specified Maven profiles. ```bash mvn -P with-c,with-dotnet,with-go,with-java,with-python install ``` -------------------------------- ### Configure and Deploy PLC4X Kafka Source Connector Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/integrations/apache-kafka.adoc Example of how to configure and deploy the PLC4xSourceConnector using the Kafka Connect REST API. Ensure the connector class and task settings are correctly specified. ```bash curl -X POST -H "Content-Type: application/json" --data '{"name": "plc-source-test", "config": {"connector.class":"org.apache.plc4x.kafka.Plc4xSourceConnector", // TODO: Continue here ... "tasks.max":"1", "file":"test.sink.txt", "topics":"connect-test" }}' http://localhost:8083/connectors ``` -------------------------------- ### Download and Deploy CMake Binaries Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/windows.adoc Instructions for downloading and deploying specific CMake binary versions for Windows ARM64 architecture. ```bash https://repo.maven.apache.org/maven2/com/googlecode/cmake-maven-project/cmake-binaries/3.27.7-b1/cmake-binaries-3.27.7-b1-windows-arm_64.jar ``` ```bash https://repo.maven.apache.org/maven2/com/googlecode/cmake-maven-project/cmake-binaries/3.27.7-b1/cmake-binaries-3.27.7-b1-windows-arm64.jar ``` -------------------------------- ### Install Python 3 on Yum-based Systems Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/linux.adoc Installs Python 3 using the yum package manager. ```bash yum intall python3 ``` -------------------------------- ### Install Python 3 on Apt-based Systems Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/linux.adoc Installs Python 3 using the apt package manager. ```bash sudo apt install python3 ``` -------------------------------- ### Check GCC Version Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/preparing/windows.adoc Verify if GCC is installed for PLC4C support. If not, install MinGW using Chocolatey. ```bash gcc --version ``` ```bash choco install mingw ``` -------------------------------- ### SZL Request Example Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/protocols/s7.adoc Demonstrates the process of constructing and executing an SZL request for PLC identification and firmware. Requires setting up a connection, creating a request instance, adding the PLCTag, preparing and executing the request, and processing the byte array response. ```java String connectionUrl = "s7://192.168.0.1/4"; // (01) Establish connection PlcConnection connection = PlcConnectionManager.getConnection(connectionUrl); // (02) Create request constructor instance PlcRequest request = connection.request(); // (03) Add the associated PLCTag to the diagnostic list // SZL_ID=0x0012 and INDEX=0x0000 for identification and firmware request.addTag(new S7Tag("SZL", "0x0012", "0x0000")); // (04) Prepare the request PlcRequest.Builder requestBuilder = request.builder(); // (05) Execute the request PlcResponse response = requestBuilder.build().execute(); // (06) Check if the response is valid if (response.getResponseCode() == PlcResponseCode.OK) { // (07) Obtain the data stream as an array of bytes byte[] data = response.getRawData(); // (08) Process the data stream // ... } ``` -------------------------------- ### Numeric Address Examples Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/users/pages/protocols/opcua.adoc Provides examples of valid OPC UA addresses using numeric identifiers. ```plaintext ns=1;i=1337 ``` ```plaintext ns=1;i=1337;DINT ``` ```plaintext ns=1;i=1337;a=Value;DINT ``` -------------------------------- ### PLC4X Maven Plugin Configuration Example (Java S7 Driver) Source: https://github.com/apache/plc4x/blob/develop/website/asciidoc/modules/developers/pages/code-gen/index.adoc This XML configuration demonstrates how to set up the PLC4X Maven plugin to generate a Java S7 driver. It specifies the protocol name, language name, and includes the necessary plugin configuration within a Maven project's pom.xml. ```xml