File tree Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Expand file tree Collapse file tree 3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change 1
1
import { WebSocket } from 'ws' ;
2
+ import { Writable } from 'stream' ;
2
3
import type {
3
4
APICommand ,
4
5
APIError ,
@@ -156,6 +157,19 @@ export class APIClient {
156
157
} ) ;
157
158
}
158
159
160
+ serialMonitorWritable ( ) {
161
+ return new Writable ( {
162
+ write : ( chunk , encoding , callback ) => {
163
+ if ( typeof chunk === 'string' ) {
164
+ chunk = Buffer . from ( chunk , encoding ) ;
165
+ }
166
+ this . serialMonitorWrite ( chunk ) . then ( ( ) => {
167
+ callback ( null ) ;
168
+ } , callback ) ;
169
+ } ,
170
+ } ) ;
171
+ }
172
+
159
173
async framebufferRead ( partId : string ) {
160
174
return await this . sendCommand < { png : string } > ( 'framebuffer:read' , {
161
175
id : partId ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export function cliHelp() {
12
12
{green --expect-text} <string> Expect the given text in the output
13
13
{green --fail-text} <string> Fail if the given text is found in the output
14
14
{green --elf} <path> ELF file to simulate (default: read from wokwi.toml)
15
+ {green --interactive} Redirect stdin to the simulated serial port
15
16
{green --scenario} <path> Run the given scenario (yaml) file, path is relative to project root
16
17
{green --serial-log-file} <path> Save the serial monitor output to the given file
17
18
{green --screenshot-part} <string> Take a screenshot of the given part id (from diagram.json)
Original file line number Diff line number Diff line change @@ -29,6 +29,7 @@ async function main() {
29
29
'--elf' : String ,
30
30
'--expect-text' : String ,
31
31
'--fail-text' : String ,
32
+ '--interactive' : Boolean ,
32
33
'--serial-log-file' : String ,
33
34
'--scenario' : String ,
34
35
'--screenshot-part' : String ,
@@ -46,6 +47,7 @@ async function main() {
46
47
const elf = args [ '--elf' ] ;
47
48
const expectText = args [ '--expect-text' ] ;
48
49
const failText = args [ '--fail-text' ] ;
50
+ const interactive = args [ '--interactive' ] ;
49
51
const serialLogFile = args [ '--serial-log-file' ] ;
50
52
const scenarioFile = args [ '--scenario' ] ;
51
53
const timeout = args [ '--timeout' ] ?? 30000 ;
@@ -255,6 +257,10 @@ async function main() {
255
257
pause : timeToNextEvent >= 0 ,
256
258
} ) ;
257
259
260
+ if ( interactive ) {
261
+ process . stdin . pipe ( client . serialMonitorWritable ( ) ) ;
262
+ }
263
+
258
264
if ( timeToNextEvent > 0 ) {
259
265
await client . simResume ( timeToNextEvent ) ;
260
266
}
You can’t perform that action at this time.
0 commit comments