Add logger, output

This commit is contained in:
jakergrossman 2021-11-18 12:00:46 -06:00
parent 95b23236e0
commit 8d244e5166
3 changed files with 40 additions and 38 deletions

View File

@ -56,35 +56,35 @@
"title": "Run Cursor Context"
},
{
"command": "mind-reader.connectHub",
"title": "Connect LEGO Hub"
},
{
"command": "mind-reader.connectHub",
"title": "Connect LEGO Hub"
},
{
"command": "mind-reader.disconnectHub",
"title": "Disconnect LEGO Hub"
},
{
"command": "mind-reader.disconnectHub",
"title": "Disconnect LEGO Hub"
},
{
"command": "mind-reader.uploadCurrentFile",
"title": "Upload current file to LEGO Hub"
},
{
"command": "mind-reader.uploadCurrentFile",
"title": "Upload current file to LEGO Hub"
},
{
"command": "mind-reader.runProgram",
"title": "Run a program from the LEGO Hub"
},
{
"command": "mind-reader.runProgram",
"title": "Run a program from the LEGO Hub"
},
{
"command": "mind-reader.stopExecution",
"title": "Stop running program on the LEGO Hub"
},
{
"command": "mind-reader.stopExecution",
"title": "Stop running program on the LEGO Hub"
},
{
"command": "mind-reader.deleteProgram",
"title": "Delete a program from the LEGO Hub"
}
{
"command": "mind-reader.deleteProgram",
"title": "Delete a program from the LEGO Hub"
}
],
"keybindings": [
{
@ -207,7 +207,12 @@
"mindreader.connection.portPath": {
"type": "string",
"markdownDescription": "Specifies the serial port path to use if `#mindreader.connectAutomatically#` is not set."
}
},
"mindreader.connection.clearOutputOnRun": {
"type": "boolean",
"description": "Whether to clear the output each time the program is run",
"default": "true"
}
}
},
"views": {

View File

@ -1,17 +1,14 @@
import * as vscode from 'vscode';
import * as pl from './pylex';
import commands from './commands';
import AccessNodeProvider from './accessNodeProvider';
import Logger from './log';
// create output channel
// Output Logger
const outputChannel = vscode.window.createOutputChannel("SPIKE Prime Output");
export function MindReaderOutput(line: string) {
outputChannel.show();
outputChannel.appendLine(line);
}
export const logger = new Logger(outputChannel);
let parser: pl.Parser = new pl.Parser();

View File

@ -2,7 +2,8 @@ import * as vscode from 'vscode';
import * as SerialPort from 'serialport';
import * as fs from 'fs';
import { performance } from 'perf_hooks';
import { MindReaderOutput } from './extension';
import { logger } from './extension';
/**
* @type RPCRequest an RPC request message
@ -104,11 +105,11 @@ export default class HubManager {
const params = json['p'];
switch (json['m']) {
case 'user_program_error':
MindReaderOutput(Buffer.from(params[3], 'base64').toString());
MindReaderOutput(Buffer.from(params[4], 'base64').toString());
logger.error(Buffer.from(params[3], 'base64').toString());
logger.error(Buffer.from(params[4], 'base64').toString());
break;
case 'runtime_error':
MindReaderOutput(Buffer.from(params[3], 'base64').toString());
logger.error(Buffer.from(params[3], 'base64').toString());
break;
}
}
@ -141,7 +142,7 @@ export default class HubManager {
let mgr = this;
this.port.on('data', data => {
mgr.receiveData(data)
mgr.receiveData(data);
});
}
@ -364,7 +365,6 @@ export default class HubManager {
options = {
port: '/dev/ttyACM0',
magic: true,
timeout: 2500,
...options
};