I'm trying to use a perl script to communicate with external hardware (Arduino). I'm using Win32::SerialPort to drive things. Works well for the most part.

In some cases though, I wasn't able to communicate. After a board reset, the script didn't get any data. In this state, it appears the board is seeing my script, but it never responds. I found that running a "real" serial program (like PuTTY) makes it start working.

With the help of a serial sniffer, I see that my program does exactly what I asked it to (port, bps, stop bits), while PuTTY is also putting the port into DSR handshake mode. Presumably when I get no data the external board thinks that it shouldn't be sending me data.

I've tried several things in the code ($port->dtr_active(1), $port->rts_active(1)), but nothing I've tried has made my serial sniffer say anything new about the port settings when the script runs.

Is there some command or series of commands in this module (or others) that would facilitate this?

The insufficient code is:

use Win32::SerialPort; my $port = Win32::SerialPort->new("COM8") or die "New port failed. $!\n"; $port->baudrate(9600); # you may change this value $port->databits(8); # but not this and the two following $port->parity("none"); $port->stopbits(1); #$port->rts_active(1); # has no (useful) effect #$port->dtr_active(1); # has no (useful) effect ...

In reply to Put a serial port in handshake mode? by ddunham

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.