www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/08/13/19:44:35

From: "David Christensen" <dchristensen AT california DOT com>
Newsgroups: comp.os.msdos.djgpp,comp.lang.perl.misc
Subject: djgpp, Win98, Perl, and serial port
Date: Fri, 13 Aug 1999 16:17:50 -0700
Lines: 74
X-Newsreader: Microsoft Outlook Express 4.72.3110.1
X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3
NNTP-Posting-Host: 209.3.225.167
Message-ID: <37b4a540@news5.newsfeeds.com>
X-Trace: 13 Aug 1999 18:07:44 -0500, 209.3.225.167
X-Report: Report abuse to abuse AT newsfeeds DOT com
X-Abuse-Info: Please be sure to forward a copy of ALL headers, INCLUDING the body
X-Abuse-Info2: ALL Spam complaints are acted upon within 24 hours!
Organization: Newsfeeds.com http://www.newsfeeds.com 72,000+ UNCENSORED Newsgroups. Instant access!!
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

comp.os.msdos.djgpp
comp.lang.perl.misc

Hello, World!

I am running the FSF distribution of DJGPP 2.01 (?) and Perl
5.004_02 on my Win98 box.  I am attempting to communicate with a
machine we are developing via the serial port (9600 8-N-1).  I have
grep'ed and read through several docs (open, sysopen, perlfaq8,
config.h, ioctrl.h, etc.) trying to piece together the clues.  This
is my current attempt -- it's supposed to read ten lines from the
port, printing each on the screen and also echoing them back to the
sender, pausing 1 second after each:

      1 #!/fsf/bin/perl -w
      2 use FileHandle;
      3
      4 sysopen HANDLE, "COM1", O_RDWR | O_EXCL, 0700
      5     or die "sysopen failed: $!\n";
      6
      7 my $i = 10;
      8
      9 print "entering while loop ...\n";
     10 while ($i-- > 0 && defined($_ = <HANDLE>)) {
     11     print HANDLE $_;
     12     print $_;
     13     sleep 1;
     14     print "bottom of  while loop ...\n";
     15 }
     16 print "leaving while loop ...\n";
     17
     18 close HANDLE;


Both COM1 and COM2 are free on my machine, so I connected a null
modem cable between them.  When I run two instances of
Hyperterminal, one on each port, I can type back and forth between
the two.  When I shutdown Hyperterminal on COM1 and start the above
Perl code in a Bash box, one of two things happens:

1. It prints "entering while loop ..." and then hogs the machine
(typing on Hyperterminal 2 doesn't show up in Bash;  ctrl+C,
ctrl+D, and ctrl+Z don't work; need 3-finger salute to kill it), or

2. It prints "entering while loop ...", prints "leaving while loop
...", and then exits (encountered EOF on HANDLE?).


Searching around on Deja, it looks like people with ActivePerl have
some modules (Win32::SerialPort, Win32::CommPort, and Win32::API)
to make life easier.  There is also supposed to be a Un*x version
of ::SerialPort.


On 1999/07/23, Bbirthisel <bbirthisel AT aol DOT com> posted a message
"Re: What is the best way to write data to a com port under DOS."
to comp.lang.perl.misc:

>There is a gentleman in Japan who is working on limited COM port
support for the djgpp-built version of Perl - but he has not yet
released results.


Any suggestions?


TIA,

--
David Christensen
dchristensen AT california DOT com





  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019