File tree 5 files changed +13
-17
lines changed
5 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -122,10 +122,7 @@ export default function App() {
122
122
if ( config ?. monitorUISettings ?. generate ) {
123
123
const randomValuesInterval = setInterval ( ( ) => {
124
124
const messages = namedVariablesMulti ( ) ;
125
- onMiddlewareMessage ( {
126
- command : null ,
127
- data : messages ,
128
- } ) ;
125
+ onMiddlewareMessage ( messages ) ;
129
126
} , 32 ) ;
130
127
return ( ) => {
131
128
clearInterval ( randomValuesInterval ) ;
Original file line number Diff line number Diff line change @@ -190,12 +190,12 @@ function _Chart(
190
190
} ;
191
191
192
192
useImperativeHandle ( ref , ( ) => ( {
193
- addNewData ( data : string [ ] ) {
193
+ addNewData ( message : string [ ] ) {
194
194
if ( pause ) {
195
195
return ;
196
196
}
197
197
// upon message receival update the chart
198
- worker . postMessage ( { data } ) ;
198
+ worker . postMessage ( { message } ) ;
199
199
} ,
200
200
} ) ) ;
201
201
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ export function MessageToBoard({
14
14
const [ message , setMessage ] = useState ( "" ) ;
15
15
16
16
const [ baudRate , setBaudrate ] = useState (
17
- config ?. pluggableMonitorSettings ?. baudarate ?. selectedValue
17
+ config ?. pluggableMonitorSettings ?. baudrate ?. selectedValue
18
18
) ;
19
19
const [ lineEnding , setLineEnding ] = useState (
20
20
config ?. monitorUISettings ?. lineEnding
@@ -24,7 +24,7 @@ export function MessageToBoard({
24
24
) ;
25
25
26
26
useEffect ( ( ) => {
27
- setBaudrate ( config ?. pluggableMonitorSettings ?. baudarate ?. selectedValue ) ;
27
+ setBaudrate ( config ?. pluggableMonitorSettings ?. baudrate ?. selectedValue ) ;
28
28
} , [ config . pluggableMonitorSettings ] ) ;
29
29
30
30
useEffect ( ( ) => {
@@ -42,7 +42,7 @@ export function MessageToBoard({
42
42
{ value : "\r\n" , label : "Both NL & CR" } ,
43
43
] ;
44
44
45
- const baudrates = config ?. pluggableMonitorSettings ?. baudarate ?. values ?. map (
45
+ const baudrates = config ?. pluggableMonitorSettings ?. baudrate ?. values ?. map (
46
46
( baud ) => ( {
47
47
value : baud ,
48
48
label : `${ baud } baud` ,
Original file line number Diff line number Diff line change @@ -4,15 +4,15 @@ const ctx: Worker = self as any;
4
4
5
5
// Respond to message from parent thread
6
6
ctx . addEventListener ( "message" , ( event ) => {
7
- const { command, data } = event . data ;
7
+ const { command, message } = event . data ;
8
8
9
9
if ( command === "cleanup" ) {
10
10
buffer = "" ;
11
11
discardFirstLine = true ;
12
12
}
13
13
14
- if ( data ) {
15
- ctx . postMessage ( parseSerialMessages ( data ) ) ;
14
+ if ( message ) {
15
+ ctx . postMessage ( parseSerialMessages ( message ) ) ;
16
16
}
17
17
} ) ;
18
18
Original file line number Diff line number Diff line change @@ -58,10 +58,7 @@ export namespace PluggableMonitor {
58
58
command : MiddlewareCommand ;
59
59
data : Partial < MonitorSettings > ;
60
60
} ;
61
- type DataMessage = {
62
- command : unknown ;
63
- data : string [ ] ;
64
- } ;
61
+ type DataMessage = string [ ] ;
65
62
66
63
export type Message =
67
64
| ClientCommandMessage
@@ -72,6 +69,7 @@ export namespace PluggableMonitor {
72
69
message : Message
73
70
) : message is ClientCommandMessage {
74
71
return (
72
+ ! Array . isArray ( message ) &&
75
73
typeof message . command === "string" &&
76
74
Object . keys ( ClientCommand ) . includes ( message . command )
77
75
) ;
@@ -80,12 +78,13 @@ export namespace PluggableMonitor {
80
78
message : Message
81
79
) : message is MiddlewareCommandMessage {
82
80
return (
81
+ ! Array . isArray ( message ) &&
83
82
typeof message . command === "string" &&
84
83
Object . keys ( MiddlewareCommand ) . includes ( message . command )
85
84
) ;
86
85
}
87
86
export function isDataMessage ( message : Message ) : message is DataMessage {
88
- return Array . isArray ( message . data ) ;
87
+ return Array . isArray ( message ) ;
89
88
}
90
89
}
91
90
}
You can’t perform that action at this time.
0 commit comments