An old btc miner project.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

miner-asic.js 652B

12345678910111213141516171819202122232425262728293031323334353637
  1. var SerialPort = require("serialport");
  2. class AsicMiner {
  3. constructor(dev, baud) {
  4. this.ready = false;
  5. this.error = null;
  6. this._onready = [];
  7. this._port = new SerialPort(dev, {
  8. baudRate: baud
  9. });
  10. this._port.on("error", msg => {
  11. this.error = msg;
  12. this._onready.forEach(x => x());
  13. });
  14. this._port.on("open", () => {
  15. this.ready = true;
  16. this._onready.forEach(x => x());
  17. });
  18. this._port.on("data", d => {
  19. console.log("From "+dev+": "+d);
  20. });
  21. }
  22. wait() {
  23. return new Promise((resolve, reject) => {
  24. if (this.ready)
  25. return resolve();
  26. this._onready.push(resolve);
  27. });
  28. }
  29. }
  30. module.exports = AsicMiner;