Code Monkey home page Code Monkey logo

Comments (3)

stephenctw avatar stephenctw commented on August 11, 2024

Hi Sander,

I tried to replicate your issue on my side, however I didn't see the null exception you saw.

Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"00017","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":84}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"00017","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":84}
Invalid TcpPort: , set to DefaultTcpPort: 502
Invalid RetryCount: , set to DefaultRetryCount: 10
Invalid RetryInterval: , set to DefaultRetryInterval: 50
Opening.../dev/ttyS0
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"17","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":85}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"17","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":85}
Invalid TcpPort: , set to DefaultTcpPort: 502
Invalid RetryCount: , set to DefaultRetryCount: 10
Invalid RetryInterval: , set to DefaultRetryInterval: 50
Opening.../dev/ttyS0
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"00017","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":86}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"00017","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":86}
Invalid TcpPort: , set to DefaultTcpPort: 502
Invalid RetryCount: , set to DefaultRetryCount: 10
Invalid RetryInterval: , set to DefaultRetryInterval: 50
Opening.../dev/ttyS0
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1
Modbus exception code: 1

I will add extra check while loading the configuration, if the starting address is not specified with proper 5 digit or 6 digit format, the operation will be ignored.

from iot-edge-modbus.

stephenctw avatar stephenctw commented on August 11, 2024

update testing images as follow.
microsoft/azureiotedge-modbus-tcp:0.0.1-amd64
microsoft/azureiotedge-modbus-tcp:0.0.1-arm32v7

Please help to validate if the issue is resolved.
Thanks!

Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"17","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":89}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"17","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":89}
Op01 has invalid StartAddress 17, remove from dictionary...
Opening.../dev/ttyS0
No valid operation in modbus session available!!
Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"17","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"},"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":90}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"17","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"},"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":90}
Op01 has invalid StartAddress 17, remove from dictionary...
Opening.../dev/ttyS0
400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"4001","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"},"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":91}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op01":{"PollingInterval":"2000","UnitId":"1","StartAddress":"4001","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"},"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}}}},"$version":91}
Op01 has invalid StartAddress 4001, remove from dictionary...
Opening.../dev/ttyS0
400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"},"Op01":null}}},"$version":92}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","TcpPort":"502","RetryCount":"10","RetryInterval":"100","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"},"Op01":null}}},"$version":92}
Op01 is null, remove from dictionary...
Opening.../dev/ttyS0
400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}},"TcpPort":null,"RetryCount":null,"RetryInterval":null}},"$version":93}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","HwId":"PowerMeter-0a:01:01:01:01:01","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","Operations":{"Op02":{"PollingInterval":"2000","UnitId":"1","StartAddress":"400020","Count":"2","CorrelationId":"MessageType1","DisplayName":"Voltage"}},"TcpPort":null,"RetryCount":null,"RetryInterval":null}},"$version":93}
Invalid TcpPort: , set to DefaultTcpPort: 502
Invalid RetryCount: , set to DefaultRetryCount: 10
Invalid RetryInterval: , set to DefaultRetryInterval: 50
Opening.../dev/ttyS0
400020: 1000

400021: 0

400020: 1000

400021: 0

400020: 1000

400021: 0

from iot-edge-modbus.

sandervandevelde avatar sandervandevelde commented on August 11, 2024

The updated module microsoft/azureiotedge-modbus-tcp:0.0.1-amd64 fixes my issue with the invalid start address.

I used thin device twin (as seen above, I added TcpPort, RetryCount, RetryInterval and CorrelationID to prevent the info lines).

"desired": {
"PublishInterval": "5000",
"SlaveConfigs": {
"Slave01": {
"SlaveConnection": "/dev/ttyS0",
"BaudRate": "9600",
"DataBits": "8",
"StopBits": "1",
"Parity": "NONE",
"FlowControl": "NONE",
"HwId": "Adam4168U1",
"Operations": {
"Op01": {
"PollingInterval": "5000",
"UnitId": "1",
"StartAddress": "00017",
"Count": "8",
"DisplayName": "Relays",
"CorrelationId": "Message8Coils"
}
},
"TcpPort": "502",
"RetryCount": "10",
"RetryInterval": "100"
}
}

When theis Module Twin is sent, is results in a good response. I get the values of the coils:

8/28/2018 10:47:47 PM> Device: [linux6900], Data:[{"machine":{"temperature":101.08185656174635,"pressure":10.123249481717938},"ambient":{"temperature":20.733080430064852,"humidity":25},"timeCreated":"2018-08-28T20:47:47.9496227Z"}]
8/28/2018 10:47:52 PM> Device: [linux6900], Data:[{"PublishTimestamp":"2018-08-28 20:47:52","Content":[{"HwId":"Adam4168U1","Data":[{"CorrelationId":"Message8Coils","SourceTimestamp":"2018-08-28 20:47:50","Values":[{"DisplayName":"Relays","Address":"00017","Value":"1"},{"DisplayName":"Relays","Address":"00018","Value":"0"},{"DisplayName":"Relays","Address":"00019","Value":"0"},{"DisplayName":"Relays","Address":"00020","Value":"0"},{"DisplayName":"Relays","Address":"00021","Value":"0"},{"DisplayName":"Relays","Address":"00022","Value":"0"},{"DisplayName":"Relays","Address":"00023","Value":"0"},{"DisplayName":"Relays","Address":"00024","Value":"0"}]}]}]}]Properties:
'content-type': 'application/edge-modbus-json'

So I change the 00017 into 17:

00024: 0
Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","HwId":"Adam4168U1","Operations":{"Op01":{"PollingInterval":"5000","UnitId":"1","StartAddress":"17","Count":"8","DisplayName":"Relays","CorrelationId":"Message8Coils"}},"TcpPort":"502","RetryCount":"10","RetryInterval":"100"}},"$version":41}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","HwId":"Adam4168U1","Operations":{"Op01":{"PollingInterval":"5000","UnitId":"1","StartAddress":"17","Count":"8","DisplayName":"Relays","CorrelationId":"Message8Coils"}},"TcpPort":"502","RetryCount":"10","RetryInterval":"100"}},"$version":41}
Op01 has invalid StartAddress 17, remove from dictionary...
Opening.../dev/ttyS0
No valid operation in modbus session available!!

The response is ok. 17 is rejected.

So I switch back to 00017:

Desired property change:
{"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","HwId":"Adam4168U1","Operations":{"Op01":{"PollingInterval":"5000","UnitId":"1","StartAddress":"00017","Count":"8","DisplayName":"Relays","CorrelationId":"Message8Coils"}},"TcpPort":"502","RetryCount":"10","RetryInterval":"100"}},"$version":42}
Attempt to load configuration: {"PublishInterval":"5000","SlaveConfigs":{"Slave01":{"SlaveConnection":"/dev/ttyS0","BaudRate":"9600","DataBits":"8","StopBits":"1","Parity":"NONE","FlowControl":"NONE","HwId":"Adam4168U1","Operations":{"Op01":{"PollingInterval":"5000","UnitId":"1","StartAddress":"00017","Count":"8","DisplayName":"Relays","CorrelationId":"Message8Coils"}},"TcpPort":"502","RetryCount":"10","RetryInterval":"100"}},"$version":42}
Opening.../dev/ttyS0
00017: 1
00018: 0
00019: 0
00020: 0
00021: 0
00022: 0
00023: 0

And I get a good response with valid values again.

I do not have any issues anymore. The response is clear.

from iot-edge-modbus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.