code: function connect() {
      // clear pending timeouts
      clearTimeout(timeoutConnectRef);
  
      // if client already open, just run
      if (client.isOpen) {
          run();
      }
  
      // if client closed, open a new connection
      client.connectTCP("127.0.0.1", { port: 8502 })
          .then(setClient)
          .then(function() {
              console.log("Connected"); })
          .catch(function(e) {
              checkError(e);
              console.log(e.message); });
  }
docs: open connection to a serial port