Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function serial_connection(body, username) {
- require("./start_configuration/eltex_configuration_file")(body, username); // creating the configuration file
- var SerialPort = require('serialport');
- var port = new SerialPort('COM' + body.serial_port_number, {
- baudRate: 115200,
- flowControl: false,
- dataBits: 8
- });
- // Open errors will be emitted as an error event
- port.on('error', function (err) {
- console.log('Error: ', err.message);
- })
- // Switches the port into "flowing mode"
- port.on('data', function (data) {
- console.log('Data1:', data.toString('utf-8'));
- });
- /*
- // Дополнительный способ загрузки старотовых конфигураций в оборудование, набором команд
- var start_configuration =
- "exit\nexit\nexit\n" +
- "ip ssh server\n" +
- "interface vlan " + body.vlan_number + "\n" +
- "ip address " + body.ip_address + " " + body.net_mask + "\n" +
- "no ip address dhcp\n" +
- "exit\n" +
- "ip route 0.0.0.0 0.0.0.0 " + body.ip_default_gateway + "\n" +
- "exit\nexit\nexit\n";
- port.write(start_configuration, function (err) {
- if (err) {
- return console.log("Err: ", err.message);
- }
- else {
- port.close();
- }
- });
- */
- var ip_tftp_server = "172.16.0.215"; // address of tftp server
- // создание загрузка настроек
- port.write('exit\nen\ncopy tftp://' + ip_tftp_server + '/' + username + '/config' + ' running-config\n');
- }
- module.exports = serial_connection;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement