home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!spool.mu.edu!sdd.hp.com!elroy.jpl.nasa.gov!ames!sun-barr!west.West.Sun.COM!cronkite.Central.Sun.COM!sixgun.East.Sun.COM!matthew
- From: matthew@sunpix.East.Sun.COM (Matthew Stier - Sun NC Development Center)
- Newsgroups: comp.lang.perl
- Subject: Handling serial ports in perl.
- Date: 11 Sep 1992 13:00:00 GMT
- Organization: Sun Microsystems, Research Triangle Park, NC
- Lines: 48
- Distribution: world
- Message-ID: <18q58gINN5sg@sixgun.East.Sun.COM>
- NNTP-Posting-Host: superdave.east.sun.com
- Summary: Anyone have a package to talk to devices?
-
-
- I'm trying to make a ipc server to talk to a device hanging off a serial
- port on a Sparcstation 1+.
-
- I've been able to emulate 'tip' using the following script, but would to
- know if anyone has written a package to talk to devices, or would have an
- idea on how to wrap this into a ipc server.
-
- {What I'm interested in, is to telnet to a host/port, issue commands which
- the server will feed to the device, and that the reply will be returned
- to requestor.}
-
-
- #!/usr/bin/perl
-
- $tty = "/dev/ttya";
-
- $SIG{'INT'} = 'dokill';
- sub dokill {
- kill 9,$child if $child;
- }
-
- if($child = fork) {
- # Parent
- open(TTY, "> $tty");
- system("stty raw > $tty"); # place the tty in the raw mode
- while (<STDIN>) {
- tr/a-z/A-Z/;
- last if /^QUIT/;
- print TTY;
- }
- sleep 1;
- do dokill();
- }
- else {
- # Child
- open(TTY, "< $tty");
- while(<TTY>) {
- print;
- }
- }
-
-
- --
- Matthew Lee Stier |
- Sun Microsystems --- RTP, NC 27709-3447 | "Wisconsin Escapee"
- Email: matthew.stier@East.Sun.COM |
- Phone: (919) 469-8300 fax: (919) 460-8355 |
-