diff --git a/example/concise-init-tcp-ip-defaults.js b/example/concise-init-tcp-ip-defaults.js index a92f1e9..ca2d6cc 100644 --- a/example/concise-init-tcp-ip-defaults.js +++ b/example/concise-init-tcp-ip-defaults.js @@ -6,7 +6,7 @@ var modbus = require('../lib'); -var master = modbus.createMaster({}); +var master = modbus.createMaster(); master.once('connected', function() { diff --git a/lib/index.js b/lib/index.js index 3f57faf..2a0b76e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -108,8 +108,8 @@ function createTransport(options) } /** - * @param {object} options - * @param {object} options.transport + * @param {object} [options] + * @param {object} [options.transport] * @param {boolean} [options.retryOnException] * @param {number} [options.maxConcurrentRequests] * @param {number} [options.defaultUnit] @@ -120,6 +120,11 @@ function createTransport(options) */ function createMaster(options) { + if (typeof options === 'undefined') + { + options = {}; + } + options.transport = createTransport(options.transport); options = new Master.Options(options);