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
any tips appreciated thanks, jis#!/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(); }
In reply to Serial Port win32 module by jismake
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |