我正在尝试使用 signal11 的 hidapi(此处)写入隐藏设备。在我的故障排除中,我注意到字符串的一部分没有显示在控制台上。这是我的代码示例
//device is a hid device and is assigned to in another part of the program.
//dataBuffer is a struct with only a char array called "buffer" and an int which is the size of the array called "size"
void DeviceCommands::Write(hid_device* device, dataBuffer* buf)
{
std::cout << "Attempting write >> buffer...\n";
buf->buffer[0] = 0;
std::cout << "Written to buffer...\n" << "writing buffer to device\n";
int res = hid_write(device, buf->buffer, sizeof(buf->buffer));
std::cout << "Write success: " + '\n';
std::cout << "Write complete\n";
}
我期待控制台返回以下内容:
Attempting write >> buffer...
Written to buffer...
writing buffer to device
Write success: (0 if the write succeeds, -1 if it fails)
Write complete
但相反,会发生这种情况:
Attempting write >> buffer...
Written to buffer...
writing buffer to device
ess: Write complete
“写成功”、结果和换行符都不见了,我对 c++ 有点陌生,但我有 c# 的经验。我只是感到困惑,非常感谢您的帮助,提前感谢并询问您是否需要更多信息!