You are reading a single comment by @CKnight and its replies. Click here to read the full conversation.
  • Yeah I'd like to have a few options.

    1. A direct cross terminal, which is easily accomplished with the Serialx.on with a write to the oppositng port. I could also put them to a loopback too, I suppose. Right now I've got the xterminal going with USB as my kind of watch port.
    2. What you're suggesting, which is pretty great actually.
    3. A little more autonomous functionality that I could call a send so that higher level functions could be implemented for bigger things such as socket dials.

    Having trouble with #3 right now. Any particular reason this wouldn't work? Right now it's like if I sent anything to the port I can't loop and read or check availability from that port in waiting, it needs to come back to the terminal or I need to utilize setTimeout.

    function Test(inSTR, timeOut) {
      var TO=getTime() + timeOut; //set timeout in seconds
    
      Serial6.println(inSTR);
    
      while (getTime() < TO) {
        if (Serial6.available() > 0) {
          console.log("Success.");
          return 1;
          }
      }
      return -1;
    }
    

    So Test('AT+CREG?',2) simply comes back with a timeout in this case.

    This is probably something silly that I'm not taking into account.

    I've tried implementing other options such as using a Serial6.on to just parse and put to a buffer, but I'm having trouble with what appears to be scoping (my JS is awful, kind of learning as I go).

About

Avatar for CKnight @CKnight started