Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to write bytes to serial port with Perl?

199 views
Skip to first unread message

Michael Shane Crowe

unread,
Dec 1, 1995, 3:00:00 AM12/1/95
to
I'm trying to write 9 bytes to a serial port with Perl, but it isn't working.
Below is the Perl script I am using, followed by my rc.Serial file if that
makes any difference. Does anyone know what I am missing here? Does Perl
need to know the baud rate? If so, how is that done?

Thanks,

Shane Crowe


Perl script:
#! /usr/bin/perl
$endSlip = pack("H18", "C0E70000000000FFC0"); #Here are the 9 bytes to send
open( PORT, "+>/dev/cua0" ); #Open the serial port
print PORT $endSlip; #Send packet to the port
close( PORT ); #Close the port

rc.serial file:
~#!/bin/sh
cd /dev

SETSERIAL="/bin/setserial -b"
PORTS=`echo cua? cua??`

${SETSERIAL} /dev/cua0 uart 16450 port 0x3F8 irq 4
${SETSERIAL} /dev/cua1 uart 16450 port 0x2F8 irq 3
${SETSERIAL} /dev/cua2 uart 16450 port 0x3E8 irq 5

echo "done."
${SETSERIAL} -bg ${PORTS}


Richard Nairn

unread,
Dec 2, 1995, 3:00:00 AM12/2/95
to
Michael Shane Crowe (sha...@bnr.ca) wrote:

: I'm trying to write 9 bytes to a serial port with Perl, but it isn't working.

: Below is the Perl script I am using, followed by my rc.Serial file if that
: makes any difference. Does anyone know what I am missing here? Does Perl
: need to know the baud rate? If so, how is that done?
:
: Thanks,
:
: Shane Crowe
:
:
: Perl script:
: #! /usr/bin/perl
: $endSlip = pack("H18", "C0E70000000000FFC0"); #Here are the 9 bytes to send
: open( PORT, "+>/dev/cua0" ); #Open the serial port
: print PORT $endSlip; #Send packet to the port
: close( PORT ); #Close the port
:

I tried out your little script sending it to a file and it worked, my
thought is that you are trying to end the slip connection by sending
that bytestream to your modem. Well, if you are connected then your
device is locked yes? That means no other program will be able to use
the modem... So your script is denied access to sending that packet
to your modem.. When you open the cua0, check to see if the open was
succesful. open (port, /dev/cua0) ||die ("Couldn't open device");
See if that is your problem...


--
From Lifes little instruction book II
# 870 Remember that great love and
great achievements involve great risk.
Richard Nairn ren...@acs.ucalgary.ca WWW: www.ucalgary.ca/~renairn/home.html

0 new messages