Hi, I am trying to figure out how to use the serial port in perl. I am using windows with ActivePerl. This is what I have so far: [CODE] $o_rs232Port = new Win32::SerialPort($ARGV[1]) || die "Can't open $ARGV[1]: $!"; $o_rs232Port->user_msg("ON"); $o_rs232Port->baudrate(115200) || die "Can't set 115200"; $o_rs232Port->parity("none") || die "Can't set parity none"; $o_rs232Port->databits(8) || die "Can't set 8 data bits"; $o_rs232Port->stopbits(1) || die "Can't set one stopbit"; $o_rs232Port->handshake("xoff") || die "Can't set flow control to xon/ xoff"; $o_rs232Port->buffers(4096, 4096); $o_rs232Port->write_settings || undef $o_rs232Port; print "Can't change Device_Control_Block: $^E\n" unless ($o_rs232Port);
($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) = $o_rs232Port- >status || die "could not get port status\n"; print "Status before write:$BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags\n"; $i_countOut = $o_rs232Port->write('N'); warn "write failed\n" unless ($i_countOut == 1); ($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) = $o_rs232Port- >status || die "could not get port status\n"; print "Status after write:$BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags\n"; ($i_countIn, $s_stringIn) = $o_rs232Port->read(1); warn "read unsuccessful\n" unless ($i_countIn == 1); # Close port $o_rs232Port->close || die "failed to close COM1"; # frees memory back to perl undef $o_rs232Port; [CODE] [RESULT] Status before write:4, , , Status after write:4, , , read unsuccessful [RESULT] It seems it writes fine but it won't read and I am clueless why. Thanks for any help, Amish -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/