morkai / h5.modbus

Implementation of the MODBUS IP/ASCII/RTU master and slave over TCP/UDP/Serial for Node.js.
https://miracle.systems/p/h5.modbus
MIT License
28 stars 21 forks source link

Minor fixes on Modbus over Serial Port #22

Closed ekawahyu closed 6 years ago

ekawahyu commented 6 years ago

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);
    }

    //
    ...
    //

  }
}
morkai commented 6 years ago

Thanks.