Reputation: 11
I have deployed the Greengrass Modbus component to my Raspberry pi 4B with the required dependencies successfully. The pi is connected to a Modbus temperature and humidit sensor via an RS485 USB dongle. I confirm that I can read the holding registers successfully using Modpoll Commandline master simulator tool, all lovely so far. The sensor can be accessed through the path "/dev/ttyUSB0".
I want Greengrass to report the values of these registers on the sensor to AWS IoTCore.
To request data, I send a payload to a specific topic from the AWS broker to the Greengrass core. In my particular case, the topic is the default one "modbus/adapter/request". I sent the following payload:
{
"request": {
"operation": "ReadHoldingRegistersRequest",
"device": 4,
"address": 1,
"count": 2
},
"id": "TestRequest"
}
And I get the following response on the topic "modbus/adapter/response":
{
"response": {
"status": "fail",
"error_message": "Modbus Error: [Connection] Failed to connect[rtu baud[9600]]",
"error": "Exception",
"payload": {
"error": "Modbus Error: [Connection] Failed to connect[rtu baud[9600]]"
},
"operation": "ReadHoldingRegistersRequest",
"device": 4
},
"id": "TestRequest"
}
To reiterate, I know the correct port because I can read the holding registers using commandline Modbuspoll. However, using the tool I can specify more parameters, such as parity type, baud rate, etc... which seems like I can't do here. For your reference, the parameters I used on Modpoll are the following:
Address: 4
Baud rate: 9600
Parity: none
Registers: 1 (or 40001 for PLC)
Path: /dev/ttyUSB0
For your information, all of the steps mentioned above are following this guide: https://docs.aws.amazon.com/greengrass/v2/developerguide/modbus-rtu-protocol-adapter-component.html#modbus-rtu-protocol-adapter-component-input-data
Any suggestion?
Upvotes: 0
Views: 293
Reputation: 11
Upon looking at the log /greengrass/v2/logs/aws.greengrass.Modbus.log , I quickly realized that it was a permission issue with the pi. I was able to quickly fix it using the sudo chmod 777 command to the port.
Upvotes: 1