bfdi533 has asked for the wisdom of the Perl Monks concerning the following question:

I have a rather complex seeming setup that I need help with. I need to be able to capture the input and output to a serial port WITHOUT blocking its use by other apps. I have vmware setup with win98 and there is a scanner application that is using this serial port. I have tried to cat the /dev/ttyS0 to a file but when I do this then vmware detects that it is open and will not run the scanner app.

I would like to do this somehow in Perl so that I can have more control in an environment that I am familiar with. (I know this can be done in C but have not a clue how to do it.)

Any insight from you Perl gods?

Ed Davison

Replies are listed 'Best First'.
Re: need to capture serial port output
by kutsu (Priest) on Sep 23, 2003 at 18:49 UTC

    Device::SerialPort might give you what you need.

    "Pain is weakness leaving the body, I find myself in pain everyday" -me

Re: need to capture serial port output
by ronzomckelvey (Acolyte) on Sep 24, 2003 at 03:30 UTC
    A long time ago I used to write interface programs that could talk to PBX's and other devices across serial ports (from SCO boxes). The concepts I used back when still would work now with Perl.

    example running of script:

    # tee input.txt</dev/ttyS0 | perl-prog.pl | tee output.txt >/dev/ttyS0
    What this does is take Standard Input from the serial port, tee puts a copy in input.txt, then pipes the data to your script, and finially all script output is sent through tee which logs it to a file again then out the serial port.

    When you write your perl script you just have to treat it like a user was typing in the data. Great when developing, as you just run the program and type in what you want. You let Linux handle all the IO to the serial port.

    Here's the actual start job from an old script:

    # start job SMDRdbctee harris.in < /dev/ttyr0a | SMDRdbc interfce | SMDRdbctee har +ris.out > /dev/ttyr0a &
    By linking tee to SMDRdbctee it's easy to see when doing ps.

    But in recent years I also moved onto Expect also for this type of work. ronzo

Re: need to capture serial port output
by Anonymous Monk on Sep 23, 2003 at 18:05 UTC
    Ever look at expect ? Expect is a program that "talks" to other interactive programs according to a script. I do alot of programming in Perl/Shell and others, and for serial port stuff or writinging programs that need to interact as a user, I've used expect. hope this helps some.

      No, actually; this does not help at all.

      The situation is that I do not need to talk to the serial port---I need to capture the data flowing to and from the serial scanner.

      Ed