Modbus TCP adapter usage with greengrass V2

0

Hi,

Am I able to use the Greengrass Modbus TCP Protocol Adapter in greengrass v2 as a component. I have a modbus device connected to my greengrass edge device with a fixed IP and trying to connect to it, however I am experiencing some errors in trying to connect to the device.

Here is the log:

2022-08-19T15:09:11.351Z [INFO] (Copier) aws.greengrass.labs.ModbusTCP: stdout. Invoked shutdown hook.. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:09:13.150Z [INFO] (Copier) aws.greengrass.labs.ModbusTCP: Run script exited. {exitCode=143, serviceName=aws.greengrass.labs.ModbusTCP, currentState=STOPPING}

2022-08-19T15:10:24.400Z [INFO] (pool-2-thread-17) aws.greengrass.labs.ModbusTCP: shell-runner-start. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=STARTING, command=["java -jar C:\greengrass\v2\packages\artifacts\aws.greengrass.labs.ModbusTCP\1...."]}

2022-08-19T15:10:28.112Z [WARN] (Copier) aws.greengrass.labs.ModbusTCP: stderr. Aug 19, 2022 8:10:27 AM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onConnectionSetup. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:10:28.114Z [WARN] (Copier) aws.greengrass.labs.ModbusTCP: stderr. INFO: Socket connection \.\pipe\NucleusNamedPipe-Cgreengrassv2:8033 to server result [AWS_ERROR_SUCCESS]. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:10:28.401Z [WARN] (Copier) aws.greengrass.labs.ModbusTCP: stderr. Aug 19, 2022 8:10:28 AM software.amazon.awssdk.eventstreamrpc.EventStreamRPCConnection$1 onProtocolMessage. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:10:28.402Z [WARN] (Copier) aws.greengrass.labs.ModbusTCP: stderr. INFO: Connection established with event stream RPC server. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:10:29.139Z [WARN] (Copier) aws.greengrass.labs.ModbusTCP: stderr. SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:10:29.140Z [WARN] (Copier) aws.greengrass.labs.ModbusTCP: stderr. SLF4J: Defaulting to no-operation (NOP) logger implementation. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:10:29.141Z [WARN] (Copier) aws.greengrass.labs.ModbusTCP: stderr. SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.. {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

2022-08-19T15:10:30.455Z [INFO] (Copier) aws.greengrass.labs.ModbusTCP: stdout. Connected: ModbusConfiguration(endpoints=[Endpoint(host=169.254.216.147, port=502, timeout=null, devices=[Device(name=PacketPower-41E4-0000-0000-0B23, unitId=0)])]). {scriptName=services.aws.greengrass.labs.ModbusTCP.lifecycle.Run, serviceName=aws.greengrass.labs.ModbusTCP, currentState=RUNNING}

Here is my recipe:


{
  "RecipeFormatVersion": "2020-01-25",
  "ComponentName": "aws.greengrass.labs.ModbusTCP",
  "ComponentVersion": "1.0.0",
  "ComponentType": "aws.greengrass.generic",
  "ComponentDescription": "Modbus TCP protocol adapter",
  "ComponentPublisher": "Amazon",
  "ComponentConfiguration": {
    "DefaultConfiguration": {
      "Modbus": {
        "Endpoints": [
          {
            "Host": "169.254.216.147",
            "Port": 502,
            "Devices": [
              {
                "Name": "PacketPower-41E4-0000-0000-0B23",
                "UnitId": 0
              }
            ]
          }
        ]
      },
      "accessControl": {
        "aws.greengrass.ipc.pubsub": {
          "aws.greengrass.labs.ModbusTCP:pubsub:1": {
            "policyDescription": "Allows publish to all topics.",
            "operations": [
              "aws.greengrass#PublishToTopic"
            ],
            "resources": [
              "*"
            ]
          },
          "aws.greengrass.labs.ModbusTCP:pubsub:2": {
            "policyDescription": "Allows subscribe to all topics.",
            "operations": [
              "aws.greengrass#SubscribeToTopic"
            ],
            "resources": [
              "*"
            ]
          }
        }
      }
    }
  },
  "Manifests": [
    {
      "Platform": {
        "os": "/linux|darwin/"
      },
      "Name": "UNIX",
      "Lifecycle": {
        "Run": "java -jar {artifacts:path}/ModbusTCP-1.0.0.jar"
      },
      "Artifacts": [
        {
          "Uri": "s3://peamans-components/artifacts/com.gateway.modbustcp/ModbusTCP-1.0.0.jar",
          "Digest": "Nph2h/xpODOMC42ZKGEeslrQVXYsgfGD931GGkuKkiY=",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Read": "OWNER",
            "Execute": "NONE"
          }
        }
      ]
    },
    {
      "Platform": {
        "os": "windows"
      },
      "Name": "Windows",
      "Lifecycle": {
        "Run": "java -jar {artifacts:path}\\ModbusTCP-1.0.0.jar"
      },
      "Artifacts": [
        {
          "Uri": "s3://peamans-components/artifacts/com.gateway.modbustcp/ModbusTCP-1.0.0.jar",
          "Digest": "Nph2h/xpODOMC42ZKGEeslrQVXYsgfGD931GGkuKkiY=",
          "Algorithm": "SHA-256",
          "Unarchive": "NONE",
          "Permission": {
            "Read": "OWNER",
            "Execute": "NONE"
          }
        }
      ]
    }
  ],
  "Lifecycle": {}
}

Thanks for any help!

已提問 2 年前檢視次數 732 次
3 個答案
0

Hello,

Based on the log which you provided there are no errors. Everything there is completely normal.

Are you experiencing problems, if so:

  1. What are you doing
  2. What did you expect to happen
  3. What actually happened
AWS
專家
已回答 2 年前
0

Hi Michael, Thanks for your reply. Love your videos! I suppose my next questions would be where do I go from here? I would like to get the below example to work.

Send Modbus TCP command using Greengrass IPC local messages You can send a command to Modbus device by publishing a request to the following topic.

modbus/request/{device name} Sample request { "id": "TestRequest", "function": "ReadCoils", "address": 1, "quantity": 1 }

However how do I achieve this? do I need to modify the Modbus TCP adapter recipe and add another artifact that handles the IPC messaging? I already have one that is doing my MQTT handling.. should I just add it into that one?

已回答 2 年前
  • You can add this logic into your existing component, that design is up to you, I don't know what is best for you.

    You do not modify the existing Modbus recipe. You create a new component, or update an existing component, to use the local pubsub IPC methods and perform the interaction with the modbus component.

    If that's overly complicated, you definitely do not need to use the modbus component at all. Your component can run a modbus client and directly connect to whatever devices you want.

0

Hi,

I have successfully been able to connect to the modbus slave device, however I am unable to read the data. I tried using a command line modbus tool and it works, however when using the same addresses and count for the modbus component I am getting errors.

Here is the response of the modbus command tool:


C:\modpoll-3.10\win>modpoll -a 1 -c 1 -r 602 -m tcp 169.254.216.147
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3
Slave configuration...: address = 1, start reference = 602, count = 1
Communication.........: 169.254.216.147, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave... (Ctrl-C to stop)
[602]: 1204
-- Polling slave... (Ctrl-C to stop)

However when using this code

message = { "id": "TestRequest", "function": "ReadInputRegisters", "address": 602, "quantity": 1 }

on the modbus-TCP adapter I get this error:

com.gateway.mqtt: stdout. Successfully subscribed to topic: modbus/response/PacketPower-41E4-0000-0000-0B23. 
com.gateway.mqtt: stdout. message, {"id": "TestRequest", "function": "ReadInputRegisters", "address": 602, "quantity": 1}. 
 com.gateway.mqtt: stdout. Successfully published to topic: modbus/request/PacketPower-41E4-0000-0000-0B23.
com.gateway.mqtt: stdout. Received modbus message:{"type":"ExceptionCode","id":"TestRequest","code":"IllegalDataAddress"}. 

已回答 2 年前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南