wokwi / rp2040js

A Raspberry Pi Pico Emulator in JavaScript
MIT License
410 stars 46 forks source link

check if stdin isTTY prior to setRawMode. #111

Closed BrianPugh closed 1 year ago

BrianPugh commented 1 year ago

I'm trying to launch this emulator from python via subprocess. Previously it would complain:

process.stdin.setRawMode(true);
              ^
TypeError: process.stdin.setRawMode is not a function
    at Object.<anonymous> (/Users/brianpugh/projects/rp2040js/demo/micropython-run.ts:33:15)
    at Module._compile (node:internal/modules/cjs/loader:1205:14)
    at Module.m._compile (/Users/brianpugh/projects/rp2040js/node_modules/ts-node/src/index.ts:1056:23)
    at Module._extensions..js (node:internal/modules/cjs/loader:1259:10)
    at Object.require.extensions.<computed> [as .ts] (/Users/brianpugh/projects/rp2040js/node_modules/ts-node/src/index.ts:1059:12)
    at Module.load (node:internal/modules/cjs/loader:1068:32)
    at Function.Module._load (node:internal/modules/cjs/loader:909:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:82:12)
    at main (/Users/brianpugh/projects/rp2040js/node_modules/ts-node/src/bin.ts:198:14)
    at Object.<anonymous> (/Users/brianpugh/projects/rp2040js/node_modules/ts-node/src/bin.ts:288:3)

This PR seems to fix my problems.

urish commented 1 year ago

Thank you!

What project are you working on?

BrianPugh commented 1 year ago

thanks for merging!

In a roundabout and funny way, I'm using it to aid in integration testing for Belay. Previously I tried:

  1. The micropython unix port, but it doesn't support proper raw-paste mode.
  2. The qemu-arm port, but it didn't have repl mode at all ready-to-go.

with rp2040js, nearly everything just worked immediately out of the box!

urish commented 1 year ago

That's a cool use case. Thanks for sharing!