Implemented serial-monitoring for the backend.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
Akos Kitta
2019-08-01 08:22:29 +02:00
committed by jbicker
parent 8d79bb3ffb
commit 692c3f6e3f
8 changed files with 383 additions and 3 deletions

View File

@@ -0,0 +1,43 @@
import { JsonRpcServer } from '@theia/core';
import { Board } from './boards-service';
export interface MonitorError {
readonly message: string;
readonly code: number
}
export interface MonitorReadEvent {
readonly connectionId: string;
readonly data: string;
}
export const MonitorServiceClient = Symbol('MonitorServiceClient');
export interface MonitorServiceClient {
notifyRead(event: MonitorReadEvent): void;
notifyError(event: MonitorError): void;
}
export const MonitorServicePath = '/services/serial-monitor';
export const MonitorService = Symbol('MonitorService');
export interface MonitorService extends JsonRpcServer<MonitorServiceClient> {
connect(config: ConnectionConfig): Promise<{ connectionId: string }>;
disconnect(connectionId: string): Promise<boolean>;
send(connectionId: string, data: string | Uint8Array): Promise<void>;
}
export interface ConnectionConfig {
readonly board: Board;
readonly port: string;
/**
* Defaults to [`SERIAL`](ConnectionType#SERIAL).
*/
readonly type?: ConnectionType;
/**
* Defaults to `9600`.
*/
readonly baudRate?: number;
}
export enum ConnectionType {
SERIAL = 0
}