Iot Hub 模块 "Modbus" 看起来健康且参数化良好,但未收到数据

Iot Hub module "Modbus" looks healthy and well parametrized but no data received

我正在将“Janitza UMG96RM-E”设备连接到 Windows 笔记本电脑,我在笔记本电脑上使用 Hyper-V 来使用 Linux cmds。我将笔记本电脑注册为边缘设备并将 Modbus 添加到模块集中。我阅读了 Janitza 文档(起始地址,位的 nbre ...)并且我在模块双胞胎文件中添加了正确的 IP 地址...一切看起来都很健康,除了我没有从 Modbus 模块接收任何数据...我不是能弄清楚哪里出了问题吗?这是 edgeHub 模块的一些日志。

<6> 2022-03-08 18:32:01.503 +00:00 [INF] - Add node: myEdgeDevice/DefenderIotMicroAgent
<6> 2022-03-08 18:32:01.711 +00:00 [INF] - Add node: myEdgeDevice/Modbus
<6> 2022-03-08 18:32:01.868 +00:00 [INF] - Done refreshing device scope identities cache. Waiting for 60 minutes.
<6> 2022-03-08 18:32:01.956 +00:00 [INF] - Obtained edge hub config from module twin
<6> 2022-03-08 18:32:02.377 +00:00 [INF] - Set the following 1 route(s) in edge hub
<6> 2022-03-08 18:32:02.377 +00:00 [INF] - modbusToIoTHub: FROM /messages/modules/Modbus/outputs/modbusOutput INTO $upstream
<6> 2022-03-08 18:32:02.378 +00:00 [INF] - Updated message store TTL to 7200 seconds
<6> 2022-03-08 18:32:02.379 +00:00 [INF] - Updated the edge hub store and forward configuration
<6> 2022-03-08 18:32:02.391 +00:00 [INF] - Started operation Get EdgeHub config
<6> 2022-03-08 18:32:02.395 +00:00 [INF] - Initialized edge hub configuration
<6> 2022-03-08 18:32:02.397 +00:00 [INF] - Starting protocol heads - (MQTT, AMQP, HTTP)
<6> 2022-03-08 18:32:02.410 +00:00 [INF] - Starting MQTT head
<6> 2022-03-08 18:32:02.524 +00:00 [INF] - Initializing TLS endpoint on port 8883 for MQTT head.
<6> 2022-03-08 18:32:02.845 +00:00 [INF] - Starting AMQP head
<6> 2022-03-08 18:32:02.873 +00:00 [INF] - Started MQTT head
<6> 2022-03-08 18:32:03.251 +00:00 [INF] - Started AMQP head
<6> 2022-03-08 18:32:03.255 +00:00 [INF] - Starting HTTP head
<4> 2022-03-08 18:32:04.026 +00:00 [WRN] - Overriding address(es) '"http://+:80"'. Binding to endpoints defined in "UseKestrel()" instead.
<6> 2022-03-08 18:32:04.063 +00:00 [INF] - Started HTTP head
<6> 2022-03-08 18:32:05.529 +00:00 [INF] - New token received on the Cbs link
<6> 2022-03-08 18:32:05.727 +00:00 [INF] - Client myEdgeDevice/Modbus in device scope authenticated locally.
<6> 2022-03-08 18:32:05.745 +00:00 [INF] - New device connection for device myEdgeDevice/Modbus
<6> 2022-03-08 18:32:05.746 +00:00 [INF] - Client myEdgeDevice/Modbus connected to edgeHub, processing existing subscriptions.
<6> 2022-03-08 18:32:05.750 +00:00 [INF] - Attempting to connect to IoT Hub for client myEdgeDevice/Modbus via AMQP...
<6> 2022-03-08 18:32:05.767 +00:00 [INF] - Bind device proxy for device myEdgeDevice/Modbus
<6> 2022-03-08 18:32:05.767 +00:00 [INF] - Initialized device listener in the AMQP protocol head for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:05.786 +00:00 [INF] - Opened link Events for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:05.827 +00:00 [INF] - Cloud connection for myEdgeDevice/Modbus is True
<6> 2022-03-08 18:32:05.827 +00:00 [INF] - Connection status for myEdgeDevice/Modbus changed to ConnectionEstablished
<6> 2022-03-08 18:32:05.827 +00:00 [INF] - Client myEdgeDevice/Modbus connected to cloud, processing existing subscriptions.
<6> 2022-03-08 18:32:05.827 +00:00 [INF] - Skipping myEdgeDevice/Modbus for subscription processing, as it is currently being processed.
<6> 2022-03-08 18:32:05.827 +00:00 [INF] - Created cloud proxy for client myEdgeDevice/Modbus via AMQP, with client operation timeout 20 seconds.
<6> 2022-03-08 18:32:05.828 +00:00 [INF] - Initialized cloud proxy 9450b673-5293-4c0b-830f-5c564f317321 for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:05.828 +00:00 [INF] - Created cloud connection for client myEdgeDevice/Modbus
<6> 2022-03-08 18:32:06.116 +00:00 [INF] - Opened link TwinReceiving for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:06.126 +00:00 [INF] - Processing pending subscriptions for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:06.129 +00:00 [INF] - Opened link TwinSending for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:06.659 +00:00 [INF] - Processing pending subscriptions for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:06.661 +00:00 [INF] - Opened link ModuleMessages for myEdgeDevice/Modbus
<6> 2022-03-08 18:32:06.760 +00:00 [INF] - Updated reported properties for myEdgeDevice/$edgeHub
<6> 2022-03-08 18:32:12.133 +00:00 [INF] - Updated reported properties for myEdgeDevice/Modbus
<6> 2022-03-08 18:36:56.469 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 18:41:56.461 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 18:46:56.461 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 18:51:56.464 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 18:56:56.464 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:01:53.016 +00:00 [INF] - Started task to cleanup processed and stale messages for endpoint iothub
<6> 2022-03-08 19:01:53.083 +00:00 [INF] - Cleaned up 0 messages from queue for endpoint iothub and 0 messages from message store.
<6> 2022-03-08 19:01:56.460 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:06:56.460 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:11:56.463 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:16:56.463 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:21:56.463 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:26:56.464 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:30:05.794 +00:00 [INF] - New token received on the Cbs link
<6> 2022-03-08 19:30:05.800 +00:00 [INF] - Token updated for myEdgeDevice/Modbus
<6> 2022-03-08 19:30:57.126 +00:00 [INF] - Request starting HTTP/1.1 GET http://172.18.0.3:9600/metrics
<6> 2022-03-08 19:30:57.203 +00:00 [INF] - Request finished in 76.276ms 200 text/plain; version=0.0.4; charset=utf-8
<6> 2022-03-08 19:31:53.089 +00:00 [INF] - Started task to cleanup processed and stale messages for endpoint iothub
<6> 2022-03-08 19:31:53.157 +00:00 [INF] - Cleaned up 0 messages from queue for endpoint iothub and 0 messages from message store.
<6> 2022-03-08 19:31:56.459 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:32:01.877 +00:00 [INF] - Starting refresh of device scope identities cache
<6> 2022-03-08 19:32:02.390 +00:00 [INF] - Starting periodic operation Get EdgeHub config...
<6> 2022-03-08 19:32:02.781 +00:00 [INF] - Obtained edge hub config from module twin
<6> 2022-03-08 19:32:02.939 +00:00 [INF] - Set the following 1 route(s) in edge hub
<6> 2022-03-08 19:32:02.940 +00:00 [INF] - modbusToIoTHub: FROM /messages/modules/Modbus/outputs/modbusOutput INTO $upstream
<6> 2022-03-08 19:32:02.941 +00:00 [INF] - Updated message store TTL to 7200 seconds
<6> 2022-03-08 19:32:02.941 +00:00 [INF] - Updated the edge hub store and forward configuration
<6> 2022-03-08 19:32:02.941 +00:00 [INF] - Successfully completed periodic operation Get EdgeHub config
<6> 2022-03-08 19:32:03.056 +00:00 [INF] - Updated reported properties for myEdgeDevice/$edgeHub
<6> 2022-03-08 19:32:04.404 +00:00 [INF] - Not changed node: myEdgeDevice
<6> 2022-03-08 19:32:04.405 +00:00 [INF] - Not changed node: myEdgeDevice/$edgeAgent
<6> 2022-03-08 19:32:04.405 +00:00 [INF] - Not changed node: myEdgeDevice/$edgeHub
<6> 2022-03-08 19:32:04.405 +00:00 [INF] - Not changed node: myEdgeDevice/DefenderIotMicroAgent
<6> 2022-03-08 19:32:04.406 +00:00 [INF] - Not changed node: myEdgeDevice/Modbus
<6> 2022-03-08 19:32:04.406 +00:00 [INF] - Done refreshing device scope identities cache. Waiting for 60 minutes.
<6> 2022-03-08 19:36:56.459 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:41:56.461 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:46:56.462 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:51:56.460 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 19:56:56.460 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 20:01:53.157 +00:00 [INF] - Started task to cleanup processed and stale messages for endpoint iothub
<6> 2022-03-08 20:01:53.159 +00:00 [INF] - Cleaned up 0 messages from queue for endpoint iothub and 0 messages from message store.
<6> 2022-03-08 20:01:56.463 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 20:06:56.461 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 20:11:56.460 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 20:16:56.463 +00:00 [INF] - Entering periodic task to reauthenticate connected clients
<6> 2022-03-08 20:21:56.461 +00:00 [INF] - Entering periodic task to reauthenticate connected clients 

Modbus 模块双胞胎:

{
    "deviceId": "myEdgeDevice",
    "moduleId": "Modbus",
    "etag": "AAAAAAAAAA4=",
    "deviceEtag": "Mzc5OTQzNzE5",
    "status": "enabled",
    "statusUpdateTime": "0001-01-01T00:00:00Z",
    "connectionState": "Connected",
    "lastActivityTime": "0001-01-01T00:00:00Z",
    "cloudToDeviceMessageCount": 0,
    "authenticationType": "sas",
    "x509Thumbprint": {
        "primaryThumbprint": null,
        "secondaryThumbprint": null
    },
    "modelId": "",
    "version": 33,
    "properties": {
        "desired": {
            "PublishInterval": 2000,
            "SlaveConfigs": {
                "Slave01": {
                    "SlaveConnection": "192.168.151.50",
                    "HwId": "HwId1",
                    "Operations": {
                        "Op01": {
                            "PollingInterval": "100",
                            "UnitId": "1",
                            "StartAddress": "19000",
                            "Count": "32",
                            "DisplayName": "Voltage",
                            "CorrelationId": "MessageType1"
                        }
                    },
                    "TcpPort": "502",
                    "RetryCount": "10",
                    "RetryInterval": "100"
                }
            },
            "routes": {
                "modbusToIoTHub": "FROM /messages/modules/Modbus/outputs/modbusOutput INTO $upstream"
            },
            "$metadata": {
                "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                "$lastUpdatedVersion": 14,
                "PublishInterval": {
                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                    "$lastUpdatedVersion": 14
                },
                "SlaveConfigs": {
                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                    "$lastUpdatedVersion": 14,
                    "Slave01": {
                        "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                        "$lastUpdatedVersion": 14,
                        "SlaveConnection": {
                            "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                            "$lastUpdatedVersion": 14
                        },
                        "HwId": {
                            "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                            "$lastUpdatedVersion": 14
                        },
                        "Operations": {
                            "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                            "$lastUpdatedVersion": 14,
                            "Op01": {
                                "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                                "$lastUpdatedVersion": 14,
                                "PollingInterval": {
                                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                                    "$lastUpdatedVersion": 14
                                },
                                "UnitId": {
                                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                                    "$lastUpdatedVersion": 14
                                },
                                "StartAddress": {
                                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                                    "$lastUpdatedVersion": 14
                                },
                                "Count": {
                                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                                    "$lastUpdatedVersion": 14
                                },
                                "DisplayName": {
                                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                                    "$lastUpdatedVersion": 14
                                },
                                "CorrelationId": {
                                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                                    "$lastUpdatedVersion": 14
                                }
                            }
                        },
                        "TcpPort": {
                            "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                            "$lastUpdatedVersion": 14
                        },
                        "RetryCount": {
                            "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                            "$lastUpdatedVersion": 14
                        },
                        "RetryInterval": {
                            "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                            "$lastUpdatedVersion": 14
                        }
                    }
                },
                "routes": {
                    "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                    "$lastUpdatedVersion": 14,
                    "modbusToIoTHub": {
                        "$lastUpdated": "2022-03-08T18:30:17.436628Z",
                        "$lastUpdatedVersion": 14
                    }
                }
            },
            "$version": 14
        },
        "reported": {
            "PublishInterval": 2000,
            "SlaveConfigs": {
                "Slave01": {
                    "Operations": {
                        "Op01": {
                            "PollingInterval": 100,
                            "UnitId": 1,
                            "StartAddress": "19000",
                            "Count": 32,
                            "DisplayName": "Voltage",
                            "CorrelationId": "MessageType1"
                        }
                    },
                    "SlaveConnection": "192.168.151.50",
                    "RetryCount": 10,
                    "RetryInterval": 100,
                    "TcpPort": 502,
                    "HwId": "HwId1"
                }
            },
            "$metadata": {
                "$lastUpdated": "2022-03-08T18:32:11.9932421Z",
                "PublishInterval": {
                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                },
                "SlaveConfigs": {
                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z",
                    "Slave01": {
                        "$lastUpdated": "2022-03-08T18:32:11.9932421Z",
                        "Operations": {
                            "$lastUpdated": "2022-03-08T18:32:11.9932421Z",
                            "Op01": {
                                "$lastUpdated": "2022-03-08T18:32:11.9932421Z",
                                "PollingInterval": {
                                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                                },
                                "UnitId": {
                                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                                },
                                "StartAddress": {
                                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                                },
                                "Count": {
                                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                                },
                                "DisplayName": {
                                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                                },
                                "CorrelationId": {
                                    "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                                }
                            }
                        },
                        "SlaveConnection": {
                            "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                        },
                        "RetryCount": {
                            "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                        },
                        "RetryInterval": {
                            "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                        },
                        "TcpPort": {
                            "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                        },
                        "HwId": {
                            "$lastUpdated": "2022-03-08T18:32:11.9932421Z"
                        }
                    }
                }
            },
            "$version": 19
        }
    }
} 

以下是我从 Janitza 文档中用来配置模块孪生的信息: Modbus address list

你检查过模块的日志了吗?使用 iotedge list 检查模块的名称。

sudo iotedge list
sudo iotedge logs Modbus

您需要指定从 modbus 模块到 edgeHub 的 $upstream 通道的 route,以便将数据路由到与部署清单中的模块名称相匹配的 Azure IoT 中心。看起来是正确的,但 doublechek 不会有什么坏处。

要查看通过 IoT 中心的数据,您可以使用 Azure IoT explorer

我发现问题出在我正在读取的寄存器 start-address 上。 在我的例子中,我在开头添加了 4(Holding Register),在结尾添加了 +1。 示例:如果在从站设备的文档中我可以从地址 19000 读取电源:在 Modbus 模块双胞胎中我将地址指定为 419001! 我希望这对以后的人有所帮助。