1

I am having the data in Modbus TCP/IP. I have to read the available data with Apache NiFi. I don't know, which processor have to use exactly (Ex. GetTCP, ListenTCP, Plc4xSourceProcessor). Can you help me on this? Is there any feasibility with Apache NiFi?

Sathishkumar C
  • 91
  • 1
  • 11

2 Answers2

3

the Plc4xSourceProcessor is what you are looking for. The Apache PLC4X project provides drivers for accessling PLCs using various protocols. One of the is the Modbus protocol. So if you use the Plc4xSourceProcessor and configure a modbus connection string and list the addresses you want to collect, then you will be able to do so.

I happen to have written the PLC4X-NiFi Integration documentation on our website just a couple of days ago: https://plc4x.apache.org/users/integrations/apache-nifi.html

I think this will be helpful.

Chris

Christofer Dutz
  • 2,305
  • 1
  • 23
  • 34
  • Thank you for the wonderful artical @Christofer. Now, i am stuck at syntax of "PLC Connection String" and "PLC Resource address String" for modbus protocal. – Sathishkumar C Sep 10 '20 at 09:50
  • 1
    This syntax depends 100% on the type of connection ... so if you're using Modbus, please give this other page here a go: https://plc4x.apache.org/users/protocols/modbus.html – Christofer Dutz Sep 10 '20 at 12:57
  • But in general the connection string should be "modbus://1.2.3.4" (Use the right IP) and then the address strings in the format you like as described on that page. – Christofer Dutz Sep 10 '20 at 12:59
  • I am simulating modbus protocol with WinModbus. My configuration in "Plc4xSourceProcessor" at Apache Nifi, PLC Connection String - modbus://localhost:502 and PLC Resource address String - {test1: {40001}}. I am getting error like "Failed to properly initialize Processor. If still scheduled to run, NiFi will attempt to initialize and run the Processor again after the 'Administrative Yield Duration' has elapsed. Failure is due to org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Invalid address format: org.apache.plc4x.java.api.exceptions.PlcRuntimeException: Invalid address format" – Sathishkumar C Sep 11 '20 at 06:49
  • I think the issue might be that the pure numeric format is something that just recently was added ... I would suggest to use the 0.8.0-SNAPSHOT version. or use "holding-register:1" as address. – Christofer Dutz Sep 11 '20 at 13:15
  • Yeah... this is working great. testData40=holding-register:0; Thanks Christofer. – Sathishkumar C Sep 14 '20 at 08:21
0

I don't really know what Modbus TCP/IP is, but it basically comes down to whether you want NiFi to be a client or a server.

ListenTCP creates a TCP server that is waiting for some client to make a connection and start sending data. The most common case would be a log forwarding system like syslog which can be configured to forward logs to a host/port over TCP.

GetTCP is a client that connects to some host/port which is the server, and starts reading data.

Plc4xSourceProcessor is not part of the official Apache NiFi code, but from quickly looking at it, it seems like more of a client processor similar to GetTCP since you give it a connection string telling it where to connect to.

Bryan Bende
  • 18,320
  • 1
  • 28
  • 39
  • Thank you so much for your response Bryan. What do mean in this statement? "GetTCP is a client that connects to some host/port which is the server, and starts reading data.". Can i have any tutorial or example for GetTCP? It will be more helpful. – Sathishkumar C Sep 05 '20 at 10:12
  • I was explaining the difference between client and server... a server waits for a client to initiate a connection. GetTCP is a client because it initiates a connection to a server that is waiting for something to connect. – Bryan Bende Sep 08 '20 at 13:30