Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 29 Jan 2000 14:52:25 +0200
From:      Giorgos Keramidas <charon@hades.hell.gr>
To:        courtney@whtz.com
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Serial ports in perl
Message-ID:  <20000129145225.E55491@hades.hell.gr>
In-Reply-To: <85256874.0059FE6B.00@mail.whtz.com>; from courtney@whtz.com on Fri, Jan 28, 2000 at 11:22:57AM -0500
References:  <85256874.0059FE6B.00@mail.whtz.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jan 28, 2000 at 11:22:57AM -0500, courtney@whtz.com wrote:
> 
> 
> Hey everyone-
> 
>      Question for the brain trust-
> 
> how would I go about access a serial port in FreeBSD in perl (I.E. I want
> to send a string from perl out the serial port...)

Like any normal file, open it with open(), read from it with <>, and
print to it with print().  What you want to know is the name of the
serial port to open each time.  Serial ports in BSD are named
/dev/cuaa? so the following piece sends a small string to the first
serial port (COM1, as MS-Dog users know it).

    open(MODEM, ">/dev/cuaa0") || die "could not open modem device";
    print MODEM "at\015";
    close MODEM;

-- 
Giorgos Keramidas, < keramida @ ceid . upatras . gr >
"Don't let your schooling interfere with your education." [Mark Twain]


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000129145225.E55491>