projects
/
vaillant-thermostat
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8456d46
)
microsecond time resultion and delay from last transmission
author
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 14 Oct 2016 12:31:51 +0000
(14:31 +0200)
committer
Dobrica Pavlinusic
<dpavlin@rot13.org>
Fri, 14 Oct 2016 12:31:51 +0000
(14:31 +0200)
serial.pl
patch
|
blob
|
history
diff --git
a/serial.pl
b/serial.pl
index
6620593
..
63372d0
100755
(executable)
--- a/
serial.pl
+++ b/
serial.pl
@@
-3,6
+3,9
@@
use warnings;
use strict;
use Device::SerialPort;
use Data::Dump qw(dump);
use strict;
use Device::SerialPort;
use Data::Dump qw(dump);
+use Time::HiRes qw(time);
+
+my $read_len = 255;
$|=1;
$|=1;
@@
-17,13
+20,18
@@
$s->read_const_time(3);
#$s->write('o');
#$s->write('o');
+my $t = time();
+
while (1) {
while (1) {
- my ($len, $string) = $s->read(255);
+ my ($len, $string) = $s->read($read_len);
+ my $ts = time();
if ( $len > 0 ) {
my $hex = unpack('H*',$string);
$hex =~ s/(..)/$1 /g;
if ( $len > 0 ) {
my $hex = unpack('H*',$string);
$hex =~ s/(..)/$1 /g;
- printf "%s %2d %s\n", time(), $len, $hex;
+ #printf "%s %2d %s\n", time(), $len, $hex;
+ printf "%8.4f %0.4f %2d %s\n", $ts, $ts - $t, $len, $hex;
+ $t = time();
}
}
}
}