Skip to content

Commit

Permalink
Added logging of the Master's events to the verbose examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
morkai committed Feb 14, 2014
1 parent 126a853 commit 0993906
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
15 changes: 15 additions & 0 deletions example/init-serial-rtu.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ var master = modbus.createMaster({
defaultTimeout: 100
});

master.on('connected', function()
{
console.log('[master#connected]');
});

master.on('disconnected', function()
{
console.log('[master#disconnected]');
});

master.on('error', function(err)
{
console.error('[master#error] %s', err.message);
});

var connection = master.getConnection();

connection.on('open', function()
Expand Down
19 changes: 19 additions & 0 deletions example/verbose-init-tcp-ip.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,25 @@ var master = new Master({
defaultTimeout: 100
});

// Emitted when the underlying Connection emits the `open` event.
master.on('connected', function()
{
console.log('[master#connected]');
});

// Emitted when the underlying Connection emits the `close` event,
// but only if the `connected` event was emitted before.
master.on('disconnected', function()
{
console.log('[master#disconnected]');
});

// Emitted when the underlying Connection emits the `error` event.
master.on('error', function(err)
{
console.error('[master#error] %s', err.message);
});

var address = 0x0000;
var quantity = 8;

Expand Down

0 comments on commit 0993906

Please sign in to comment.