I have a strange problem with i am trying to send a command to a device over serial but the device do not respond. When i use a serial console app (hyperterminal) it works. but not with perl. The COM settings are same. with serial monitor, i can see same data going out from both instances. But the reply comes with hyperterminal and no response from perl script. the script is as below

#!/usr/bin/perl use Win32::SerialPort; use Win32API::CommPort; use strict; my $InBytes=12; my $val=2147483647; #my $timeout=10; # create some widgets here our $buffer = ''; our $PortObj1 = Win32::SerialPort->new ('COM16',0) or die "Can't open +serial port COM1: $^E\n"; $PortObj1->close or die "Can't close serial"; our $PortObj1 = Win32::SerialPort->new ('COM16',1) or die "Can't open +serial port COM1: $^E\n"; $PortObj1->baudrate(57600) or die "fail setting baud rate"; $PortObj1->parity("none") or die "fail setting parity"; $PortObj1->databits(8) or die "fail setting databits"; $PortObj1->stopbits(1) or die "fail setting stopbits"; $PortObj1->handshake("none") or die "fail setting handshake"; my $flowcontrol = $PortObj1->handshake; $PortObj1->buffers(4096, 4096); # read, write print "$flowcontrol\n"; $PortObj1->write_settings or die "fail write settings"; sleep(1); my $count_out = $PortObj1->write("V\r\r") or die "write failed:$^E"; print "$count_out"; closePort($PortObj1); sub closePort($) { my ($serial) = @_; $serial->close(); }
any tips appreciated thanks, jis

In reply to Serial Port win32 module by jismake

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.