[英]Is there a limit to the ArrayBuffer size of chrome.hid.send?
The docs do not seem to mention any such limit but I am getting strange errors when I try to send a 64 byte-long message. 文档似乎没有提到任何此类限制,但是当我尝试发送64字节长的消息时出现了奇怪的错误。 All other message transfers seem to work fine.
所有其他邮件传输似乎都可以正常工作。
Not that I think it is really relevant to the question being asked, but here is my send
method within the COMMS
namespace in case there is an obvious error that I should be aware of: 我并不是说这确实与所提出的问题有关,但是这是我在
COMMS
命名空间中的send
方法,以防出现明显的错误,我应该注意:
// Transmits the given data
//
// @param[in] outData, The data to send as an ArrayBuffer
// @param[in] onTxCompleted, The method called on completion of the outgoing transfer. The return
// code is passed as a string.
// @param[in] onRxCompleted, The method called on completion of the incoming transfer. The return
// code is passed as a string along with the response as an ArrayBuffer.
send: function(outData, onTxCompleted, onRxCompleted) {
if (-1 === connection_) {
console.log("Attempted to send data with no device connected.");
return;
}
if (0 == outData.byteLength) {
console.log("Attempted to send nothing.");
return;
}
if (COMMS.receiving) {
console.log("Waiting for a response to a previous message. Aborting.");
return;
}
if (COMMS.transmitting) {
console.log("Waiting for a previous message to finish sending. Aborting.");
return;
}
COMMS.transmitting = true;
chrome.hid.send(connection_, REPORT_ID, outData, function() {
COMMS.transmitting = false;
if (onTxCompleted) {
onTxCompleted(chrome.runtime.lastError ? chrome.runtime.lastError.message : '');
}
if (chrome.runtime.lastError) {
console.log('Error in COMMS.send: ' + chrome.runtime.lastError.message);
return;
}
// Register a response handler if one is expected
if (onRxCompleted) {
COMMS.receiving = true;
chrome.hid.receive(connection_, function(reportId, inData) {
COMMS.receiving = false;
onRxCompleted(chrome.runtime.lastError ? chrome.runtime.lastError.message : '', inData);
});
}
});
}
For a device whose properties from the HidDeviceInfo
read "maxInputReportSize":64,"maxOutputReportSize":64
, there does NOT seem to be an additional limit imposed by chrome.hid.send
. 对于从
HidDeviceInfo
读取的属性为"maxInputReportSize":64,"maxOutputReportSize":64
, chrome.hid.send
似乎没有附加限制。 But something does seem to be awry. 但是似乎有些不对劲。
Using the method in the OP, I can successfully send a message that prompts one back from the device. 使用OP中的方法,我可以成功发送一条消息,提示从设备返回一个消息。 I currently am unable to send an outgoing message only.
我目前无法仅发送外发邮件。 I wish the
chrome.lastError.message
was a little more detailed than Transfer Failed
. 我希望
chrome.lastError.message
比Transfer Failed
更加详细。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.