use Win32::SerialPort; $PortName = "COM1"; $quiet = 0; $Configuration_File_Name = "c:/com1_config.txt"; $PortObj = new Win32::SerialPort ($PortName, $quiet) || die "Can't open $PortName: $^E\n"; # $quiet is optional $PortObj->user_msg(ON); $PortObj->databits(8); $PortObj->baudrate(1200); $PortObj->parity("none"); $PortObj->stopbits(1); $PortObj->handshake("none"); $PortObj->buffers(4096, 4096); $PortObj->write_settings || undef $PortObj; $PortObj->save($Configuration_File_Name); $PortObj->baudrate(300); $PortObj->restart($Configuration_File_Name); # back to 1200 baud ($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) = $PortObj->status || warn "could not get port status\n"; if ($BlockingFlags) { warn "Port is blocked"; } if ($BlockingFlags & BM_fCtsHold) { warn "Waiting for CTS"; } if ($LatchErrorFlags & CE_FRAME) { warn "Framing Error"; } ($count_in, $string_in) = $PortObj->read($InBytes); print "Count: $count_in \n"; print "String: $string_in \n"; $PortObj->close || die "failed to close"; undef $PortObj;