chrome.hid.send falla en el segundo uso

Algo sobre mi uso dechrome.hid.send parece estar saliendo del autobús en mal estado. Constantemente NO puedo hacer que mi segundo uso de la llamada API funcione. A veces, también fallará en el primer uso. CON EL MISMO CÓDIGO EXACTO, puedo volver e intentarlo un poco más tarde (tal vez 10 minutos) y el primer envío funcionará.

El dispositivo con el que estoy trabajando no devuelve una respuesta a todos los mensajes que se le envían. El mensaje de prueba, por ejemplo, es solo un mensaje ficticio que el dispositivo ignora. He probado esto tanto en una Mac como en una PC. La profundidad de mi pila de llamadas es 2 en este punto de mi aplicación (literalmente, primero se inicia con un clic en el botón y luego unsetTimeout llama al mismo método 5s más tarde).

He estado probando el envío de buffers de 64 Bytes y 58 Bytes. Las propiedades del objeto HidDeviceInfo leían "maxInputReportSize": 64, "maxOutputReportSize": 64

Parámetros en el primer uso:

Parámetros en el segundo uso:

Realmente no puedo identificar cómo estoy usando la API incorrectamente. Cuando los mensajes tienen éxito, puedo verlos en el lado del dispositivo.

// 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;
  var dummyUint8Array = new Uint8Array(outData);
  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);
      });
    }
  });
}


// Example usage
var testMessage = new Uint8Array(58);
var testTransmission = function() {
  message[0] = 123;
  COMMS.send(message.buffer, null, null);
  setTimeout(testTransmission, 5000);
};
testTranmission();

Respuestas a la pregunta(1)

Su respuesta a la pregunta