Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2017
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. var serial = {
  2. xhr: new XMLHttpRequest(),
  3. port: null,
  4. response: "",
  5. timeout: 1000,
  6. host: "http://localhost:8886",
  7. open: function (port, baudrate) {
  8. var url = this.host + "/serial/open?port=" + port + "&baudrate=" + baudrate + "&timeout=" + this.timeout;
  9. this.xhr.open("GET", url, false);
  10. this.xhr.send();
  11. if (this.xhr.status != 200) {
  12. this.port = null;
  13. return false;
  14. } else {
  15. this.port = port;
  16. return true;
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement