morkai/h5.modbus

Minor fixes on Modbus over Serial Port

Closed this issue · 1 comments

I just did npm update to the latest h5.modbus from master branch and found some errors that need minor fixes as follow:

SerialListener.js:

class SerialListener extends Listener
{
  /**
   * @param {SerialListenerOptions} [options]
   */
  constructor(options)
  {
    super();
    //
    ...
    //
    /**
     * @private
     * @type {function(this:SerialListener, Buffer)}
     */
    //this.onSerialData = this.onSerialData.bind(this);
    this.onSerialReadable = this.onSerialReadable.bind(this);

    if (!options)
    {
      options = {};
    }
    //
    ...
    //
}

SerialConnection.js:

class SerialConnection extends Connection
{
  /**
   * @param {SerialConnectionOptions} options
   */
  constructor(options)
  {
    super();

    //
    ...
    //

  isOpen()
  {
    //return this.serialPort !== null && this.serialPort.isOpen();
    return this.serialPort !== null && this.serialPort.isOpen;
  }

  //
  ...
  //

  setUpSerialPort(serialPort)
  {
    if (!serialPort)
    {

      //
      ...
      //

      //serialPort = new SerialPort(this.serialPortOptions.path, this.serialPortOptions, false, null);
      serialPort = new SerialPort(this.serialPortOptions.path, this.serialPortOptions);
    }

    //
    ...
    //

  }
}

Thanks.