chrome.hid.send的ArrayBuffer大小是否有限制
Is there a limit to the ArrayBuffer size of chrome.hid.send?
文档似乎没有提到任何此类限制,但是当我尝试发送64字节长的消息时,我遇到了奇怪的错误。 所有其他邮件传输似乎都可以正常工作。
并不是说我认为它与所问的问题真正相关,但这是我在 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);
});
}
});
}
对于其
属性从HidDeviceInfo
读取"maxInputReportSize":64,"maxOutputReportSize":64
的设备,似乎没有chrome.hid.send
施加的额外限制。 但似乎确实有些不对劲。
使用 OP 中的方法,我可以成功发送一条消息,提示从设备返回。 我目前无法仅发送传出消息。 我希望chrome.lastError.message
比Transfer Failed
更详细一点。
相关文章:
- document.getElementById(“”).value是否有限制
- 是否有一个 JavaScript 加载器可以将套接字的数量限制为 1 或 2
- 是否有一种方法可以限制要上传到客户端服务器的文件大小
- 根据类型通过 HTML ID 标记进行 JS 搜索是否有限制
- 我想包含在我的网站页面上的 JavaScript 库/插件是否有经验法则大小限制
- 是否有一组限制可用于模拟JavaScript中的函数式编程
- Jquery:一个jquery对象(方法链)上可以调用的函数数量是否有限制
- 是否有需要重定向网址的技术限制
- chrome.hid.send的ArrayBuffer大小是否有限制
- 在jQuery中使用replaceWIth的数据大小是否有限制
- 使用字符串的替换方法时是否有长度限制
- 元素的背景图像的修改频率是否有限制
- 在Netsuite API中调用nlapiSearchGlobal(keywords)方法是否有限制?
- 关于AJAX XMLHttpRequest post函数的数据大小是否有限制?
- 在javascript中通过class属性应用样式时是否有限制?
- 你可以使用的.animate()'s的数量是否有限制?
- 在JSONP请求中可以提交的内容是否有限制?
- 通过ajax发送和接收数据是否有限制?
- 在jquery中通过.post()传递参数是否有限制?
- 传递给jQuery.append()的字符串的大小是否有限制?