This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const {createServer} = require('net'); | |
const externalServer = createServer(); | |
const internalServer = createServer(); | |
let externalClient = null; | |
let internalClient = null; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Running on the PC with the 3G modem | |
var net = require('net'); | |
var plcConn = net.connect(502, '192.168.1.10'); | |
var pcConn = net.connect(3000, '123.123.123.123'); | |
pcConn.on('connect', function() | |
{ | |
plcConn.pipe(pcConn); | |
pcConn.pipe(plcConn); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const INODE_LAN_HOST = process.argv[2] || '192.168.1.109'; | |
connect(); | |
function connect(socket) | |
{ | |
if (socket) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
const net = require('net'); | |
const client = net.connect(54321, process.argv[2] || '127.0.0.1'); | |
let count = 0; | |
let total = 0; | |
client.on('data', function(data) | |
{ | |
count++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var exec = require('child_process').exec; | |
function restart(counter) | |
{ | |
console.log('%d. pm2 restart all', counter); | |
exec('pm2 restart all', function(err, stdout, stderr) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var modbus = require('h5.modbus'); | |
var MASTER_OPTIONS = { | |
// ... | |
}; | |
var WRITE_ADDRESS = 321; | |
var WRITE_VALUE = new Buffer([0, 0, 0, 0]); | |
var WRITE_OPTIONS = { | |
// ... | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
var master = modbus.createMaster({ | |
// ... | |
}); | |
// ... | |
var lastWriteAt = 0; | |
var lastDataAt = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var tcpOptions = { | |
type: 'tcp', | |
socket: socket, // require('net').Socket | |
host: '127.0.0.1', | |
port: 502, | |
autoConnect: true, | |
autoReconnect: true, | |
minConnectTime: 2500, | |
maxReconnectTime: 5000 | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var net = require('net'); | |
var modbus; try { modbus = require('h5.modbus'); } catch (err) { modbus = require('../lib'); } | |
var INTERVAL = 1000; | |
var RESPONSE_TIMEOUT = 200; // Decrease this value until you get timeout errors. | |
var END_OF_FRAME_TIMEOUT = 100; // Decrease this value until you get incomplete/invalid response frame errors. | |
var DEVICE_ADDRESS = '127.0.0.1'; | |
var DEVICE_UNITS = [1, 2, 3, 4]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
C:\Workspace\pm2-stop>pm2 start test.js -f --name "test-0" | |
[PM2] Starting test.js in fork_mode (1 instance) | |
[PM2] Done. | |
┌──────────┬────┬──────┬───────┬────────┬─────────┬────────┬────────────┬──────────┐ | |
│ App name │ id │ mode │ pid │ status │ restart │ uptime │ memory │ watching │ | |
├──────────┼────┼──────┼───────┼────────┼─────────┼────────┼────────────┼──────────┤ | |
│ test-0 │ 0 │ fork │ 53996 │ online │ 0 │ 0s │ 9.434 MB │ disabled │ | |
└──────────┴────┴──────┴───────┴────────┴─────────┴────────┴────────────┴──────────┘ | |
Use `pm2 show <id|name>` to get more details about an app |