in reply to Spoof /dev/ttyS0

I've done something like this a long time ago to fool a DosEMU emulated app into thinking I had a real modem, I just can't recall the exact details but it worked by hooking your perl "emulator" to /dev/pty(a..z)(0..9) (pick one). This enables the pty's slave device on /dev/tty(a..z)(0..9).

Different *nixes implement pseudo-terms differently, apparently on MacOS it's possible to have a /dev/ttyS0 backed by a /dev/ptyS0 but not entirely sure on that, it's been a while :)

Anyhow, you can read/write to the pty from your perl script, and anything that goes there ends up on the corresponding slave term where the application you're testing can read/write from it, thinking you've got a network device behind it.

As long as you can properly "emulate" things, it shouldn't be a problem.

(It is, however, probably not the nicest way to do this)

Replies are listed 'Best First'.
Re^2: Spoof /dev/ttyS0
by akujbida (Acolyte) on Sep 25, 2008 at 06:21 UTC
    This also sounds attractive, but now that I have the amazingly simple FIFO up, I'll pass on trying to figure this out. Your suggestion, however, is much appreciated and copied to my file of solutions, in case I need it.
      Yeah, if a FIFO works then stick with that, it's a lot simpler to deal with. The pty/tty thing will work when an application expects to be able to do some specific ioctl calls on the device (such as DosEMU). I dug up some more info on what I did and it was basically to use DosEMU to run a DOS based BBS software and make it telnettable (by fooling the BBS software into thinking it was talking to a modem when in reality it was talking to a telnet<->"modem" gateway thing). Anyway, rambling on here... :D
        Hey MadCat, keep rambling. It may seem useless to someone else, but its useful for me. I've been using DosBox to run my BBS server, but I want to run dosemu instead but haven't been able to figure out how to do it, so please ramble on! Or message me, either way. Thanks a ton, Noisome (noisomep (\@/) gmail.com)