Attached amtterm to stdin and stdout
Bryan Roe committed
Aug 3, 2022 at 01:19 UTC
2939503ffc7830468adcdf28618cfe76a33b7125
1 file changed
+18
-9
agents/meshcmd.js
+18
-9
@@ -25,7 +25,7 @@ limitations under the License.
25
//console.displayStreamPipeMessages = 1; // Display stream pipe and un-pipes
26
//var __gc = setInterval(function () { console.log('GC'); _debugGC() }, 2000); //
27
28
-
28
+setModulePath('modules_meshcmd');
29
var fs = require('fs');
30
var os = require('os');
31
var net = require('net');
@@ -3016,19 +3016,28 @@ function performAmtTerm(args) {
3016
// Called when the serial-over-lan connection state changes
3017
function onSolStateChange(stack, state) {
3018
console.log(["Disconnected", "Connecting...", "Connected...", "Started Serial-over-LAN..."][state]);
3019
- if (state == 0) { exit(0); }
3020
- if (state == 3) {
3021
- // TODO: Serial-over-LAN is connected, we need to send stdin keys using sol.m.Send('abc');
3022
- // For now, we setup thie timer to send 'abc' at one second interval into serial-over-lan channel.
3023
- if (solTimer == null) { solTimer = setInterval(function () { sol.m.Send('abc'); }, 1000); }
3024
- } else {
3019
+ if (state == 0)
3020
+ {
3021
+ console.echo = true; // This enables local echo to the console when keys are pressed
3022
+ console.canonical = true; // This puts the console into canonical mode, which means stdin will not process each key press individually, instead it will process line by line.
3023
+ exit(0);
3024
+ }
3025
+ if (state == 3)
3026
+ {
3027
+ console.echo = false; // This disables local echo to the console when keys are pressed
3028
+ console.canonical = false; // This takes the console out of canonical mode, which means stdin will process each key press individually, instead of by line.
3029
+ process.stdin.on('data', function (c) { sol.m.Send(c); });
3030
+ }
3031
+ else
3032
+ {
3033
// Serial-over-LAN is not active, stop any stdin key capture
3026
- if (solTimer != null) { clearInterval(solTimer); solTimer = null; }
3034
+ console.echo = true; // This enables local echo to the console when keys are pressed
3035
+ console.canonical = true; // This puts the console into canonical mode, which means stdin will not process each key press individually, instead it will process line by line.
3036
}
3037
}
3038
3039
// This is called when serial-over-lan data come in from Intel AMT
3031
-function onSolData(stack, data) { console.log(data); }
3040
+function onSolData(stack, data) { process.stdout.write(data); }
3041
3042
3043
//