### Install node-omron-fins Module Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Demonstrates how to install the node-omron-fins library using npm. This involves creating a new directory for the project and then running the npm install command with the Git repository URL. ```sh mkdir helloFins cd helloFins npm install git://github.com/patrick--/node-omron-fins.git ``` -------------------------------- ### Start PLC Monitoring Mode with Callback Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Initiates the PLC into monitor mode. It accepts an optional callback function that is executed upon completion, receiving error and byte count information. ```javascript /* Puts into Monitor mode */ .run(function(err,bytes) { }); ``` -------------------------------- ### Read Memory Area (with callback) Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Demonstrates the `.read()` method for fetching data from a specified memory area. It shows how to read a certain number of registers starting from a given address, with an optional callback function to handle the response or errors. ```javascript /* Reads 10 registers starting from register 00000 in the DM Memory Area */ .read('D00000',10); /* Same as above with callback */ client.read('D00000',10,function(err,bytes) { console.log("Bytes: ", bytes); }); ``` -------------------------------- ### Basic FINS Client Data Read Example Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Demonstrates how to connect to a remote FINS client, set up error and response listeners, and read data from a specified memory address. It requires the 'omron-fins' module and establishes a connection to a client on a given port and IP address. ```javascript var fins = require('omron-fins'); // Connecting to remote FINS client on port 9600 with default timeout value. var client = fins.FinsClient(9600,'127.0.0.1'); // Setting up our error listener client.on('error',function(error) { console.log("Error: ", error); }); // Setting up the response listener // Showing properties of a response client.on('reply',function(msg) { console.log("Reply from: ", msg.remotehost); console.log("Transaction SID: ", msg.sid) console.log("Replying to issued command of: ", msg.command); console.log("Response code of: ", msg.code); console.log("Data returned: ", msg.values); }); //Read 10 registers starting at DM register 00000 client.read('D00000',10); ``` -------------------------------- ### Set PLC to Run Mode using Node.js Source: https://context7.com/ptrks/node-omron-fins/llms.txt Puts the PLC controller into Monitor/Run mode, enabling program execution. This command is essential for starting the PLC's operational cycle after configuration or a stop. An optional callback can be provided to handle the response asynchronously. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { if (msg.response === '0000') { console.log("PLC is now running"); } }); // Put PLC into Monitor mode client.run(); // With callback client.run(function(err, bytes) { console.log("Run command sent, bytes:", bytes); }); ``` -------------------------------- ### Fill Memory Area (with callback) Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Illustrates the `.fill()` command, which writes a specified value to a range of consecutive memory registers. It requires the starting address, the data to fill, and the number of registers to fill. A callback can be used for asynchronous processing. ```javascript /* Writes 1337 in 10 consecutive DM registers from 00100 to 00110 */ .fill('D00100',1337,10); /* Sames as above with callback */ .fill('D00100',1337,10,function(err,bytes) { console.log("Bytes: ", bytes); }); ``` -------------------------------- ### client.write(address, data, callback) Source: https://context7.com/ptrks/node-omron-fins/llms.txt Writes values to consecutive registers starting at the specified address. Supports single values, arrays, and bit-level writes. ```APIDOC ## client.write(address, data, [callback]) Writes values to consecutive registers starting at the specified address. Supports single values, arrays, and bit-level writes. ### Method `client.write(address, data, [callback])` ### Parameters #### Path Parameters * **address** (string) - Required - The starting memory address (e.g., 'D00000', 'HB50:03'). * **data** (number | Array) - Required - The value(s) to write. For bits, use 0 for OFF and 1 for ON. * **callback** (function) - Optional - A callback function to handle the response. Receives `(err, bytes)`. ### Request Example ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { if (msg.response === '0000') { console.log("Write successful"); } }); // Write single value to D00000 client.write('D00000', 1337); // Write array of values to consecutive registers D00000, D00001, D00002 client.write('D00000', [12, 34, 56]); // Write with callback client.write('D00000', [12, 34, 56], function(err, bytes) { console.log("Bytes sent:", bytes); }); // Write to a single bit - set bit 3 of HB register 50 to ON client.write('HB50:03', 1); // Write to multiple consecutive bits - set bits 3, 4, 5 of HB50 client.write('HB50:03', [1, 1, 1]); // Bit values: 0 = OFF, 1 = ON // Note: Writing values > 1 to bits will cause an error ``` ### Response * **response** (string) - The response code from the PLC. '0000' indicates success. ``` -------------------------------- ### Multiple FINS Clients for Asynchronous Communication Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Illustrates how to instantiate multiple FINS client objects to manage asynchronous communications. This approach allows for rapid sending and receiving of packets without waiting for individual responses. The example reads memory areas from a list of remote hosts, collecting responses or timeouts in an array. ```javascript var fins = require('omron-fins'); var debug = true; var clients = []; var responses = []; /* List of remote hosts can be generated from local or remote resource */ var remoteHosts = ['127.0.0.1','127.0.0.2','127.0.0.3']; / * Data is ready to be processed (sent to API,DB,etc) */ var finished = function(responses) { console.log("All responses and or timeouts received"); console.log(responses); }; var pollUnits = function() { /* We use number of hosts to compare to the length of the response array */ var numberOfRemoteHosts = remoteHosts.length; var options = {timeout:10000}; for (var i in remoteHosts) { / * Add key value entry into responses array */ clients[i] = fins.FinsClient(9600,remoteHosts[i],options); clients[i].on('reply',function(msg) { /* Add key value pair of [ipAddress] = values from read */ responses[msg.remotehost] = msg.values; /* Check to see size of response array is equal to number of hosts */ if(Object.keys(responses).length == numberOfRemoteHosts){ finished(responses); } if(debug) console.log("Got reply from: ", msg.remotehost); }); /* If timeout occurs log response for that IP as null */ clients[i].on('timeout',function(host) { responses[host] = null; if(Object.keys(responses).length == numberOfRemoteHosts){ finished(responses); }; if(debug) console.log("Got timeout from: ", host); }); clients[i].on('error',function(error) { console.log("Error: ", error) }); /* Read 10 registers starting at DM location 00000 */ clients[i].read('D00000',10); }; }; console.log("Starting....."); pollUnits(); ``` -------------------------------- ### client.read(address, regsToRead, callback) Source: https://context7.com/ptrks/node-omron-fins/llms.txt Reads consecutive registers from a specified memory area starting at the given address. Supports both word-level and bit-level addressing. ```APIDOC ## client.read(address, regsToRead, [callback]) Reads consecutive registers from a specified memory area starting at the given address. Supports both word-level and bit-level addressing. ### Method `client.read(address, regsToRead, [callback])` ### Parameters #### Path Parameters * **address** (string) - Required - The starting memory address (e.g., 'D00000', 'CB1:00'). * **regsToRead** (number) - Required - The number of registers or bits to read. * **callback** (function) - Optional - A callback function to handle the response. Receives `(err, bytes)`. ### Request Example ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { console.log("Read values:", msg.values); // Output: Read values: [ 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 ] }); // Read 10 registers from Data Memory starting at D00000 client.read('D00000', 10); // Read with callback client.read('D00000', 10, function(err, bytes) { console.log("Bytes sent:", bytes); }); // Read a single bit - CIO bit 1.00 client.read('CB1:00', 1, function(err, bytes) { console.log("Bytes:", bytes); }); ``` ### Memory Area Prefixes * **D** - Data Memory (word) * **DM** - Data Memory (bit) * **C** - CIO (word) * **CB** - CIO (bit) * **W** - Work Area (word) * **WB** - Work Area (bit) * **H** - Holding Bit (word) * **HB** - Holding Bit (bit) * **A** - Auxiliary Bit (word) * **AB** - Auxiliary Bit (bit) * **E** - Extended Memory ### Response * **values** (Array) - An array containing the read values. The type of values (word or bit) depends on the memory area and addressing used. ``` -------------------------------- ### Write to Memory Area (with callback) Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Provides examples of the `.write()` method for writing data to OMRON devices. It covers writing single values, multiple values to consecutive registers, and specific bits within registers. An optional callback can be provided for asynchronous handling. ```javascript /* Writes single value of 1337 into DM register 00000 */ .write('D00000',1337) /* Writes 1 to bit 3 of HB register 50 */ .write('HB50:03',1) /* Writes the values 12,34,56 into DM registers 00000 00001 000002 */ .write('D00000',[12,34,56]); /* Same as above with callback */ .write('D00000',[12,34,56],function(err,bytes) { console.log("Bytes: ", bytes); }); /* Writes 1 to bits 3,4 & 5 of HB register 50 */ .write('HB50:03',[1,1,1]) ``` -------------------------------- ### Read PLC Memory Registers (Node.js) Source: https://context7.com/ptrks/node-omron-fins/llms.txt Reads consecutive registers from a specified memory area starting at the given address. Supports both word-level and bit-level addressing. Callbacks can be provided for asynchronous handling. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { console.log("Read values:", msg.values); // Output: Read values: [ 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 ] }); // Read 10 registers from Data Memory starting at D00000 client.read('D00000', 10); // Read with callback client.read('D00000', 10, function(err, bytes) { console.log("Bytes sent:", bytes); }); // Read a single bit - CIO bit 1.00 client.read('CB1:00', 1, function(err, bytes) { console.log("Bytes:", bytes); }); // Memory area prefixes: // D - Data Memory (word) // DM - Data Memory (bit) // C - CIO (word) // CB - CIO (bit) // W - Work Area (word) // WB - Work Area (bit) // H - Holding Bit (word) // HB - Holding Bit (bit) // A - Auxiliary Bit (word) // AB - Auxiliary Bit (bit) // E - Extended Memory ``` -------------------------------- ### Fill Registers with Value using Node.js Source: https://context7.com/ptrks/node-omron-fins/llms.txt Fills a specified number of consecutive registers with a given value. This is useful for initializing or clearing memory areas in the PLC. It takes the starting address, the value to write, and the number of registers to write. An optional callback can be provided for asynchronous operations. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { if (msg.response === '0000') { console.log("Fill successful"); } }); // Fill 10 registers starting at D00100 with value 1337 // D00100 through D00109 will all contain 1337 client.fill('D00100', 1337, 10); // Fill with callback client.fill('D00100', 1337, 10, function(err, bytes) { console.log("Bytes sent:", bytes); }); // Clear 100 registers (set to 0) client.fill('D00000', 0, 100); ``` -------------------------------- ### Write PLC Memory Registers (Node.js) Source: https://context7.com/ptrks/node-omron-fins/llms.txt Writes values to consecutive registers starting at the specified address. Supports single values, arrays, and bit-level writes. Callbacks can be provided for asynchronous handling. Bit values are 0 for OFF and 1 for ON. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { if (msg.response === '0000') { console.log("Write successful"); } }); // Write single value to D00000 client.write('D00000', 1337); // Write array of values to consecutive registers D00000, D00001, D00002 client.write('D00000', [12, 34, 56]); // Write with callback client.write('D00000', [12, 34, 56], function(err, bytes) { console.log("Bytes sent:", bytes); }); // Write to a single bit - set bit 3 of HB register 50 to ON client.write('HB50:03', 1); // Write to multiple consecutive bits - set bits 3, 4, 5 of HB50 client.write('HB50:03', [1, 1, 1]); // Bit values: 0 = OFF, 1 = ON // Note: Writing values > 1 to bits will cause an error ``` -------------------------------- ### Create FinsClient Instance Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Illustrates the creation of a `FinsClient` object, which is the main interface for communicating with OMRON devices. It requires specifying the port, IP address, and optional configuration like timeout. ```javascript var options = {timeout:10000}; var client = fins.FinsClient(9600,'127.0.0.1'); ``` -------------------------------- ### Transfer Memory Area (with callback) Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Demonstrates the `.transfer()` command, used for copying data between memory areas. It specifies the source address, destination address, and the number of registers to transfer. An optional callback handles the operation's completion or errors. ```javascript /* Transfers 10 consecutive DM registers from 50 to 100 */ .fill('D50','D100',10); /* Sames as above with callback */ .fill('D50','D100',10,function(err,bytes) { console.log("Bytes: ", bytes); }); ``` -------------------------------- ### Initialize FINS Client with Event Listeners (Node.js) Source: https://context7.com/ptrks/node-omron-fins/llms.txt Creates a new FINS client instance for communicating with an OMRON PLC. The client is an EventEmitter that emits 'reply', 'timeout', and 'error' events. It can be configured with default or custom timeouts. ```javascript var fins = require('omron-fins'); // Create client with default timeout (2000ms) var client = fins.FinsClient(9600, '192.168.1.10'); // Create client with custom timeout (10 seconds) var options = { timeout: 10000 }; var client = fins.FinsClient(9600, '192.168.1.10', options); // Set up event listeners client.on('reply', function(msg) { console.log("Remote Host:", msg.remotehost); // IP address of responding device console.log("Transaction SID:", msg.sid); // Transaction identifier console.log("Command Code:", msg.command); // Issued command code (hex) console.log("Response Code:", msg.response); // Response code from PLC console.log("Values:", msg.values); // Array of read values (if applicable) }); client.on('timeout', function(host) { console.log("Timeout from:", host); }); client.on('error', function(error) { console.log("Error:", error); }); ``` -------------------------------- ### FinsClient Constructor Source: https://context7.com/ptrks/node-omron-fins/llms.txt Creates a new FINS client instance for communicating with an OMRON PLC. The client is an EventEmitter that emits 'reply', 'timeout', and 'error' events. ```APIDOC ## FinsClient Constructor Creates a new FINS client instance for communicating with an OMRON PLC. The client is an EventEmitter that emits `reply`, `timeout`, and `error` events. ### Method `FinsClient(port, host, [options])` ### Parameters #### Path Parameters * **port** (number) - Required - The UDP port to use for communication. * **host** (string) - Required - The IP address of the OMRON PLC or FINS-capable device. #### Query Parameters * **options** (object) - Optional - Configuration options for the client. * **timeout** (number) - Optional - The timeout in milliseconds for FINS requests. Defaults to 2000ms. ### Request Example ```javascript var fins = require('omron-fins'); // Create client with default timeout (2000ms) var client = fins.FinsClient(9600, '192.168.1.10'); // Create client with custom timeout (10 seconds) var options = { timeout: 10000 }; var client = fins.FinsClient(9600, '192.168.1.10', options); // Set up event listeners client.on('reply', function(msg) { console.log("Remote Host:", msg.remotehost); // IP address of responding device console.log("Transaction SID:", msg.sid); // Transaction identifier console.log("Command Code:", msg.command); // Issued command code (hex) console.log("Response Code:", msg.response); // Response code from PLC console.log("Values:", msg.values); // Array of read values (if applicable) }); client.on('timeout', function(host) { console.log("Timeout from:", host); }); client.on('error', function(error) { console.log("Error:", error); }); ``` ### Response * **reply** (event) - Emitted when a response is received from the device. * **remotehost** (string) - The IP address of the responding device. * **sid** (number) - The transaction identifier. * **command** (string) - The issued command code in hexadecimal format. * **response** (string) - The response code from the PLC. * **values** (Array) - An array of read values (if applicable). * **timeout** (event) - Emitted when a FINS request times out. * **host** (string) - The IP address of the device that timed out. * **error** (event) - Emitted when an error occurs. * **error** (Error) - The error object. ``` -------------------------------- ### Asynchronous Communication with Multiple PLC Devices (JavaScript) Source: https://context7.com/ptrks/node-omron-fins/llms.txt This JavaScript code demonstrates establishing simultaneous asynchronous connections to multiple OMRON PLC devices. It configures each client with specific options, sets up event listeners for 'reply', 'timeout', and 'error', and initiates a read operation for a set of registers on each PLC. The `finished` callback is invoked once all responses are received or timeouts occur. ```javascript var fins = require('omron-fins'); var clients = []; var responses = []; var remoteHosts = ['192.168.1.10', '192.168.1.11', '192.168.1.12']; var finished = function(responses) { console.log("All responses received:"); for (var host in responses) { if (responses[host] !== null) { console.log(host + ": " + responses[host]); } else { console.log(host + ": TIMEOUT"); } } // Process data - send to database, API, etc. }; var pollUnits = function() { var numberOfRemoteHosts = remoteHosts.length; var options = { timeout: 10000 }; for (var i in remoteHosts) { clients[i] = fins.FinsClient(9600, remoteHosts[i], options); clients[i].on('reply', function(msg) { responses[msg.remotehost] = msg.values; if (Object.keys(responses).length == numberOfRemoteHosts) { finished(responses); } }); clients[i].on('timeout', function(host) { responses[host] = null; if (Object.keys(responses).length == numberOfRemoteHosts) { finished(responses); } }); clients[i].on('error', function(error) { console.log("Error:", error); }); // Read 10 registers from each PLC clients[i].read('D00000', 10); } }; pollUnits(); ``` -------------------------------- ### Read PLC Controller Status using Node.js Source: https://context7.com/ptrks/node-omron-fins/llms.txt Reads the current status of the PLC controller. This includes information about the PLC's operating mode (RUN, STOP, CPU_STANDBY), execution mode (RUN, MONITOR, DEBUG), and details about any fatal or non-fatal errors. An optional callback can be provided. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { console.log("Status:", msg.status); // 'RUN', 'STOP', or 'CPU_STANDBY' console.log("Mode:", msg.mode); // 'RUN', 'MONITOR', or 'DEBUG' console.log("Fatal Errors:", msg.fatalErrorData); console.log("Non-Fatal Errors:", msg.nonFatalErrorData); // Fatal error types: SYSTEM_ERROR, IO_SETTING_ERROR, IO_POINT_OVERFLOW, // CPU_BUS_ERROR, MEMORY_ERROR // Non-fatal types: PC_LINK_ERROR, HOST_LINK_ERROR, BATTERY_ERROR, // REMOTE_IO_ERROR, SPECIAL_IO_UNIT_ERROR, IO_COLLATE_ERROR }); client.status(); // With callback client.status(function(err, bytes) { console.log("Bytes sent:", bytes); }); ``` -------------------------------- ### Require node-omron-fins Library Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Shows how to include the node-omron-fins library in your Node.js project. This is typically done at the beginning of your script using the `require` function. ```javascript var fins = require('omron-fins'); ``` -------------------------------- ### Read Multiple Memory Areas Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Shows the usage of the `.readMultiple()` command to fetch data from various memory locations simultaneously. This method accepts an array of addresses, allowing for flexible data retrieval from different memory areas. ```javascript /* Reads multiple registers from different memory areas, you can mix and match words and bit reads. Does not currently support callback */ .readMultiple('D100','H10','CB80:03','H22'); ``` -------------------------------- ### client.readMultiple(addresses...) Source: https://context7.com/ptrks/node-omron-fins/llms.txt Reads from multiple non-consecutive memory addresses in a single command. Supports mixing word and bit reads. ```APIDOC ## client.readMultiple(addresses...) Reads from multiple non-consecutive memory addresses in a single command. Supports mixing word and bit reads. ### Method `client.readMultiple(address1, address2, ..., addressN)` ### Parameters #### Path Parameters * **addresses** (string) - Required - One or more memory addresses to read from. Can be a mix of word and bit addresses. ### Request Example ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { console.log("Multiple read values:", msg.values); // Output: Multiple read values: [ 1234, 5678, 9012, 1, 3456 ] // Values are returned in the same order as requested addresses }); // Read from multiple memory areas - mix of words and bits client.readMultiple('H18', 'W32', 'H20', 'CB80:03', 'H22'); // Read multiple Data Memory addresses client.readMultiple('D100', 'D200', 'D300', 'D400'); // Note: readMultiple does not support callbacks ``` ### Response * **values** (Array) - An array containing the read values. The values are returned in the same order as the requested addresses. ``` -------------------------------- ### Read Multiple PLC Memory Addresses (Node.js) Source: https://context7.com/ptrks/node-omron-fins/llms.txt Reads from multiple non-consecutive memory addresses in a single command. Supports mixing word and bit reads. The values are returned in the same order as the requested addresses. This method does not support callbacks. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { console.log("Multiple read values:", msg.values); // Output: Multiple read values: [ 1234, 5678, 9012, 1, 3456 ] // Values are returned in the same order as requested addresses }); // Read from multiple memory areas - mix of words and bits client.readMultiple('H18', 'W32', 'H20', 'CB80:03', 'H22'); // Read multiple Data Memory addresses client.readMultiple('D100', 'D200', 'D300', 'D400'); // Note: readMultiple does not support callbacks ``` -------------------------------- ### Handle FINS Protocol Replies Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Defines an event listener for 'reply' events emitted by the `FinsClient`. This listener processes incoming messages, logging details such as the transaction identifier, command code, response code, and the remote host's IP address. ```javascript client.on('reply',msg){ console.log('SID: ', msg.sid); console.log('Command Code: ', msg.command); console.log('Response Code: ', msg.response); console.log('Remote Host: ', msg.remotehost); }); ``` -------------------------------- ### Stop PLC Program Execution with Callback Source: https://github.com/ptrks/node-omron-fins/blob/master/README.md Stops the PLC program execution by putting it into program mode. An optional callback can be provided to handle the completion of the stop operation, including error and byte count details. The function can also be called without arguments. ```javascript /* Stops program excution by putting into Program mode */ .stop(function(err,bytes) { }); .stop(); ``` -------------------------------- ### Stop PLC Program Execution using Node.js Source: https://context7.com/ptrks/node-omron-fins/llms.txt Stops the PLC program execution by transitioning the controller to Program mode. This is typically used for maintenance, debugging, or safely halting operations. An optional callback can be provided for asynchronous confirmation. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { if (msg.response === '0000') { console.log("PLC stopped"); } }); // Stop the PLC client.stop(); // With callback client.stop(function(err, bytes) { console.log("Stop command sent, bytes:", bytes); }); ``` -------------------------------- ### Transfer Data Between PLC Registers using Node.js Source: https://context7.com/ptrks/node-omron-fins/llms.txt Transfers data between consecutive memory registers within the PLC. It copies a specified number of registers from a source address to a destination address. This function is useful for moving data blocks. An optional callback can be provided for asynchronous operations. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { if (msg.response === '0000') { console.log("Transfer successful"); } }); // Transfer 10 registers from H500 to H1000 // H500-H509 will be copied to H1000-H1009 client.transfer('H500', 'H1000', 10); // Transfer with callback client.transfer('H500', 'H1000', 10, function(err, bytes) { console.log("Bytes sent:", bytes); }); // Transfer between different memory areas client.transfer('D50', 'D100', 10); ``` -------------------------------- ### Close PLC Connection using Node.js Source: https://context7.com/ptrks/node-omron-fins/llms.txt Closes the UDP socket connection to the PLC and clears any pending timeouts. This method should be called when communication with the PLC is no longer required to free up resources and prevent potential issues. It's often used in response handlers or timeout events. ```javascript var fins = require('omron-fins'); var client = fins.FinsClient(9600, '192.168.1.10'); client.on('reply', function(msg) { console.log("Values:", msg.values); // Close connection after receiving response client.close(); }); client.on('timeout', function(host) { console.log("Timeout - closing connection"); client.close(); }); client.read('D00000', 10); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.