Skip to content

Commit a3290fd

Browse files
committed
Refactored advanced decoder interface
1 parent a7b468e commit a3290fd

File tree

4 files changed

+58
-25
lines changed

4 files changed

+58
-25
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import { SWODecoderConfig } from './common';
2+
3+
export interface SWOAdvancedDecoderConfig extends SWODecoderConfig {
4+
decoder: string;
5+
config: any;
6+
ports: number[];
7+
}
8+
9+
export interface AdvancedDecoder {
10+
/**
11+
* @param config: Contains the swo configuration from launch.json. Do not modify this object
12+
* @param outputData: function to call to output data to the OUTPUT Window
13+
* @param graphData: Function that emits a message to the grapher. Not sure how this works
14+
*
15+
* I am documenting what I know. Please make a PR with edits if you know more. Do not use
16+
* the parameters outputData or graphData until after init is ready. If you wish to do any debug
17+
* prints, use console.log(...)
18+
*
19+
* Note that typeName() and outputLabel() are used to create a name for the OUTPUT panel. So, you
20+
* can't use outputData/graphData in those methods either.
21+
*/
22+
init(
23+
config: SWOAdvancedDecoderConfig,
24+
outputData: (output: string, timestamp?: boolean) => void,
25+
graphData: (data: number, id: string) => void
26+
): void;
27+
28+
typeName(): string; // Used to create the OUTPUT Panel name
29+
outputLabel(): string; // Used to create the OUTPUT Panel name
30+
31+
/**
32+
*
33+
* @param port: the ITM Port
34+
* @param data: Data just received
35+
*/
36+
softwareEvent(port: number, data: Buffer): void;
37+
38+
/**
39+
* SWV Sync packet received. Probably can be ignored
40+
*/
41+
synchronized(): void;
42+
/**
43+
* SWV Sync lost. Probably can be ignored
44+
*/
45+
lostSynchronization(): void;
46+
47+
/**
48+
* Do any cleanup you want to. Again do not use any functions passed to init from here
49+
* because they are in the process of being destroyed. Even if it works, we cannot guarantee
50+
* that in the future
51+
*/
52+
dispose?(): void;
53+
}

src/frontend/swo/common.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ export interface SWOGraphDecoderConfig extends SWOBasicDecoderConfig {
2828
graphId: string;
2929
}
3030

31-
export interface SWOAdvancedDecoderConfig extends SWODecoderConfig {
32-
decoder: string;
33-
config: any;
34-
ports: number[];
35-
}
36-
3731
export interface GraphConfiguration {
3832
type: string;
3933
label: string;
@@ -88,20 +82,6 @@ export interface GrapherConfigurationMessage extends GrapherMessage {
8882
status: 'stopped' | 'terminated' | 'continued';
8983
}
9084

91-
export interface AdvancedDecoder {
92-
init(
93-
config: SWOAdvancedDecoderConfig,
94-
outputData: (output: string, timestamp?: boolean) => void,
95-
graphData: (data: number, id: string) => void
96-
): void;
97-
typeName(): string;
98-
outputLabel(): string;
99-
softwareEvent(port: number, data: Buffer): void;
100-
synchronized(): void;
101-
lostSynchronization(): void;
102-
dispose?(): void;
103-
}
104-
10585
export enum PacketType {
10686
HARDWARE = 1,
10787
SOFTWARE,

src/frontend/swo/core.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,9 @@ import { SWOBinaryProcessor } from './decoders/binary';
77
import { SWORTTGraphProcessor } from './decoders/graph';
88
import { SWORTTDecoder } from './decoders/common';
99
import { SWORTTSource } from './sources/common';
10-
import { SWODecoderConfig, GraphConfiguration, SWOAdvancedDecoderConfig,
11-
SWOBinaryDecoderConfig, SWOConsoleDecoderConfig, SWOGraphDecoderConfig,
12-
SWOBasicDecoderConfig, GrapherMessage, GrapherStatusMessage,
13-
GrapherProgramCounterMessage } from './common';
10+
import { SWODecoderConfig, GraphConfiguration, SWOBinaryDecoderConfig, SWOConsoleDecoderConfig, SWOGraphDecoderConfig,
11+
SWOBasicDecoderConfig, GrapherMessage, GrapherStatusMessage, GrapherProgramCounterMessage } from './common';
12+
import { SWOAdvancedDecoderConfig } from './advanced-decoder';
1413
import { SWORTTAdvancedProcessor } from './decoders/advanced';
1514
import { EventEmitter } from 'events';
1615
import { PacketType, Packet } from './common';

src/frontend/swo/decoders/advanced.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import * as vscode from 'vscode';
22
import { SWORTTDecoder } from './common';
3-
import { SWOAdvancedDecoderConfig, AdvancedDecoder, GrapherDataMessage } from '../common';
3+
import { GrapherDataMessage } from '../common';
4+
import { SWOAdvancedDecoderConfig, AdvancedDecoder } from '../advanced-decoder';
45
import { EventEmitter } from 'events';
56
import { Packet } from '../common';
67
import { CortexDebugChannel } from '../../../dbgmsgs';

0 commit comments

Comments
 (0)