【发布时间】:2019-04-21 11:51:36
【问题描述】:
我正在尝试通过我的 Java 程序向它发送 HID 数据包来设置我的 RGB 键盘的 LED,找到了 Java HIDAPI 包装器here。
到目前为止,我一直很成功,但只是在我的 Linux 笔记本电脑上。当我尝试在 Windows 上运行代码时,我收到一个错误“无效函数”,我假设它等同于系统错误 0x1,ERROR_INVALID_FUNCTION。
此示例代码段不会在 Windows 上运行,但会在 Linux 上运行。 (当它从终端运行并在命令前附加“sudo”时。)
// Device is found prior to this...
if (device != null) {
device.disableBlocking();
// Initialise the buffer, and send it. PACKET_SIZE is 264
byte[] buffer = new byte[PACKET_SIZE];
for (int i = 0; i < PACKET_SIZE; i++) { buffer[i] = (byte)0x00; }
// These bytes are required for it to actually change the LED's.
buffer[0] = 0x07;
buffer[1] = 0x0E;
buffer[2] = 0x01;
buffer[3] = 0x01;
try {
// Actually send the data.
device.sendFeatureReport(buffer);
}
// Handle I/O exceptions
catch (IOException e) {
e.printStackTrace();
}
// Close the device.
device.close();
}
else {
System.err.println("DEVICE IS NULL");
}
我试过以管理员身份运行,遗憾的是没有区别...
如果我的问题不够清楚,请告诉我,我会尝试进一步澄清。
任何帮助将不胜感激!我迫不及待地想找到解决办法! :)
操作系统的版本,如果重要的话:
Linux Ubuntu 18.04
视窗 8.1
【问题讨论】:
标签: java linux windows hid hidapi