node-dmx / dmx

DMX controller library for node.js
MIT License
297 stars 96 forks source link

EnttecUSBDMXPRO driver: SerialPort "writable" property no longer exists? #80

Open tracycollins opened 5 years ago

tracycollins commented 5 years ago

In the sendUniverse method, it checks the "writable" property:

EnttecUSBDMXPRO.prototype.sendUniverse = function () {
  if (!this.dev.writable) {
    return;
  }

I think that it should be checking SerialPort.isOpen property instead? I can't find the writable property in the current SerialPort documentation: https://serialport.io/docs/en/api-stream

I found this while debugging a memory leak when testing an animation to be sure my app wouldn't crash if it couldn't find an Enttec device. If testing for 'writable', the driver will write to a non-existent serial port, leak memory, and eventually crash. When I changed the driver code to this, it seems to run ok:

EnttecUSBDMXPRO.prototype.sendUniverse = function () {
  if (!this.dev.isOpen) {
    return;
  }
Fensterbank commented 4 years ago

Good catch, in the documentation of the serial port version 7.x.x we are using there is also no mention of writable. isOpen exists since serialport 5.0.0 while this code was once created using serialport 4, so someone should make a pull request and fix this.

But I'm wondering: if writable would be undefined, the driver would not work at all... Is writable still implemented in the serialport codebase or how does this even work? o_O

Granjow commented 3 years ago

It is coming from the stream writable and still exists :)