如何使用 busctl 命令行工具调用需要字节数组的 D-Bus 方法

How to call D-Bus method that expects array of bytes using busctl command line tool

我正在尝试执行 busctl call 一种将字节数组作为参数(签名 ay)的方法。我该怎么做?

这是我目前尝试过的方法:

# busctl call ${SERVICE_IFACE} ${THE_OBJECT} ${SERVICE_IFACE} ${METHOD} ay 0x00 0x00 0x01 0x00 0xaf
Too many parameters for signature.
# busctl call ${SERVICE_IFACE} ${THE_OBJECT} ${SERVICE_IFACE} ${METHOD} yyyyy 0x00 0x00 0x01 0x00 0xaf
Call failed: Invalid arguments 'yyyyy' to call xyz.openbmc_project.Control.Haven.SendHostCommand(), expecting 'ay'.
# busctl call ${SERVICE_IFACE} ${THE_OBJECT} ${SERVICE_IFACE} ${METHOD} a5y 0x00 0x00 0x01 0x00 0xaf
Invalid array signature: Invalid argument
# busctl call ${SERVICE_IFACE} ${THE_OBJECT} ${SERVICE_IFACE} ${METHOD} ay '0x00 0x00 0x01 0x00 0xaf'
Failed to parse '0x00 0x00 0x01 0x00 0xaf' number of array entries: Invalid argument

那么,它想要什么?

我认为您需要将数组的长度放在值之前。所以在你的例子中是:

busctl call ${SERVICE_IFACE} ${THE_OBJECT} ${SERVICE_IFACE} ${METHOD} ay 5 0x00 0x00 0x01 0x00 0xaf