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 11import { WebSocket } from 'ws' ;
2+ import { Writable } from 'stream' ;
23import type {
34 APICommand ,
45 APIError ,
@@ -156,6 +157,19 @@ export class APIClient {
156157 } ) ;
157158 }
158159
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+
159173 async framebufferRead ( partId : string ) {
160174 return await this . sendCommand < { png : string } > ( 'framebuffer:read' , {
161175 id : partId ,
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export function cliHelp() {
1212 {green --expect-text} <string> Expect the given text in the output
1313 {green --fail-text} <string> Fail if the given text is found in the output
1414 {green --elf} <path> ELF file to simulate (default: read from wokwi.toml)
15+ {green --interactive} Redirect stdin to the simulated serial port
1516 {green --scenario} <path> Run the given scenario (yaml) file, path is relative to project root
1617 {green --serial-log-file} <path> Save the serial monitor output to the given file
1718 {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() {
2929 '--elf' : String ,
3030 '--expect-text' : String ,
3131 '--fail-text' : String ,
32+ '--interactive' : Boolean ,
3233 '--serial-log-file' : String ,
3334 '--scenario' : String ,
3435 '--screenshot-part' : String ,
@@ -46,6 +47,7 @@ async function main() {
4647 const elf = args [ '--elf' ] ;
4748 const expectText = args [ '--expect-text' ] ;
4849 const failText = args [ '--fail-text' ] ;
50+ const interactive = args [ '--interactive' ] ;
4951 const serialLogFile = args [ '--serial-log-file' ] ;
5052 const scenarioFile = args [ '--scenario' ] ;
5153 const timeout = args [ '--timeout' ] ?? 30000 ;
@@ -255,6 +257,10 @@ async function main() {
255257 pause : timeToNextEvent >= 0 ,
256258 } ) ;
257259
260+ if ( interactive ) {
261+ process . stdin . pipe ( client . serialMonitorWritable ( ) ) ;
262+ }
263+
258264 if ( timeToNextEvent > 0 ) {
259265 await client . simResume ( timeToNextEvent ) ;
260266 }
You can’t perform that action at this time.
0 commit comments