mirror of
				https://github.com/node-red/node-red-nodes.git
				synced 2025-03-01 10:37:43 +00:00 
			
		
		
		
	serial control rc 1
This commit is contained in:
		| @@ -366,7 +366,7 @@ | ||||
|     }); | ||||
| </script> | ||||
|  | ||||
| <script type="text/html" data-template-name="port select"> | ||||
| <script type="text/html" data-template-name="serial control"> | ||||
|     <div class="form-row node-input-serial"> | ||||
|         <label for="node-input-serial"><i class="fa fa-random"></i> <span data-i18n="serial.label.serialport"></span></label> | ||||
|         <input type="text" id="node-input-serial"> | ||||
| @@ -378,7 +378,7 @@ | ||||
| </script> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     RED.nodes.registerType('port select',{ | ||||
|     RED.nodes.registerType('serial control',{ | ||||
|         category: 'network', | ||||
|         defaults: { | ||||
|             name: {name:""}, | ||||
|   | ||||
| @@ -225,7 +225,7 @@ module.exports = function(RED) { | ||||
|     RED.nodes.registerType("serial request", SerialRequestNode); | ||||
|  | ||||
|  | ||||
|     // Port Select Node | ||||
|     // Serial Control Node | ||||
|     function PortSelectNode(n) { | ||||
|         RED.nodes.createNode(this,n); | ||||
|         this.serialConfig = RED.nodes.getNode(n.serial); | ||||
| @@ -252,13 +252,13 @@ module.exports = function(RED) { | ||||
|                 node.send({payload: node.serialConfig}); | ||||
|             } else if (msg.payload.hasOwnProperty("stop")) {  | ||||
|                 serialPool.close(node.serialConfig.serialport,() => { | ||||
|                     RED.log.info("[serialconfig:"+node.serialConfig.id+"] stopped"); | ||||
|                     RED.log.info("[serialconfig:"+node.serialConfig.id+"] " + RED._("serial.stopped",{port:node.serialConfig.serialport})); | ||||
|                 }); | ||||
|                 node.send({payload: node.serialConfig}); | ||||
|             } | ||||
|         }); | ||||
|     } | ||||
|     RED.nodes.registerType("port select", PortSelectNode); | ||||
|     RED.nodes.registerType("serial control", PortSelectNode); | ||||
|  | ||||
|     var serialPool = (function() { | ||||
|         var connections = {}; | ||||
|   | ||||
| @@ -68,6 +68,7 @@ | ||||
|             "closed": "serial port __port__ closed", | ||||
|             "list": "Failed to list ports. Please enter manually.", | ||||
|             "badbaudrate": "Baudrate is invalid" | ||||
|         } | ||||
|         }, | ||||
|         "stopped": "__port__ stopped" | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user