()
| 10 | } |
| 11 | |
| 12 | function parseArgs(): RunOptions { |
| 13 | const args = process.argv.slice(2); |
| 14 | |
| 15 | if (args.length === 0 || args.includes("--help") || args.includes("-h")) { |
| 16 | console.log(` |
| 17 | AVR8JS Test Runner - Execute AVR hex files in simulation |
| 18 | |
| 19 | Usage: npm start <hex-file> [options] |
| 20 | |
| 21 | Arguments: |
| 22 | hex-file Path to Intel HEX file to execute |
| 23 | |
| 24 | Options: |
| 25 | --timeout <seconds> Maximum simulated time in seconds (default: 30) |
| 26 | --verbose Enable verbose output |
| 27 | -h, --help Show this help message |
| 28 | |
| 29 | Example: |
| 30 | npm start build/output.hex --timeout 5 |
| 31 | `); |
| 32 | exit(args.includes("--help") || args.includes("-h") ? 0 : 1); |
| 33 | } |
| 34 | |
| 35 | const options: RunOptions = { |
| 36 | hexFile: args[0], |
| 37 | timeout: 30, |
| 38 | verbose: false |
| 39 | }; |
| 40 | |
| 41 | for (let i = 1; i < args.length; i++) { |
| 42 | if (args[i] === "--timeout" && i + 1 < args.length) { |
| 43 | options.timeout = parseFloat(args[++i]); |
| 44 | } else if (args[i] === "--verbose") { |
| 45 | options.verbose = true; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | return options; |
| 50 | } |
| 51 | |
| 52 | async function executeProgram(hex: string, options: RunOptions): Promise<number> { |
| 53 | const runner = new AVRRunner(hex); |
no test coverage detected