@@ -3,12 +3,13 @@ import chalk from 'chalk';
33import { existsSync , readFileSync , writeFileSync } from 'fs' ;
44import path , { join } from 'path' ;
55import { APIClient } from './APIClient' ;
6- import type { APIEvent , SerialMonitorDataPayload } from './APITypes' ;
6+ import type { APIEvent , ChipsLogPayload , SerialMonitorDataPayload } from './APITypes' ;
77import { EventManager } from './EventManager' ;
88import { ExpectEngine } from './ExpectEngine' ;
99import { parseConfig } from './config' ;
1010import { cliHelp } from './help' ;
1111import { readVersion } from './readVersion' ;
12+ import { loadChips } from './loadChips' ;
1213
1314const millis = 1_000_000 ;
1415
@@ -90,6 +91,8 @@ async function main() {
9091 process . exit ( 1 ) ;
9192 }
9293
94+ const chips = loadChips ( config . chip ?? [ ] , rootDir ) ;
95+
9396 const expectEngine = new ExpectEngine ( ) ;
9497
9598 if ( expectText ) {
@@ -126,6 +129,11 @@ async function main() {
126129 await client . fileUpload ( firmwareName , readFileSync ( firmwarePath ) ) ;
127130 await client . fileUpload ( 'firmware.elf' , readFileSync ( elfPath ) ) ;
128131
132+ for ( const chip of chips ) {
133+ await client . fileUpload ( `${ chip . name } .chip.json` , readFileSync ( chip . jsonPath , 'utf-8' ) ) ;
134+ await client . fileUpload ( `${ chip . name } .chip.wasm` , readFileSync ( chip . wasmPath ) ) ;
135+ }
136+
129137 if ( ! quiet ) {
130138 console . log ( 'Starting simulation...' ) ;
131139 }
@@ -151,14 +159,6 @@ async function main() {
151159
152160 await client . serialMonitorListen ( ) ;
153161 const { timeToNextEvent } = eventManager ;
154- await client . simStart ( {
155- elf : 'test.elf' ,
156- firmware : firmwareName ,
157- pause : timeToNextEvent >= 0 ,
158- } ) ;
159- if ( timeToNextEvent > 0 ) {
160- await client . simResume ( timeToNextEvent ) ;
161- }
162162
163163 client . onEvent = ( event ) => {
164164 if ( event . event === 'sim:pause' ) {
@@ -174,7 +174,22 @@ async function main() {
174174 }
175175 expectEngine . feed ( bytes ) ;
176176 }
177+ if ( event . event === 'chips:log' ) {
178+ const { message, chip } = ( event as APIEvent < ChipsLogPayload > ) . payload ;
179+ console . log ( chalk `[{magenta ${ chip } }] ${ message } ` ) ;
180+ }
177181 } ;
182+
183+ await client . simStart ( {
184+ elf : 'test.elf' ,
185+ firmware : firmwareName ,
186+ chips : chips . map ( ( chip ) => chip . name ) ,
187+ pause : timeToNextEvent >= 0 ,
188+ } ) ;
189+
190+ if ( timeToNextEvent > 0 ) {
191+ await client . simResume ( timeToNextEvent ) ;
192+ }
178193}
179194
180195main ( ) . catch ( ( err ) => {
0 commit comments