#!/usr/bin/perl use strict; use warnings; use Win32::SerialPort; use Time::HiRes; my $PORT = "COM1"; # port to watch my $now; my $hex; my $inbyte; print "prog start \n"; my $starttime; $starttime = Time::HiRes::time(); $now = Time::HiRes::time() - $starttime; print "Before serial port iniialization time is: $now \n"; my $port = Win32::SerialPort->new($PORT) || die "Can't Open $PORT: $!"; $port->databits(8); $port->baudrate(9600); $port->parity("none"); $port->stopbits(1); while(1) { $inbyte=ord($port->read(1)); $hex = unpack('H2', "$inbyte"); if ($inbyte == 1){ # assume this is start of new packet $now = Time::HiRes::time() - $starttime; print "\n $now $hex"; } else { print " ", $hex; } }