mirror of
				https://github.com/We-Dont-Byte/Mind_Reader.git
				synced 2025-02-04 10:38:42 +00:00 
			
		
		
		
	Add logger, output
This commit is contained in:
		
							
								
								
									
										55
									
								
								package.json
									
									
									
									
									
								
							
							
						
						
									
										55
									
								
								package.json
									
									
									
									
									
								
							@@ -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": {
 | 
			
		||||
 
 | 
			
		||||
@@ -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();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -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
 | 
			
		||||
      };
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user