You are reading a single comment by @Mrbbp and its replies. Click here to read the full conversation.
  • i've written something like that

    var reponse= {trame:"",longueur:0};
    
    s.setup(9600,{rx:B6, tx:B5});
    s.on('data', function(data) {
      reponse.trame+= data;
      if (reponse.trame.length >= reponse.longueur) {
        switch (reponse.trame.charCodeAt(1)) {
          case 0x01: // status
            console.log("status:",reponse.trame.char­CodeAt(3));
            break;
          case 0x09: // status
            console.log("check Drive:",reponse.trame.charCodeAt(3));
            break;
          case 0x12: //Check the total numbers of audio in all folders(12)
            console.log("nbr total audios:",(reponse.trame.charCodeAt(3)<<8­ ^ reponse.trame.charCodeAt(4)));
            break;
          case 0x0C: //Check the total audios(0C)
            console.log("nbr total audios:",(reponse.trame.charCodeAt(3)<<8­ ^ reponse.trame.charCodeAt(4)));
            break;
          case 0x0D: //current audio
            console.log("nom fichier audio:",reponse.trame.charCodeAt(3),repo­nse.trame.charCodeAt(4));
            break;
          case 0x24: //duration audio
            console.log("Duréé: "+reponse.trame.charCodeAt(3)+"H "+reponse.trame.charCodeAt(4)+"mn "+reponse.trame.charCodeAt(5)+"s");
            break;
          default:
            break;
          }
      }
    });
    

    and each command sent, fill the reponse.longeur with the appropriate value...

    function Duration() {
     var command = [0xAA, 0x24, 0x00, 0xCE];
      // Return: AA 24 03 hour minute second SM
      reponse.longueur = 7;
      reponse.trame = "";
      s.write(command);
    }
    

    Not Tested

    Thanks for your help @allObjects.

About

Avatar for Mrbbp @Mrbbp started