Interacting with RPC devices via device files. #129
-
I've recently been looking into interacting with RPC devices via devices files, from looking through the devices.py script i was able to decipher that the def _write_message(self, data):
self.file.write(self.MESSAGE_DELIMITER + json.dumps(data) + self.MESSAGE_DELIMITER) so writing {
"type": "invoke",
"data": {
"deviceId": 0,
"name": "getRedstoneInput",
"parameters": {
"side": "west"
}
}
} or a list: {
"type": "invoke",
"data": {
"deviceId": 0,
"name": "getRedstoneInput",
"parameters": [
"west"
]
}
} and does the order of the fields on the json matter? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I'm not entirely sure I understand you. |
Beta Was this translation helpful? Give feedback.
-
Yes, that is the basic format of the RPC "protocol". One tricky bit is the need to switch the hvc0 into raw mode after opening it (as seen here). The |
Beta Was this translation helpful? Give feedback.
Yes, that is the basic format of the RPC "protocol". One tricky bit is the need to switch the hvc0 into raw mode after opening it (as seen here). The
parameters
field is a list/array, in the order the backing RPC method expects them, so order does matter.